package com.sdk.esc;

import com.prt.esc.printer.Printer;

import java.util.ArrayList;

public class PrinterUtils {
   private static ArrayList<Printer> printers = new ArrayList<>();

   public static ArrayList<Printer> getPrinters(){
      return printers;
   }

   public static void addPrinter(Printer printer){
      if (printer != null) {
         int index = -1;
         for (int i = 0; i < printers.size(); i++) {
            if (printers.get(i).getPrinterTAG().equals(printer.getPrinterTAG())) {
               index = i;
            }
         }
         if (index != -1) {
            printers.remove(index);
         }
         printers.add(printer);
      }
   }
}
