Interface UOMService
- All Superinterfaces:
Service
public interface UOMService extends Service
Provides APIs for the conversion of unit-of-measure values.
-
Method Summary
Modifier and Type Method Description double
convert(java.lang.String enumName, double value, java.lang.String valueUOM, java.lang.String targetUOM, PlatformUserContext context, Scope... scopes)
For an enumeration type, converts the given value from a source unit of measure to a target unit of measure.double
convertHierEnum(HierEnumConversionConfig hierEnumConversionConfig, double value, java.lang.String valueUOM, java.lang.String targetUOM, PlatformUserContext context, Scope... scopes)
For an enumeration type, converts the given value from a source unit of measure to a target unit of measure.double
convertHierEnum(HierEnumConversionData conversionData, double value, java.lang.String valueUOM, java.lang.String targetUOM, PlatformUserContext context, java.util.List<java.util.List<Scope>> scopes)
For an enumeration type, converts the given value from a source unit of measure to a target unit of measure.HierEnumConversionData
fetchHierEnumConversionData(HierEnumConversionConfig hierEnumConversionConfig, PlatformUserContext context, java.util.List<java.util.List<Scope>> scopes)
Return an in-memory cache of conversion data for the provided scopes.
-
Method Details
-
convert
double convert(java.lang.String enumName, double value, java.lang.String valueUOM, java.lang.String targetUOM, PlatformUserContext context, Scope... scopes)For an enumeration type, converts the given value from a source unit of measure to a target unit of measure. Requires the population of EnumConversionDef before use. Optionally, a list of Scopes can be provided. When provided, a conversion factor will be looked up for each Scope until one is found - if no Scoped factor is found, an exception is thrown- Parameters:
enumName
- enumeration Namevalue
- current value of UOMvalueUOM
- uom in which value is specifiedtargetUOM
- uom in which value needs to be convertedcontext
- Please referPlatformUserContext
scopes
- array of scopes. The value conversion will be performed with the first matching scope in the array. Please referScope
- Returns:
- converted value in targetUOM
-
convertHierEnum
double convertHierEnum(HierEnumConversionConfig hierEnumConversionConfig, double value, java.lang.String valueUOM, java.lang.String targetUOM, PlatformUserContext context, Scope... scopes)For an enumeration type, converts the given value from a source unit of measure to a target unit of measure. Requires the population of HierEnumConversionDef before use. Optionally, a list of Scopes(maximum 6) can be provided. When provided, a conversion factor will be looked up for the provided group of Scope - if no Scoped factor is found, an exception is thrown- Parameters:
hierEnumConversionConfig
-HierEnumConversionConfig
value
- current value of UOMvalueUOM
- uom in which value is specifiedtargetUOM
- uom in which value needs to be convertedcontext
- Please referPlatformUserContext
scopes
- array of scopes(maximum 6). The value conversion will be performed with the exact matching scope in the array. Please referScope
- Returns:
- converted value in targetUOM
-
fetchHierEnumConversionData
HierEnumConversionData fetchHierEnumConversionData(HierEnumConversionConfig hierEnumConversionConfig, PlatformUserContext context, java.util.List<java.util.List<Scope>> scopes)Return an in-memory cache of conversion data for the provided scopes. Should be called before invokingconvertHierEnum(HierEnumConversionData, double, String, String, PlatformUserContext, List)
- Parameters:
hierEnumConversionConfig
-HierEnumConversionConfig
context
- Please referPlatformUserContext
scopes
- list of scopes(maximum 6). The value conversion will be performed with the exact matching scope in the list. Please referScope
- Returns:
HierEnumConversionData
-
convertHierEnum
double convertHierEnum(HierEnumConversionData conversionData, double value, java.lang.String valueUOM, java.lang.String targetUOM, PlatformUserContext context, java.util.List<java.util.List<Scope>> scopes)For an enumeration type, converts the given value from a source unit of measure to a target unit of measure. Requires the population of HierEnumConversionDef before use and call to #fetchHierEnumConversionData(HierEnumConversionConfig, PlatformUserContext, List)
which cache the conversions for the provided scopes. A list of Scopes(maximum 6) should be provided. When provided, a conversion factor will be looked up for the provided group of Scope - if no Scoped factor is found, an exception is thrown- Parameters:
conversionData
-HierEnumConversionData
value
- current value of UOMvalueUOM
- uom in which value is specifiedtargetUOM
- uom in which value needs to be convertedcontext
- Please referPlatformUserContext
scopes
- list of scopes(maximum 6). The value conversion will be performed with the exact matching scope in the list. Please referScope
- Returns:
- converted value in targetUOM
-