/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package inport; import java.util.List; import java.util.Optional; /** * * @author topazh_ag */ public class Operation { private OperationTemplate template; private boolean fixation = false; private double start; private double duration; private MovingObject executor; private Optional bunker = Optional.empty(); private Optional intensity = Optional.empty(); private List resources; public void setIntensity(Optional intensity) { this.intensity = intensity; } public Optional getIntensity() { return intensity; } public Optional getBunker() { return bunker; } public void setBunker(Optional bunker) { this.bunker = bunker; } public boolean getFixation() { return fixation; } public void setFixation(boolean fixation) { this.fixation = fixation; } public List getResources() { return resources; } public void setResources(List resources) { this.resources = resources; } public MovingObject getExecutor() { return executor; } public void setExecutor(MovingObject executor) { this.executor = executor; } /** * Get the value of duration * * @return the value of duration */ public double getDuration() { return duration; } /** * Set the value of duration * * @param duration new value of duration */ public void setDuration(double duration) { this.duration = duration; } /** * Get the value of start * * @return the value of start */ public double getStart() { return start; } /** * Set the value of start * * @param start new value of start */ public void setStart(double start) { this.start = start; } /** * Get the value of template * * @return the value of template */ public OperationTemplate getTemplate() { return template; } /** * Set the value of template * * @param template new value of template */ public void setTemplate(OperationTemplate template) { this.template = template; } public Operation() { } @Override public String toString() { if (executor == null) { executor = ConversionUtil.getExecutor(template); } if (resources == null) { resources = ConversionUtil.getResources(template); } StringBuilder sb = new StringBuilder(); sb.append(template.getId()).append("; "); sb.append(fixation ? "F" : "R").append("; ").append(start).append("; ").append(duration); sb.append(" (").append(executor.getId()).append(" "); sb.append(bunker.map(b -> b.getId() + " ").orElse("")).append("["); boolean isFirst = true; for (MovingObject obj : resources) { if (isFirst) { isFirst = false; } else { sb.append(", "); } sb.append(obj.getId()); } sb.append("]"); sb.append(intensity.map(i -> " " + i).orElse("")); sb.append(")"); return sb.toString(); } }