/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package inport; import java.util.ArrayList; import java.util.List; import java.util.OptionalInt; /** * * @author topazh_ag */ public class LoadingTemplate extends OperationTemplate { private TransportShip loader; private OptionalInt loaderType = OptionalInt.empty(); private Storage storage; private List resources; private List resourcesTypes; private double intensity; private boolean withMooring; private Cargo cargo; public OptionalInt getLoaderType() { return loaderType; } public void setLoaderType(OptionalInt loaderType) { this.loaderType = loaderType; } /** * Get the value of resources * * @return the value of resources */ public List getResources() { return resources; } /** * Set the value of resources * * @param resources new value of resources */ public void setResources(List resources) { this.resources = resources; } public List getResourcesTypes() { return resourcesTypes; } public void setResourcesTypes(List resourcesTypes) { this.resourcesTypes = resourcesTypes; } public TransportShip getLoader() { return loader; } public void setLoader(TransportShip loader) { this.loader = loader; } public double getIntensity() { return intensity; } public void setIntensity(double intensity) { this.intensity = intensity; } public Storage getStorage() { return storage; } public void setStorage(Storage storage) { this.storage = storage; } public void setWithMooring(boolean withMooring) { this.withMooring = withMooring; } public boolean getWithMooring() { return withMooring; } public void setCargo(Cargo cargo) { this.cargo = cargo; } public Cargo getCargo() { return cargo; } public LoadingTemplate(TransportShip loader, Berth berth, Storage storage, Cargo cargo, List resourcesTypes, boolean withMooring, double intensity, int id) { super(id, berth); this.loader = loader; this.storage = storage; this.resources = new ArrayList<>(); this.resourcesTypes = new ArrayList<>(resourcesTypes); this.withMooring = withMooring; this.intensity = intensity; this.cargo = cargo; } public LoadingTemplate() { this.resources = new ArrayList<>(); this.resourcesTypes = new ArrayList<>(); } @Override public String toString() { String res = ""; boolean first = true; for(LoadingEquipment eq : resources) { if (!first) res += "," + eq.getId(); else res += eq.getId(); first = false; } for (Integer t : getResourcesTypes()) { if (!first) res += "," + t; else res += t; first = false; } int startId; if (loaderType.isPresent()) { startId = loaderType.getAsInt(); } else { startId = loader.getId(); } int source = startId; if (intensity>0) source = storage.getId(); int target = startId; if (intensity<=0) target = storage.getId(); return getId() + "; " + "loa; " + twtoString() + "; " + source + "; " + cargo.getId() + "; " + target + "; " + getStartLocation().getId() + "; [" + res +"]; " + Math.abs(intensity) + "; " + (withMooring ? "M" : "U"); } }