-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: introduce enum type PhysicalPropertyModel (#1148)
* feat: introduce enum type PhysicalPropertyModel * renamed functions related to setting and initializing physicalproperties in phase and physicalpropertyhandler. no change in system * test: add test
- Loading branch information
1 parent
5cc8177
commit e999736
Showing
16 changed files
with
236 additions
and
109 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
src/main/java/neqsim/physicalproperties/physicalpropertysystem/PhysicalPropertyModel.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
package neqsim.physicalproperties.physicalpropertysystem; | ||
|
||
import neqsim.util.exception.InvalidInputException; | ||
|
||
/** | ||
* Types of PhysicalPropertyModel. This is used when initializing PhysicalPropertyhandler. | ||
* | ||
* @author ASMF | ||
*/ | ||
public enum PhysicalPropertyModel { | ||
DEFAULT(0), WATER(1), GLYCOL(2), AMINE(3), CO2WATER(4), BASIC(6); | ||
|
||
/** Holder for old style integer pt. */ | ||
private final int value; | ||
/** Holder for old style string physical property description. */ | ||
|
||
// We know we'll never mutate this, so we can keep | ||
// a local copy for fast lookup in forName | ||
private static final PhysicalPropertyModel[] copyOfValues = values(); | ||
|
||
/** | ||
* Constructor for PhysicalPropertyModel enum. | ||
* | ||
* @param value Numeric value index for phase type | ||
*/ | ||
private PhysicalPropertyModel(int value) { | ||
this.value = value; | ||
} | ||
|
||
/** | ||
* Getter for property value. | ||
* | ||
* @return Numeric index of phase type | ||
*/ | ||
@Deprecated | ||
public int getValue() { | ||
return this.value; | ||
} | ||
|
||
/** | ||
* Get PhysicalPropertyType by name. | ||
* | ||
* @param name Name to get PhysicalPropertyType for. | ||
* @return PhysicalPropertyType object | ||
*/ | ||
public static PhysicalPropertyModel byName(String name) { | ||
for (PhysicalPropertyModel pt : copyOfValues) { | ||
if (pt.name().equals(name.toUpperCase())) { | ||
return pt; | ||
} | ||
} | ||
throw new RuntimeException( | ||
new InvalidInputException("PhysicalPropertyModel", "byName", "name", "is not valid.")); | ||
} | ||
|
||
/** | ||
* Get PhysicalPropertyModel by value. | ||
* | ||
* @param value Value to get PhysicalPropertyModel for. | ||
* @return PhysicalPropertyModel object | ||
*/ | ||
public static PhysicalPropertyModel byValue(int value) { | ||
for (PhysicalPropertyModel pt : copyOfValues) { | ||
if (pt.getValue() == (value)) { | ||
return pt; | ||
} | ||
} | ||
throw new RuntimeException( | ||
new InvalidInputException("PhysicalPropertyModel", "byValue", "value", "is not valid.")); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.