From 55adc69b57dab3082e64a20316c48ba90bd55f3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=85smund=20V=C3=A5ge=20Fannemel?= <34712686+asmfstatoil@users.noreply.github.com> Date: Thu, 21 Jul 2022 20:55:28 +0200 Subject: [PATCH] refact: auto format and auto fix snyk (#488) --- .../processEquipment/util/Recycle.java | 862 +++++++++--------- .../util/RecycleController.java | 399 ++++---- 2 files changed, 636 insertions(+), 625 deletions(-) diff --git a/src/main/java/neqsim/processSimulation/processEquipment/util/Recycle.java b/src/main/java/neqsim/processSimulation/processEquipment/util/Recycle.java index 9152150e1..640b05084 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/util/Recycle.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/util/Recycle.java @@ -1,7 +1,6 @@ package neqsim.processSimulation.processEquipment.util; import java.util.ArrayList; - import neqsim.processSimulation.processEquipment.ProcessEquipmentBaseClass; import neqsim.processSimulation.processEquipment.mixer.MixerInterface; import neqsim.processSimulation.processEquipment.stream.Stream; @@ -18,451 +17,452 @@ * @version $Id: $Id */ public class Recycle extends ProcessEquipmentBaseClass implements MixerInterface { - private static final long serialVersionUID = 1000; - - protected ArrayList streams = new ArrayList(0); - private ArrayList downstreamProperty = new ArrayList(0); - protected int numberOfInputStreams = 0; - protected StreamInterface mixedStream; - StreamInterface lastIterationStream = null; - private StreamInterface outletStream = null; - private double tolerance = 1e-4; - private double error = 1e6; - private int priority = 100; - boolean firstTime = true; - int iterations = 0; - int maxIterations = 10; - - /** - *

- * Constructor for Recycle. - *

- */ - @Deprecated - public Recycle() { - this("Recycle"); - } - - /** - *

- * Constructor for Recycle. - *

- * - * @param name a {@link java.lang.String} object - */ - public Recycle(String name) { - super(name); - } - - /** {@inheritDoc} */ - @Override - public SystemInterface getThermoSystem() { - return mixedStream.getThermoSystem(); - } - - /** - *

- * Setter for the field downstreamProperty. - *

- * - * @param property a {@link java.lang.String} object - */ - public void setDownstreamProperty(String property) { - downstreamProperty.add(property); + private static final long serialVersionUID = 1000; + + protected ArrayList streams = new ArrayList(0); + private ArrayList downstreamProperty = new ArrayList(0); + protected int numberOfInputStreams = 0; + protected StreamInterface mixedStream; + StreamInterface lastIterationStream = null; + private StreamInterface outletStream = null; + private double tolerance = 1e-4; + private double error = 1e6; + private int priority = 100; + boolean firstTime = true; + int iterations = 0; + int maxIterations = 10; + + /** + *

+ * Constructor for Recycle. + *

+ */ + @Deprecated + public Recycle() { + this("Recycle"); + } + + /** + *

+ * Constructor for Recycle. + *

+ * + * @param name a {@link java.lang.String} object + */ + public Recycle(String name) { + super(name); + } + + /** {@inheritDoc} */ + @Override + public SystemInterface getThermoSystem() { + return mixedStream.getThermoSystem(); + } + + /** + *

+ * Setter for the field downstreamProperty. + *

+ * + * @param property a {@link java.lang.String} object + */ + public void setDownstreamProperty(String property) { + downstreamProperty.add(property); + } + + /** {@inheritDoc} */ + @Override + public void replaceStream(int i, StreamInterface newStream) { + streams.set(i, newStream); + } + + /** {@inheritDoc} */ + @Override + public void addStream(StreamInterface newStream) { + streams.add(newStream); + + if (numberOfInputStreams == 0) { + mixedStream = streams.get(0).clone(); + // mixedStream.getThermoSystem().setNumberOfPhases(2); + // mixedStream.getThermoSystem().reInitPhaseType(); + // mixedStream.getThermoSystem().init(0); + // mixedStream.getThermoSystem().init(3); } - - /** {@inheritDoc} */ - @Override - public void replaceStream(int i, StreamInterface newStream) { - streams.set(i, newStream); - } - - /** {@inheritDoc} */ - @Override - public void addStream(StreamInterface newStream) { - streams.add(newStream); - - if (numberOfInputStreams == 0) { - mixedStream = streams.get(0).clone(); - // mixedStream.getThermoSystem().setNumberOfPhases(2); - // mixedStream.getThermoSystem().reInitPhaseType(); - // mixedStream.getThermoSystem().init(0); - // mixedStream.getThermoSystem().init(3); + mixedStream.setEmptyThermoSystem(streams.get(0).getThermoSystem()); + numberOfInputStreams++; + lastIterationStream = mixedStream.clone(); + } + + /** + *

+ * getStream. + *

+ * + * @param i a int + * @return a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} object + */ + public StreamInterface getStream(int i) { + return streams.get(i); + } + + /** + *

+ * mixStream. + *

+ */ + public void mixStream() { + int index = 0; + // String compName = new String(); + + for (int k = 1; k < streams.size(); k++) { + for (int i = 0; i < streams.get(k).getThermoSystem().getPhase(0) + .getNumberOfComponents(); i++) { + boolean gotComponent = false; + String componentName = + streams.get(k).getThermoSystem().getPhase(0).getComponent(i).getName(); + // System.out.println("adding: " + componentName); + // int numberOfPhases = streams.get(k).getThermoSystem().getNumberOfPhases(); + + double moles = + streams.get(k).getThermoSystem().getPhase(0).getComponent(i).getNumberOfmoles(); + // System.out.println("moles: " + moles + " " + + // mixedStream.getThermoSystem().getPhase(0).getNumberOfComponents()); + for (int p = 0; p < mixedStream.getThermoSystem().getPhase(0) + .getNumberOfComponents(); p++) { + if (mixedStream.getThermoSystem().getPhase(0).getComponent(p).getName() + .equals(componentName)) { + gotComponent = true; + index = + streams.get(0).getThermoSystem().getPhase(0).getComponent(p).getComponentNumber(); + // compName = streams.get(0).getThermoSystem().getPhase(0).getComponent(p) + // .getComponentName(); + } } - mixedStream.setEmptyThermoSystem(streams.get(0).getThermoSystem()); - numberOfInputStreams++; - lastIterationStream = mixedStream.clone(); - } - /** - *

- * getStream. - *

- * - * @param i a int - * @return a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} object - */ - public StreamInterface getStream(int i) { - return streams.get(i); - } - - /** - *

- * mixStream. - *

- */ - public void mixStream() { - int index = 0; - // String compName = new String(); - - for (int k = 1; k < streams.size(); k++) { - for (int i = 0; i < streams.get(k).getThermoSystem().getPhase(0) - .getNumberOfComponents(); i++) { - boolean gotComponent = false; - String componentName = - streams.get(k).getThermoSystem().getPhase(0).getComponent(i).getName(); - // System.out.println("adding: " + componentName); - // int numberOfPhases = streams.get(k).getThermoSystem().getNumberOfPhases(); - - double moles = streams.get(k).getThermoSystem().getPhase(0).getComponent(i) - .getNumberOfmoles(); - // System.out.println("moles: " + moles + " " + - // mixedStream.getThermoSystem().getPhase(0).getNumberOfComponents()); - for (int p = 0; p < mixedStream.getThermoSystem().getPhase(0) - .getNumberOfComponents(); p++) { - if (mixedStream.getThermoSystem().getPhase(0).getComponent(p).getName() - .equals(componentName)) { - gotComponent = true; - index = streams.get(0).getThermoSystem().getPhase(0).getComponent(p) - .getComponentNumber(); - // compName = streams.get(0).getThermoSystem().getPhase(0).getComponent(p) - // .getComponentName(); - } - } - - if (gotComponent) { - // System.out.println("adding moles starting...."); - mixedStream.getThermoSystem().addComponent(index, moles); - // mixedStream.getThermoSystem().init_x_y(); - // System.out.println("adding moles finished"); - } else { - System.out.println("ikke gaa hit"); - mixedStream.getThermoSystem().addComponent(index, moles); - } - } - } - // mixedStream.getThermoSystem().init_x_y(); - // mixedStream.getThermoSystem().initBeta(); - // mixedStream.getThermoSystem().init(2); - } - - /** - *

- * guessTemperature. - *

- * - * @return a double - */ - public double guessTemperature() { - double gtemp = 0; - for (int k = 0; k < streams.size(); k++) { - gtemp += streams.get(k).getThermoSystem().getTemperature() - * streams.get(k).getThermoSystem().getNumberOfMoles() - / mixedStream.getThermoSystem().getNumberOfMoles(); - } - return gtemp; - } - - /** - *

- * calcMixStreamEnthalpy. - *

- * - * @return a double - */ - public double calcMixStreamEnthalpy() { - double enthalpy = 0; - for (int k = 0; k < streams.size(); k++) { - streams.get(k).getThermoSystem().init(3); - enthalpy += streams.get(k).getThermoSystem().getEnthalpy(); - // System.out.println("total enthalpy k : " + ( ((Stream) - // streams.get(k)).getThermoSystem()).getEnthalpy()); - } - // System.out.println("total enthalpy of streams: " + enthalpy); - return enthalpy; - } - - /** {@inheritDoc} */ - @Deprecated - public StreamInterface getOutStream() { - return mixedStream; - } - - /** - *

- * initiateDownstreamProperties. - *

- * - * @param outstream a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} - * object - */ - public void initiateDownstreamProperties(StreamInterface outstream) { - lastIterationStream = outstream.clone(); - } - - /** - *

- * setDownstreamProperties. - *

- */ - public void setDownstreamProperties() { - if (downstreamProperty.size() > 0) { - for (int i = 0; i < downstreamProperty.size(); i++) { - if (downstreamProperty.get(i).equals("flow rate")) - mixedStream.setFlowRate(outletStream.getFlowRate("kg/hr"), "kg/hr"); - } - } - } - - /** {@inheritDoc} */ - @Override - public void run() { - iterations++; - /* - * if(firstTime || iterations>maxIterations) { firstTime=false; return; - * - * } - */ - double enthalpy = 0.0; - // System.out.println("flow rate old in recycle " + - // outletStream.getFlowRate("kg/hr")); - // ((Stream) streams.get(0)).getThermoSystem().display(); - SystemInterface thermoSystem2 = streams.get(0).getThermoSystem().clone(); - // System.out.println("total number of moles " + - // thermoSystem2.getTotalNumberOfMoles()); - mixedStream.setThermoSystem(thermoSystem2); - ThermodynamicOperations testOps = new ThermodynamicOperations(thermoSystem2); - if (streams.size() > 1) { - mixedStream.getThermoSystem().setNumberOfPhases(2); - mixedStream.getThermoSystem().reInitPhaseType(); - mixedStream.getThermoSystem().init(0); - - mixStream(); - - setDownstreamProperties(); - try { - enthalpy = calcMixStreamEnthalpy(); - } catch (Exception e) { - // String error = e.getMessage(); - return; - } - // System.out.println("temp guess " + guessTemperature()); - mixedStream.getThermoSystem().setTemperature(guessTemperature()); - testOps.PHflash(enthalpy, 0); - // System.out.println("filan temp " + mixedStream.getTemperature()); + if (gotComponent) { + // System.out.println("adding moles starting...."); + mixedStream.getThermoSystem().addComponent(index, moles); + // mixedStream.getThermoSystem().init_x_y(); + // System.out.println("adding moles finished"); } else { - setDownstreamProperties(); - testOps.TPflash(); + System.out.println("ikke gaa hit"); + mixedStream.getThermoSystem().addComponent(index, moles); } - setError(massBalanceCheck()); - System.out.println(name + " recycle error: " + getError()); - lastIterationStream = (Stream) mixedStream.clone(); - outletStream.setThermoSystem(mixedStream.getThermoSystem()); - // System.out.println("flow rate new in recycle " + - // outletStream.getFlowRate("kg/hr")); - - // System.out.println("enthalpy: " + - // mixedStream.getThermoSystem().getEnthalpy()); - // System.out.println("enthalpy: " + enthalpy); - // System.out.println("temperature: " + - // mixedStream.getThermoSystem().getTemperature()); - - // System.out.println("beta " + mixedStream.getThermoSystem().getBeta()); - // outStream.setThermoSystem(mixedStream.getThermoSystem()); + } } - - /** - *

- * massBalanceCheck. - *

- * - * @return a double - */ - public double massBalanceCheck() { - double error = 0.0; - // System.out.println("flow rate new " + - // mixedStream.getThermoSystem().getFlowRate("kg/hr")); - // System.out.println("temperature " + - // mixedStream.getThermoSystem().getTemperature("C")); - // System.out.println("pressure " + - // mixedStream.getThermoSystem().getPressure("bara")); - if (lastIterationStream.getFluid().getNumberOfComponents() != mixedStream.getFluid() - .getNumberOfComponents()) { - return 10.0; - } - for (int i = 0; i < mixedStream.getThermoSystem().getPhase(0) - .getNumberOfComponents(); i++) { - // System.out.println("x last " + - // lastIterationStream.getThermoSystem().getPhase(0).getComponent(i).getx()); - // System.out.println("x new " + - // mixedStream.getThermoSystem().getPhase(0).getComponent(i).getx()); - error += Math.abs(mixedStream.getThermoSystem().getPhase(0).getComponent(i).getx() - - lastIterationStream.getThermoSystem().getPhase(0).getComponent(i).getx()); - } - return Math.abs(error); + // mixedStream.getThermoSystem().init_x_y(); + // mixedStream.getThermoSystem().initBeta(); + // mixedStream.getThermoSystem().init(2); + } + + /** + *

+ * guessTemperature. + *

+ * + * @return a double + */ + public double guessTemperature() { + double gtemp = 0; + for (int k = 0; k < streams.size(); k++) { + gtemp += streams.get(k).getThermoSystem().getTemperature() + * streams.get(k).getThermoSystem().getNumberOfMoles() + / mixedStream.getThermoSystem().getNumberOfMoles(); } - - /** {@inheritDoc} */ - @Override - public void displayResult() {} - - /** {@inheritDoc} */ - @Override - public void setPressure(double pres) { - for (int k = 0; k < streams.size(); k++) { - streams.get(k).getThermoSystem().setPressure(pres); - } - mixedStream.getThermoSystem().setPressure(pres); + return gtemp; + } + + /** + *

+ * calcMixStreamEnthalpy. + *

+ * + * @return a double + */ + public double calcMixStreamEnthalpy() { + double enthalpy = 0; + for (int k = 0; k < streams.size(); k++) { + streams.get(k).getThermoSystem().init(3); + enthalpy += streams.get(k).getThermoSystem().getEnthalpy(); + // System.out.println("total enthalpy k : " + ( ((Stream) + // streams.get(k)).getThermoSystem()).getEnthalpy()); } - - /** - *

- * setTemperature. - *

- * - * @param temp a double - */ - public void setTemperature(double temp) { - for (int k = 0; k < streams.size(); k++) { - streams.get(k).getThermoSystem().setTemperature(temp); + // System.out.println("total enthalpy of streams: " + enthalpy); + return enthalpy; + } + + /** {@inheritDoc} */ + @Deprecated + public StreamInterface getOutStream() { + return mixedStream; + } + + /** + *

+ * initiateDownstreamProperties. + *

+ * + * @param outstream a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} + * object + */ + public void initiateDownstreamProperties(StreamInterface outstream) { + lastIterationStream = outstream.clone(); + } + + /** + *

+ * setDownstreamProperties. + *

+ */ + public void setDownstreamProperties() { + if (downstreamProperty.size() > 0) { + for (int i = 0; i < downstreamProperty.size(); i++) { + if (downstreamProperty.get(i).equals("flow rate")) { + mixedStream.setFlowRate(outletStream.getFlowRate("kg/hr"), "kg/hr"); } - mixedStream.getThermoSystem().setTemperature(temp); - } - - /** - *

- * Getter for the field tolerance. - *

- * - * @return the tolerance - */ - public double getTolerance() { - return tolerance; - } - - /** - *

- * Setter for the field tolerance. - *

- * - * @param tolerance the tolerance to set - */ - public void setTolerance(double tolerance) { - this.tolerance = tolerance; - } - - /** - *

- * Getter for the field error. - *

- * - * @return the error - */ - public double getError() { - return error; + } } - - /** - *

- * Setter for the field error. - *

- * - * @param error the error to set - */ - public void setError(double error) { - this.error = error; - } - - /** - *

- * Getter for the field priority. - *

- * - * @return a int + } + + /** {@inheritDoc} */ + @Override + public void run() { + iterations++; + /* + * if(firstTime || iterations>maxIterations) { firstTime=false; return; + * + * } */ - public int getPriority() { - return priority; - } - - /** - *

- * Setter for the field priority. - *

- * - * @param priority a int - */ - public void setPriority(int priority) { - this.priority = priority; - } - - /** {@inheritDoc} */ - @Override - public boolean solved() { - if (error < tolerance) - return true; - else - return false; + double enthalpy = 0.0; + // System.out.println("flow rate old in recycle " + + // outletStream.getFlowRate("kg/hr")); + // ((Stream) streams.get(0)).getThermoSystem().display(); + SystemInterface thermoSystem2 = streams.get(0).getThermoSystem().clone(); + // System.out.println("total number of moles " + + // thermoSystem2.getTotalNumberOfMoles()); + mixedStream.setThermoSystem(thermoSystem2); + ThermodynamicOperations testOps = new ThermodynamicOperations(thermoSystem2); + if (streams.size() > 1) { + mixedStream.getThermoSystem().setNumberOfPhases(2); + mixedStream.getThermoSystem().reInitPhaseType(); + mixedStream.getThermoSystem().init(0); + + mixStream(); + + setDownstreamProperties(); + try { + enthalpy = calcMixStreamEnthalpy(); + } catch (Exception e) { + // String error = e.getMessage(); + return; + } + // System.out.println("temp guess " + guessTemperature()); + mixedStream.getThermoSystem().setTemperature(guessTemperature()); + testOps.PHflash(enthalpy, 0); + // System.out.println("filan temp " + mixedStream.getTemperature()); + } else { + setDownstreamProperties(); + testOps.TPflash(); } - - /** - *

- * Getter for the field downstreamProperty. - *

- * - * @return a {@link java.util.ArrayList} object - */ - public ArrayList getDownstreamProperty() { - return downstreamProperty; + setError(massBalanceCheck()); + System.out.println(name + " recycle error: " + getError()); + lastIterationStream = (Stream) mixedStream.clone(); + outletStream.setThermoSystem(mixedStream.getThermoSystem()); + // System.out.println("flow rate new in recycle " + + // outletStream.getFlowRate("kg/hr")); + + // System.out.println("enthalpy: " + + // mixedStream.getThermoSystem().getEnthalpy()); + // System.out.println("enthalpy: " + enthalpy); + // System.out.println("temperature: " + + // mixedStream.getThermoSystem().getTemperature()); + + // System.out.println("beta " + mixedStream.getThermoSystem().getBeta()); + // outStream.setThermoSystem(mixedStream.getThermoSystem()); + } + + /** + *

+ * massBalanceCheck. + *

+ * + * @return a double + */ + public double massBalanceCheck() { + double error = 0.0; + // System.out.println("flow rate new " + + // mixedStream.getThermoSystem().getFlowRate("kg/hr")); + // System.out.println("temperature " + + // mixedStream.getThermoSystem().getTemperature("C")); + // System.out.println("pressure " + + // mixedStream.getThermoSystem().getPressure("bara")); + if (lastIterationStream.getFluid().getNumberOfComponents() != mixedStream.getFluid() + .getNumberOfComponents()) { + return 10.0; } - - /** - *

- * Setter for the field downstreamProperty. - *

- * - * @param upstreamProperty a {@link java.util.ArrayList} object - */ - public void setDownstreamProperty(ArrayList upstreamProperty) { - this.downstreamProperty = upstreamProperty; + for (int i = 0; i < mixedStream.getThermoSystem().getPhase(0).getNumberOfComponents(); i++) { + // System.out.println("x last " + + // lastIterationStream.getThermoSystem().getPhase(0).getComponent(i).getx()); + // System.out.println("x new " + + // mixedStream.getThermoSystem().getPhase(0).getComponent(i).getx()); + error += Math.abs(mixedStream.getThermoSystem().getPhase(0).getComponent(i).getx() + - lastIterationStream.getThermoSystem().getPhase(0).getComponent(i).getx()); } - - /** - *

- * Getter for the field outletStream. - *

- * - * @return a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} object - */ - public StreamInterface getOutletStream() { - return outletStream; + return Math.abs(error); + } + + /** {@inheritDoc} */ + @Override + public void displayResult() {} + + /** {@inheritDoc} */ + @Override + public void setPressure(double pres) { + for (int k = 0; k < streams.size(); k++) { + streams.get(k).getThermoSystem().setPressure(pres); } - - /** - *

- * Setter for the field outletStream. - *

- * - * @param outletStream a - * {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} object - */ - public void setOutletStream(StreamInterface outletStream) { - this.outletStream = outletStream; - lastIterationStream = this.outletStream.clone(); + mixedStream.getThermoSystem().setPressure(pres); + } + + /** + *

+ * setTemperature. + *

+ * + * @param temp a double + */ + public void setTemperature(double temp) { + for (int k = 0; k < streams.size(); k++) { + streams.get(k).getThermoSystem().setTemperature(temp); } - - /** {@inheritDoc} */ - @Override - public void removeInputStream(int i) { - streams.remove(i); + mixedStream.getThermoSystem().setTemperature(temp); + } + + /** + *

+ * Getter for the field tolerance. + *

+ * + * @return the tolerance + */ + public double getTolerance() { + return tolerance; + } + + /** + *

+ * Setter for the field tolerance. + *

+ * + * @param tolerance the tolerance to set + */ + public void setTolerance(double tolerance) { + this.tolerance = tolerance; + } + + /** + *

+ * Getter for the field error. + *

+ * + * @return the error + */ + public double getError() { + return error; + } + + /** + *

+ * Setter for the field error. + *

+ * + * @param error the error to set + */ + public void setError(double error) { + this.error = error; + } + + /** + *

+ * Getter for the field priority. + *

+ * + * @return a int + */ + public int getPriority() { + return priority; + } + + /** + *

+ * Setter for the field priority. + *

+ * + * @param priority a int + */ + public void setPriority(int priority) { + this.priority = priority; + } + + /** {@inheritDoc} */ + @Override + public boolean solved() { + if (error < tolerance) { + return true; + } else { + return false; } + } + + /** + *

+ * Getter for the field downstreamProperty. + *

+ * + * @return a {@link java.util.ArrayList} object + */ + public ArrayList getDownstreamProperty() { + return downstreamProperty; + } + + /** + *

+ * Setter for the field downstreamProperty. + *

+ * + * @param upstreamProperty a {@link java.util.ArrayList} object + */ + public void setDownstreamProperty(ArrayList upstreamProperty) { + this.downstreamProperty = upstreamProperty; + } + + /** + *

+ * Getter for the field outletStream. + *

+ * + * @return a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} object + */ + public StreamInterface getOutletStream() { + return outletStream; + } + + /** + *

+ * Setter for the field outletStream. + *

+ * + * @param outletStream a {@link neqsim.processSimulation.processEquipment.stream.StreamInterface} + * object + */ + public void setOutletStream(StreamInterface outletStream) { + this.outletStream = outletStream; + lastIterationStream = this.outletStream.clone(); + } + + /** {@inheritDoc} */ + @Override + public void removeInputStream(int i) { + streams.remove(i); + } } diff --git a/src/main/java/neqsim/processSimulation/processEquipment/util/RecycleController.java b/src/main/java/neqsim/processSimulation/processEquipment/util/RecycleController.java index a2e7b6d67..227bf53ae 100644 --- a/src/main/java/neqsim/processSimulation/processEquipment/util/RecycleController.java +++ b/src/main/java/neqsim/processSimulation/processEquipment/util/RecycleController.java @@ -12,210 +12,221 @@ * @version $Id: $Id */ public class RecycleController implements java.io.Serializable { - private static final long serialVersionUID = 1000; - - ArrayList recycleArray = new ArrayList(); - ArrayList priorityArray = new ArrayList(); - private int currentPriorityLevel = 100; - private int minimumPriorityLevel = 100; - private int maximumPriorityLevel = 100; - - /** - *

- * Constructor for RecycleController. - *

- */ - public RecycleController() {} - - /** - *

- * init. - *

- */ - public void init() { - for (Recycle recyc : recycleArray) { - if (recyc.getPriority() < minimumPriorityLevel) - minimumPriorityLevel = recyc.getPriority(); - if (recyc.getPriority() > maximumPriorityLevel) - maximumPriorityLevel = recyc.getPriority(); - } - - currentPriorityLevel = minimumPriorityLevel; - } - - /** - *

- * resetPriorityLevel. - *

- */ - public void resetPriorityLevel() { - currentPriorityLevel = minimumPriorityLevel; + private static final long serialVersionUID = 1000; + + ArrayList recycleArray = new ArrayList(); + ArrayList priorityArray = new ArrayList(); + private int currentPriorityLevel = 100; + private int minimumPriorityLevel = 100; + private int maximumPriorityLevel = 100; + + /** + *

+ * Constructor for RecycleController. + *

+ */ + public RecycleController() {} + + /** + *

+ * init. + *

+ */ + public void init() { + for (Recycle recyc : recycleArray) { + if (recyc.getPriority() < minimumPriorityLevel) { + minimumPriorityLevel = recyc.getPriority(); + } + if (recyc.getPriority() > maximumPriorityLevel) { + maximumPriorityLevel = recyc.getPriority(); + } } - /** - *

- * addRecycle. - *

- * - * @param recycle a {@link neqsim.processSimulation.processEquipment.util.Recycle} object - */ - public void addRecycle(Recycle recycle) { - recycleArray.add(recycle); - priorityArray.add(recycle.getPriority()); + currentPriorityLevel = minimumPriorityLevel; + } + + /** + *

+ * resetPriorityLevel. + *

+ */ + public void resetPriorityLevel() { + currentPriorityLevel = minimumPriorityLevel; + } + + /** + *

+ * addRecycle. + *

+ * + * @param recycle a {@link neqsim.processSimulation.processEquipment.util.Recycle} object + */ + public void addRecycle(Recycle recycle) { + recycleArray.add(recycle); + priorityArray.add(recycle.getPriority()); + } + + /** + *

+ * doSolveRecycle. + *

+ * + * @param recycle a {@link neqsim.processSimulation.processEquipment.util.Recycle} object + * @return a boolean + */ + public boolean doSolveRecycle(Recycle recycle) { + if (recycle.getPriority() == getCurrentPriorityLevel()) { + return true; + } else { + return false; } - - /** - *

- * doSolveRecycle. - *

- * - * @param recycle a {@link neqsim.processSimulation.processEquipment.util.Recycle} object - * @return a boolean - */ - public boolean doSolveRecycle(Recycle recycle) { - if (recycle.getPriority() == getCurrentPriorityLevel()) - return true; - else - return false; + } + + /** + *

+ * isHighestPriority. + *

+ * + * @param recycle a {@link neqsim.processSimulation.processEquipment.util.Recycle} object + * @return a boolean + */ + public boolean isHighestPriority(Recycle recycle) { + if (recycle.getPriority() == maximumPriorityLevel) { + return true; + } else { + return false; } - - /** - *

- * isHighestPriority. - *

- * - * @param recycle a {@link neqsim.processSimulation.processEquipment.util.Recycle} object - * @return a boolean - */ - public boolean isHighestPriority(Recycle recycle) { - if (recycle.getPriority() == maximumPriorityLevel) - return true; - else - return false; - } - - /** - *

- * solvedCurrentPriorityLevel. - *

- * - * @return a boolean - */ - public boolean solvedCurrentPriorityLevel() { - for (Recycle recyc : recycleArray) { - if (recyc.getPriority() == currentPriorityLevel) { - if (!recyc.solved()) - return false; - } + } + + /** + *

+ * solvedCurrentPriorityLevel. + *

+ * + * @return a boolean + */ + public boolean solvedCurrentPriorityLevel() { + for (Recycle recyc : recycleArray) { + if (recyc.getPriority() == currentPriorityLevel) { + if (!recyc.solved()) { + return false; } - return true; + } } - - /** - *

- * nextPriorityLevel. - *

- */ - public void nextPriorityLevel() { - currentPriorityLevel = maximumPriorityLevel; + return true; + } + + /** + *

+ * nextPriorityLevel. + *

+ */ + public void nextPriorityLevel() { + currentPriorityLevel = maximumPriorityLevel; + } + + /** + *

+ * hasLoverPriorityLevel. + *

+ * + * @return a boolean + */ + public boolean hasLoverPriorityLevel() { + if (currentPriorityLevel > minimumPriorityLevel) { + return true; + } else { + return false; } - - /** - *

- * hasLoverPriorityLevel. - *

- * - * @return a boolean - */ - public boolean hasLoverPriorityLevel() { - if (currentPriorityLevel > minimumPriorityLevel) { - return true; - } else - return false; + } + + /** + *

+ * hasHigherPriorityLevel. + *

+ * + * @return a boolean + */ + public boolean hasHigherPriorityLevel() { + if (currentPriorityLevel < maximumPriorityLevel) { + return true; + } else { + return false; } - - /** - *

- * hasHigherPriorityLevel. - *

- * - * @return a boolean - */ - public boolean hasHigherPriorityLevel() { - if (currentPriorityLevel < maximumPriorityLevel) { - return true; - } else - return false; + } + + /** + *

+ * solvedAll. + *

+ * + * @return a boolean + */ + public boolean solvedAll() { + for (Recycle recyc : recycleArray) { + if (!recyc.solved()) { + return false; + } } - - /** - *

- * solvedAll. - *

- * - * @return a boolean - */ - public boolean solvedAll() { - for (Recycle recyc : recycleArray) { - if (!recyc.solved()) - return false; - } - return true; - } - - /** - *

- * clear. - *

- */ - public void clear() { - recycleArray.clear(); - priorityArray.clear(); - } - - /** - *

- * Getter for the field currentPriorityLevel. - *

- * - * @return a int - */ - public int getCurrentPriorityLevel() { - return currentPriorityLevel; + return true; + } + + /** + *

+ * clear. + *

+ */ + public void clear() { + recycleArray.clear(); + priorityArray.clear(); + } + + /** + *

+ * Getter for the field currentPriorityLevel. + *

+ * + * @return a int + */ + public int getCurrentPriorityLevel() { + return currentPriorityLevel; + } + + /** + *

+ * Setter for the field currentPriorityLevel. + *

+ * + * @param currentPriorityLevel a int + */ + public void setCurrentPriorityLevel(int currentPriorityLevel) { + this.currentPriorityLevel = currentPriorityLevel; + } + + /** {@inheritDoc} */ + @Override + public int hashCode() { + return Objects.hash(currentPriorityLevel, maximumPriorityLevel, minimumPriorityLevel, + priorityArray, recycleArray); + } + + /** {@inheritDoc} */ + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; } - - /** - *

- * Setter for the field currentPriorityLevel. - *

- * - * @param currentPriorityLevel a int - */ - public void setCurrentPriorityLevel(int currentPriorityLevel) { - this.currentPriorityLevel = currentPriorityLevel; + if (obj == null) { + return false; } - - /** {@inheritDoc} */ - @Override - public int hashCode() { - return Objects.hash(currentPriorityLevel, maximumPriorityLevel, minimumPriorityLevel, - priorityArray, recycleArray); - } - - /** {@inheritDoc} */ - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - RecycleController other = (RecycleController) obj; - return currentPriorityLevel == other.currentPriorityLevel - && maximumPriorityLevel == other.maximumPriorityLevel - && minimumPriorityLevel == other.minimumPriorityLevel - && Objects.equals(priorityArray, other.priorityArray) - && Objects.equals(recycleArray, other.recycleArray); + if (getClass() != obj.getClass()) { + return false; } + RecycleController other = (RecycleController) obj; + return currentPriorityLevel == other.currentPriorityLevel + && maximumPriorityLevel == other.maximumPriorityLevel + && minimumPriorityLevel == other.minimumPriorityLevel + && Objects.equals(priorityArray, other.priorityArray) + && Objects.equals(recycleArray, other.recycleArray); + } }