Utilities
Converters
General purpose converters (java.util.Functions) for performing value conversions throughout the automation
interface are provided. These converters are referenced from the AutomationInterface documentation wherever they apply.
The AutomationInterface is typed strongly. In some cases, however, e.g. when specifying file locations, it is desirable
to allow for a range of possibly parameter types. This is achieved by accepting parameters of type Object and
converting the given parameters to the desired type.
The following converters are provided:
ScriptConverters.TO_PATH
Attempts to convert arbitraryObjects to Paths usingIAutomationPathsApi.resolvePath(Object) IAutomationPathsApi.resolvePath.
ScriptConverters.TO_SCRIPT_PATH
Attempts to convert arbitraryObjects to Paths using
IAutomationPathsApi.resolveScriptPath(Object) IAutomationPathsApi.resolveScriptPath.
ScriptConverters.TO_VERSION
Attempts to convert arbitraryObjects to IVersions. The following conversions are
implemented:
- For
nullorIVersionarguments the given argument is returned. No conversion is applied. Strings are converted usingVersion.valueOf(String).Numbers are converted by converting theintobtained fromNumber.intValue()usingVersion.valueOf(int).- All other
Objects are converted by converting theStringobtained fromObject.toString().
ScriptConverters.TO_BIG_INTEGER
Attempts to convert arbitraryObjects to BigIntegers. The following
conversions are implemented:
- For
nullorBigIntegerarguments the given argument is returned. No conversion is applied. Integers,Longs,Shorts andBytes are converted usingBigInteger.valueOf(long).- All other types of objects are interpreted as
Strings (Object.toString()) and passed toBigInteger.BigInteger(String).
ScriptConverters.TO_BIG_DECIMAL
Attempts to convert arbitraryObjects to Doubles. The following
conversions are implemented:
- For
nullorDoublearguments the given argument is returned. No conversion is applied. Floats andDoubles, are converted usingDouble.valueOf(double).Integers,Longs,Shorts andBytes are converted usingDouble.valueOf(double).- All other types of objects are interpreted as
Strings (Object.toString()) and passed toDouble.Double(String).
ModelConverters.TO_MDF
Attempts to convert arbitraryObjects to MDFObjects. The following conversions are
implemented:
- For
nullorMDFObjectarguments the given argument is returned. No conversion is applied. IHasModelObjects are converted using theirIHasModelObject.getMdfObject()method.IViewedModelObjects are converted using theirIViewedModelObject.getMdfObject()method.- For all other
ObjectsClassCastExceptions are thrown.
Exceptions see the used functions described above.