From 2f27f1ff5c117ff3bd2316c58c85979ec0b9d3e1 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, 27 Feb 2024 14:08:14 +0100 Subject: [PATCH] refact: deprecate getting phase from name --- .../java/neqsim/thermo/system/SystemInterface.java | 10 +++++++++- src/main/java/neqsim/thermo/system/SystemThermo.java | 9 +-------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/main/java/neqsim/thermo/system/SystemInterface.java b/src/main/java/neqsim/thermo/system/SystemInterface.java index 75db75ed2f..5cb9a059d3 100644 --- a/src/main/java/neqsim/thermo/system/SystemInterface.java +++ b/src/main/java/neqsim/thermo/system/SystemInterface.java @@ -628,7 +628,10 @@ public default double getGamma2() { * @param phaseTypeName a {@link java.lang.String} object * @return a {@link neqsim.thermo.phase.PhaseInterface} object */ - public PhaseInterface getPhase(String phaseTypeName); + @Deprecated + public default PhaseInterface getPhase(String phaseTypeName) { + return getPhase(PhaseType.byDesc(phaseTypeName)); + } /** *

@@ -666,6 +669,7 @@ public default double getGamma2() { * @param phaseTypeName a {@link java.lang.String} object * @return PhaseIndex to index into phaseArray. */ + @Deprecated public int getPhaseIndex(String phaseTypeName); /** @@ -925,6 +929,7 @@ public default double getGamma2() { * supported) * @return a {@link neqsim.thermo.phase.PhaseInterface} object */ + @Deprecated public PhaseInterface getPhaseOfType(String phaseTypeName); /** @@ -1018,6 +1023,7 @@ public void addPlusFraction(String componentName, double numberOfMoles, double m * @param phaseTypeName PhaseType to look for * @return True if system contains a phase of requested type */ + @Deprecated public default boolean hasPhaseType(String phaseTypeName) { return hasPhaseType(PhaseType.byDesc(phaseTypeName)); } @@ -2209,6 +2215,7 @@ public default ComponentInterface getComponent(int i) { * @param unit mole/volume/weight * @return phase: fraction in specified unit */ + @Deprecated public double getPhaseFraction(String phaseTypeName, String unit); /** @@ -2383,6 +2390,7 @@ public default double getNumberOfMoles() { * @param phaseTypeName Name of phase type to look for * @return Phase number */ + @Deprecated public default int getPhaseNumberOfPhase(String phaseTypeName) { return getPhaseNumberOfPhase(PhaseType.byDesc(phaseTypeName)); } diff --git a/src/main/java/neqsim/thermo/system/SystemThermo.java b/src/main/java/neqsim/thermo/system/SystemThermo.java index d8fe26cbd6..a42d561741 100644 --- a/src/main/java/neqsim/thermo/system/SystemThermo.java +++ b/src/main/java/neqsim/thermo/system/SystemThermo.java @@ -2352,13 +2352,6 @@ public PhaseInterface getPhase(PhaseType pt) { return null; } - /** {@inheritDoc} */ - @Override - public PhaseInterface getPhase(String phaseTypeName) { - PhaseType pt = PhaseType.byDesc(phaseTypeName); - return getPhase(pt); - } - /** {@inheritDoc} */ @Override public PhaseInterface getPhaseOfType(String phaseTypeName) { @@ -2392,7 +2385,7 @@ public final int getPhaseIndex(int index) { @Override public int getPhaseIndex(String phaseTypeName) { // TODO: returning first if not found, not same as the others. - for (int i = 0; i < numberOfPhases; i++) { + for (int i = 0; i < getNumberOfPhases(); i++) { if (getPhase(i).getPhaseTypeName().equals(phaseTypeName)) { return phaseIndex[i]; }