From 1cb105aaf0663e17a824af68a7c7b4da2dcae5e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=85smund=20V=C3=A5ge=20Fannemel?= <34712686+asmfstatoil@users.noreply.github.com> Date: Tue, 19 Mar 2024 09:23:33 +0100 Subject: [PATCH] refact: reorder methods using eclipse reorder code --- .../neqsim/api/ioc/CalculationResult.java | 20 ++--- .../dataPresentation/SampleXYDataSource.java | 40 +++++----- .../dataPresentation/dataHandeling.java | 78 +++++++++---------- src/main/java/neqsim/util/unit/BaseUnit.java | 4 +- .../java/neqsim/util/unit/NeqSimUnitSet.java | 64 +++++++-------- .../java/neqsim/util/unit/PressureUnit.java | 54 ++++++------- src/main/java/neqsim/util/unit/RateUnit.java | 24 +++--- .../neqsim/util/unit/TemperatureUnit.java | 32 ++++---- src/main/java/neqsim/util/unit/Unit.java | 20 ++--- .../neqsim/util/util/DoubleCloneable.java | 16 ++-- 10 files changed, 176 insertions(+), 176 deletions(-) diff --git a/src/main/java/neqsim/api/ioc/CalculationResult.java b/src/main/java/neqsim/api/ioc/CalculationResult.java index e81fcee28..89dceb2a9 100644 --- a/src/main/java/neqsim/api/ioc/CalculationResult.java +++ b/src/main/java/neqsim/api/ioc/CalculationResult.java @@ -27,16 +27,6 @@ public CalculationResult(Double[][] fluidProperties, String[] calculationError) this.calculationError = calculationError; } - /** {@inheritDoc} */ - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + Arrays.hashCode(calculationError); - result = prime * result + Arrays.deepHashCode(fluidProperties); - return result; - } - /** {@inheritDoc} */ @Override public boolean equals(Object obj) { @@ -53,4 +43,14 @@ public boolean equals(Object obj) { return Arrays.equals(calculationError, other.calculationError) && Arrays.deepEquals(fluidProperties, other.fluidProperties); } + + /** {@inheritDoc} */ + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + Arrays.hashCode(calculationError); + result = prime * result + Arrays.deepHashCode(fluidProperties); + return result; + } } diff --git a/src/main/java/neqsim/dataPresentation/SampleXYDataSource.java b/src/main/java/neqsim/dataPresentation/SampleXYDataSource.java index 56b34fb76..5e67e71ce 100644 --- a/src/main/java/neqsim/dataPresentation/SampleXYDataSource.java +++ b/src/main/java/neqsim/dataPresentation/SampleXYDataSource.java @@ -59,25 +59,13 @@ public SampleXYDataSource(double[][] p, String[] name, String title, String xaxi } /** - * Returns the x-value for the specified series and item. Series are numbered 0, 1, ... - * - * @param series The index (zero-based) of the series; - * @param item The index (zero-based) of the required item; - * @return The x-value for the specified series and item. - */ - public Number getXValue(int series, int item) { - return (Double.valueOf(points[2 * series][item])); - } - - /** - * Returns the y-value for the specified series and item. Series are numbered 0, 1, ... + * Returns the number of items in the specified series. * * @param series The index (zero-based) of the series; - * @param item The index (zero-based) of the required item; - * @return The y-value for the specified series and item. + * @return The number of items in the specified series. */ - public Number getYValue(int series, int item) { - return (Double.valueOf(points[(series * 2 + 1)][item])); + public int getItemCount(int series) { + return items[series]; } /** @@ -100,12 +88,24 @@ public String getSeriesName(int series) { } /** - * Returns the number of items in the specified series. + * Returns the x-value for the specified series and item. Series are numbered 0, 1, ... * * @param series The index (zero-based) of the series; - * @return The number of items in the specified series. + * @param item The index (zero-based) of the required item; + * @return The x-value for the specified series and item. */ - public int getItemCount(int series) { - return items[series]; + public Number getXValue(int series, int item) { + return (Double.valueOf(points[2 * series][item])); + } + + /** + * Returns the y-value for the specified series and item. Series are numbered 0, 1, ... + * + * @param series The index (zero-based) of the series; + * @param item The index (zero-based) of the required item; + * @return The y-value for the specified series and item. + */ + public Number getYValue(int series, int item) { + return (Double.valueOf(points[(series * 2 + 1)][item])); } } diff --git a/src/main/java/neqsim/dataPresentation/dataHandeling.java b/src/main/java/neqsim/dataPresentation/dataHandeling.java index 4ce655f07..d8d45d853 100644 --- a/src/main/java/neqsim/dataPresentation/dataHandeling.java +++ b/src/main/java/neqsim/dataPresentation/dataHandeling.java @@ -26,32 +26,39 @@ public class dataHandeling { */ public dataHandeling() {} + /** + * Returns the number of items in the specified series. + * + * @param series The index (zero-based) of the series; + * @return The number of items in the specified series. + */ + public int getItemCount(int series) { + return 81; + } + /** *

- * getXValue. + * getLegendItemCount. *

* - * @param series a int - * @param item a int - * @return a {@link java.lang.Number} object + * @return a int */ - public Number getXValue(int series, int item) { - return Double.valueOf(-10.0 + (item * 0.2)); + public int getLegendItemCount() { + return 2; } /** - * Returns the y-value for the specified series and item. Series are numbered 0, 1, ... + *

+ * getLegendItemLabels. + *

* - * @param series The index (zero-based) of the series; - * @param item The index (zero-based) of the required item; - * @return The y-value for the specified series and item. + * @return an array of {@link java.lang.String} objects */ - public Number getYValue(int series, int item) { - if (series == 0) { - return Double.valueOf(Math.cos(-10.0 + (item * 0.2))); - } else { - return Double.valueOf(2 * (Math.sin(-10.0 + (item * 0.2)))); - } + public String[] getLegendItemLabels() { + String[] str = new String[2]; + str[1] = ""; + str[2] = ""; + return str; } /** @@ -79,39 +86,32 @@ public String getSeriesName(int series) { } } - /** - * Returns the number of items in the specified series. - * - * @param series The index (zero-based) of the series; - * @return The number of items in the specified series. - */ - public int getItemCount(int series) { - return 81; - } - /** *

- * getLegendItemCount. + * getXValue. *

* - * @return a int + * @param series a int + * @param item a int + * @return a {@link java.lang.Number} object */ - public int getLegendItemCount() { - return 2; + public Number getXValue(int series, int item) { + return Double.valueOf(-10.0 + (item * 0.2)); } /** - *

- * getLegendItemLabels. - *

+ * Returns the y-value for the specified series and item. Series are numbered 0, 1, ... * - * @return an array of {@link java.lang.String} objects + * @param series The index (zero-based) of the series; + * @param item The index (zero-based) of the required item; + * @return The y-value for the specified series and item. */ - public String[] getLegendItemLabels() { - String[] str = new String[2]; - str[1] = ""; - str[2] = ""; - return str; + public Number getYValue(int series, int item) { + if (series == 0) { + return Double.valueOf(Math.cos(-10.0 + (item * 0.2))); + } else { + return Double.valueOf(2 * (Math.sin(-10.0 + (item * 0.2)))); + } } /** diff --git a/src/main/java/neqsim/util/unit/BaseUnit.java b/src/main/java/neqsim/util/unit/BaseUnit.java index 502aacf75..7407e5963 100644 --- a/src/main/java/neqsim/util/unit/BaseUnit.java +++ b/src/main/java/neqsim/util/unit/BaseUnit.java @@ -43,13 +43,13 @@ public double getSIvalue() { /** {@inheritDoc} */ @Override - public double getValue(String fromunit) { + public double getValue(double val, String fromunit, String tounit) { throw new UnsupportedOperationException("Unimplemented method 'getValue'"); } /** {@inheritDoc} */ @Override - public double getValue(double val, String fromunit, String tounit) { + public double getValue(String fromunit) { throw new UnsupportedOperationException("Unimplemented method 'getValue'"); } } diff --git a/src/main/java/neqsim/util/unit/NeqSimUnitSet.java b/src/main/java/neqsim/util/unit/NeqSimUnitSet.java index f7b5b8a41..aa050d6e0 100644 --- a/src/main/java/neqsim/util/unit/NeqSimUnitSet.java +++ b/src/main/java/neqsim/util/unit/NeqSimUnitSet.java @@ -9,6 +9,14 @@ * @version $Id: $Id */ public class NeqSimUnitSet { + private String temperatureUnit = "K"; + + private String pressureUnit = "bara"; + + private String flowRateUnit = "mol/sec"; + + private String componentConcentrationUnit = "molefraction"; + /** *

* Getter for the field componentConcentrationUnit. @@ -22,70 +30,67 @@ public String getComponentConcentrationUnit() { /** *

- * Setter for the field componentConcentrationUnit. + * Getter for the field flowRateUnit. *

* - * @param componentConcentrationUnit the componentConcentrationUnit to set + * @return the flowRateUnit */ - public void setComponentConcentrationUnit(String componentConcentrationUnit) { - this.componentConcentrationUnit = componentConcentrationUnit; + public String getFlowRateUnit() { + return flowRateUnit; } /** *

- * Getter for the field flowRateUnit. + * Getter for the field pressureUnit. *

* - * @return the flowRateUnit + * @return the pressureUnit */ - public String getFlowRateUnit() { - return flowRateUnit; + public String getPressureUnit() { + return pressureUnit; } /** *

- * Setter for the field flowRateUnit. + * Getter for the field temperatureUnit. *

* - * @param flowRateUnit the flowRateUnit to set + * @return the temperatureUnit */ - public void setFlowRateUnit(String flowRateUnit) { - this.flowRateUnit = flowRateUnit; + public String getTemperatureUnit() { + return temperatureUnit; } /** *

- * Getter for the field pressureUnit. + * Setter for the field componentConcentrationUnit. *

* - * @return the pressureUnit + * @param componentConcentrationUnit the componentConcentrationUnit to set */ - public String getPressureUnit() { - return pressureUnit; + public void setComponentConcentrationUnit(String componentConcentrationUnit) { + this.componentConcentrationUnit = componentConcentrationUnit; } - /** *

- * Setter for the field pressureUnit. + * Setter for the field flowRateUnit. *

* - * @param pressureUnit the pressureUnit to set + * @param flowRateUnit the flowRateUnit to set */ - public void setPressureUnit(String pressureUnit) { - this.pressureUnit = pressureUnit; + public void setFlowRateUnit(String flowRateUnit) { + this.flowRateUnit = flowRateUnit; } - /** *

- * Getter for the field temperatureUnit. + * Setter for the field pressureUnit. *

* - * @return the temperatureUnit + * @param pressureUnit the pressureUnit to set */ - public String getTemperatureUnit() { - return temperatureUnit; + public void setPressureUnit(String pressureUnit) { + this.pressureUnit = pressureUnit; } - /** *

* Setter for the field temperatureUnit. @@ -96,9 +101,4 @@ public String getTemperatureUnit() { public void setTemperatureUnit(String temperatureUnit) { this.temperatureUnit = temperatureUnit; } - - private String temperatureUnit = "K"; - private String pressureUnit = "bara"; - private String flowRateUnit = "mol/sec"; - private String componentConcentrationUnit = "molefraction"; } diff --git a/src/main/java/neqsim/util/unit/PressureUnit.java b/src/main/java/neqsim/util/unit/PressureUnit.java index de81e055a..0cee5417a 100644 --- a/src/main/java/neqsim/util/unit/PressureUnit.java +++ b/src/main/java/neqsim/util/unit/PressureUnit.java @@ -26,33 +26,6 @@ public PressureUnit(double value, String unit) { super(value, unit); } - /** {@inheritDoc} */ - @Override - public double getValue(double val, String fromunit, String tounit) { - invalue = val; - return getConversionFactor(fromunit) / getConversionFactor(tounit) * invalue; - } - - /** {@inheritDoc} */ - @Override - public double getValue(String tounit) { - if (tounit.equals("barg")) { - return (getConversionFactor(inunit) / getConversionFactor("bara")) * invalue - - ThermodynamicConstantsInterface.referencePressure; - } else if (inunit.equals("barg")) { - return (getConversionFactor(inunit) / getConversionFactor("bara")) * invalue - + ThermodynamicConstantsInterface.referencePressure; - } else if (tounit.equals("atm")) { - return (getConversionFactor(inunit) / getConversionFactor("bara")) * invalue - / ThermodynamicConstantsInterface.referencePressure; - } else if (inunit.equals("atm")) { - return (getConversionFactor(inunit) / getConversionFactor("bara")) * invalue - * ThermodynamicConstantsInterface.referencePressure; - } else { - return getConversionFactor(inunit) / getConversionFactor(tounit) * invalue; - } - } - /** *

* getConversionFactor. @@ -95,4 +68,31 @@ public double getConversionFactor(String name) { return conversionFactor; } + + /** {@inheritDoc} */ + @Override + public double getValue(double val, String fromunit, String tounit) { + invalue = val; + return getConversionFactor(fromunit) / getConversionFactor(tounit) * invalue; + } + + /** {@inheritDoc} */ + @Override + public double getValue(String tounit) { + if (tounit.equals("barg")) { + return (getConversionFactor(inunit) / getConversionFactor("bara")) * invalue + - ThermodynamicConstantsInterface.referencePressure; + } else if (inunit.equals("barg")) { + return (getConversionFactor(inunit) / getConversionFactor("bara")) * invalue + + ThermodynamicConstantsInterface.referencePressure; + } else if (tounit.equals("atm")) { + return (getConversionFactor(inunit) / getConversionFactor("bara")) * invalue + / ThermodynamicConstantsInterface.referencePressure; + } else if (inunit.equals("atm")) { + return (getConversionFactor(inunit) / getConversionFactor("bara")) * invalue + * ThermodynamicConstantsInterface.referencePressure; + } else { + return getConversionFactor(inunit) / getConversionFactor(tounit) * invalue; + } + } } diff --git a/src/main/java/neqsim/util/unit/RateUnit.java b/src/main/java/neqsim/util/unit/RateUnit.java index 21bf9714e..a0ebac47c 100644 --- a/src/main/java/neqsim/util/unit/RateUnit.java +++ b/src/main/java/neqsim/util/unit/RateUnit.java @@ -45,18 +45,6 @@ public RateUnit(double value, String name, double molarmass, double stddens, dou this.boilp = boilp; } - /** {@inheritDoc} */ - @Override - public double getSIvalue() { - return getConversionFactor(inunit) / getConversionFactor("SI") * invalue; - } - - /** {@inheritDoc} */ - @Override - public double getValue(String tounit) { - return getConversionFactor(inunit) / getConversionFactor(tounit) * invalue; - } - /** *

* getConversionFactor. @@ -122,4 +110,16 @@ public double getConversionFactor(String name) { return factor; } + + /** {@inheritDoc} */ + @Override + public double getSIvalue() { + return getConversionFactor(inunit) / getConversionFactor("SI") * invalue; + } + + /** {@inheritDoc} */ + @Override + public double getValue(String tounit) { + return getConversionFactor(inunit) / getConversionFactor(tounit) * invalue; + } } diff --git a/src/main/java/neqsim/util/unit/TemperatureUnit.java b/src/main/java/neqsim/util/unit/TemperatureUnit.java index dbd450cd1..339252c7b 100644 --- a/src/main/java/neqsim/util/unit/TemperatureUnit.java +++ b/src/main/java/neqsim/util/unit/TemperatureUnit.java @@ -23,22 +23,6 @@ public TemperatureUnit(double value, String name) { super(value, name); } - /** {@inheritDoc} */ - @Override - public double getValue(double val, String fromunit, String tounit) { - invalue = val; - return getConversionFactor(fromunit) / getConversionFactor(tounit) * invalue; - } - - /** {@inheritDoc} */ - @Override - public double getValue(String tounit) { - if (tounit.equals("C")) { - return getConversionFactor(inunit) / getConversionFactor("K") * invalue - 273.15; - } - return getConversionFactor(inunit) / getConversionFactor(tounit) * invalue; - } - /** *

* getConversionFactor. @@ -59,4 +43,20 @@ public double getConversionFactor(String name) { } return conversionFactor; } + + /** {@inheritDoc} */ + @Override + public double getValue(double val, String fromunit, String tounit) { + invalue = val; + return getConversionFactor(fromunit) / getConversionFactor(tounit) * invalue; + } + + /** {@inheritDoc} */ + @Override + public double getValue(String tounit) { + if (tounit.equals("C")) { + return getConversionFactor(inunit) / getConversionFactor("K") * invalue - 273.15; + } + return getConversionFactor(inunit) / getConversionFactor(tounit) * invalue; + } } diff --git a/src/main/java/neqsim/util/unit/Unit.java b/src/main/java/neqsim/util/unit/Unit.java index cde4b08c2..da6e78743 100644 --- a/src/main/java/neqsim/util/unit/Unit.java +++ b/src/main/java/neqsim/util/unit/Unit.java @@ -24,16 +24,6 @@ public interface Unit { */ double getSIvalue(); - /** - *

- * Get process value in specified unit. - *

- * - * @param tounit Unit to get process value in. - * @return Value converted to the specified unit. - */ - double getValue(String tounit); - /** *

* getValue. @@ -45,4 +35,14 @@ public interface Unit { * @return a double */ double getValue(double val, String fromunit, String tounit); + + /** + *

+ * Get process value in specified unit. + *

+ * + * @param tounit Unit to get process value in. + * @return Value converted to the specified unit. + */ + double getValue(String tounit); } diff --git a/src/main/java/neqsim/util/util/DoubleCloneable.java b/src/main/java/neqsim/util/util/DoubleCloneable.java index 47a6f72fc..29ae698ee 100644 --- a/src/main/java/neqsim/util/util/DoubleCloneable.java +++ b/src/main/java/neqsim/util/util/DoubleCloneable.java @@ -49,23 +49,23 @@ public DoubleCloneable clone() { /** *

- * set. + * doubleValue. *

* - * @param val a double + * @return a double */ - public void set(double val) { - doubleValue = val; + public double doubleValue() { + return doubleValue; } /** *

- * doubleValue. + * set. *

* - * @return a double + * @param val a double */ - public double doubleValue() { - return doubleValue; + public void set(double val) { + doubleValue = val; } }