Package org.openmuc.jeebus.spine.utils
Class SpineUtilities
- java.lang.Object
-
- org.openmuc.jeebus.spine.utils.SpineUtilities
-
public class SpineUtilities extends java.lang.Object
-
-
Field Summary
Fields Modifier and Type Field Description static java.time.format.DateTimeFormatterFORMATTER
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.LongdateTimeToRelativeMilliseconds(java.lang.String dateTime)static java.lang.LongdurationToRelativeMilliseconds(java.lang.String duration)static org.openmuc.jeebus.spine.xsd.v1.EntityAddressTypeextractEntityAddress(org.openmuc.jeebus.spine.xsd.v1.EntityAddressType address)static org.openmuc.jeebus.spine.xsd.v1.FeatureAddressTypegetAddressCopy(org.openmuc.jeebus.spine.xsd.v1.FeatureAddressType address)static java.lang.DoublegetCalculatedScaledValue(org.openmuc.jeebus.spine.xsd.v1.ScaledNumberType scaledNumberObject)Returns the actual value of a ScaledNumberType object as Double.static org.openmuc.jeebus.spine.xsd.v1.CmdControlTypegetDeleteCmdControl()static java.lang.StringgetNowTimestamp()Use this method to get the current timestamp in UTC.static org.openmuc.jeebus.spine.xsd.v1.CmdControlTypegetPartialCmdControl()static java.lang.StringgetThreadName(java.lang.String useCaseName, java.lang.String actor)static booleanisDirectSubentity(org.openmuc.jeebus.spine.xsd.v1.EntityAddressType entityAddressChild, org.openmuc.jeebus.spine.xsd.v1.EntityAddressType entityAddressParent)Is entityAddressChild a direct child of entityAddressParent?static booleanisFilterDeleteSet(org.openmuc.jeebus.spine.xsd.v1.CmdType cmdType)static booleanisFilterPartialSet(org.openmuc.jeebus.spine.xsd.v1.CmdType cmdType)static booleanisSubAddress(org.openmuc.jeebus.spine.xsd.v1.EntityAddressType parentAddress, org.openmuc.jeebus.spine.xsd.v1.FeatureAddressType childAddress)static <E extends java.lang.Enum<E>>
booleanisValidEnumValue(java.lang.Class<E> clazz, java.lang.String name)Returns if a string is a valid value of a given enum.static java.lang.StringsimplifyCmd(org.openmuc.jeebus.spine.xsd.v1.CmdType what)static java.lang.StringsimplifyCmds(org.openmuc.jeebus.spine.xsd.v1.DatagramType what)static java.lang.StringsimplifyDatagram(org.openmuc.jeebus.spine.xsd.v1.DatagramType what)static booleansupportsPartialRead(org.openmuc.jeebus.spine.xsd.v1.NodeManagementDetailedDiscoveryDataType detailedDiscoveryData, java.lang.String featureName, java.lang.String functionName)static booleantimestampIsInInterval(java.lang.String timestampString, org.openmuc.jeebus.spine.xsd.v1.TimestampIntervalType interval)Checks if a given timestamp is in given interval.static java.lang.LongtoRelativeMilliseconds(java.lang.String time)
-
-
-
Method Detail
-
getNowTimestamp
public static java.lang.String getNowTimestamp()
Use this method to get the current timestamp in UTC. It is formatted withFORMATTERusing the patternyyyy-MM-dd'T'HH:mm:ss'Z'.- Returns:
- the current timestamp
-
simplifyDatagram
public static java.lang.String simplifyDatagram(org.openmuc.jeebus.spine.xsd.v1.DatagramType what)
- Returns:
- a simplified String representation of the whole Datagram. The format is "source command cmd -> destination"
-
simplifyCmds
public static java.lang.String simplifyCmds(org.openmuc.jeebus.spine.xsd.v1.DatagramType what)
- Returns:
- a simplified String representation of the CmdTypes contained in the given Datagram.
-
simplifyCmd
public static java.lang.String simplifyCmd(org.openmuc.jeebus.spine.xsd.v1.CmdType what)
- Returns:
- a simplified String representation of the given CmdType
-
getThreadName
public static java.lang.String getThreadName(java.lang.String useCaseName, java.lang.String actor)
-
getPartialCmdControl
public static org.openmuc.jeebus.spine.xsd.v1.CmdControlType getPartialCmdControl()
-
getDeleteCmdControl
public static org.openmuc.jeebus.spine.xsd.v1.CmdControlType getDeleteCmdControl()
-
getAddressCopy
public static org.openmuc.jeebus.spine.xsd.v1.FeatureAddressType getAddressCopy(org.openmuc.jeebus.spine.xsd.v1.FeatureAddressType address)
-
extractEntityAddress
public static org.openmuc.jeebus.spine.xsd.v1.EntityAddressType extractEntityAddress(org.openmuc.jeebus.spine.xsd.v1.EntityAddressType address)
-
durationToRelativeMilliseconds
public static java.lang.Long durationToRelativeMilliseconds(java.lang.String duration) throws java.lang.IllegalArgumentException- Parameters:
duration- A String representing a relative time (xs:duration)- Returns:
- the given time converted to relative milliseconds from now
- Throws:
java.lang.IllegalArgumentException
-
dateTimeToRelativeMilliseconds
public static java.lang.Long dateTimeToRelativeMilliseconds(java.lang.String dateTime) throws java.time.format.DateTimeParseException- Parameters:
dateTime- A String representing an absolute time (xs:dateTime)- Returns:
- the given time converted to relative milliseconds from now
- Throws:
java.time.format.DateTimeParseException
-
toRelativeMilliseconds
public static java.lang.Long toRelativeMilliseconds(java.lang.String time) throws java.time.format.DateTimeParseException- Parameters:
time- A String representing an absolute time (xs:dateTime) or a relative time (xs:duration)- Returns:
- the given time converted to relative milliseconds from now
- Throws:
java.time.format.DateTimeParseException
-
isDirectSubentity
public static boolean isDirectSubentity(org.openmuc.jeebus.spine.xsd.v1.EntityAddressType entityAddressChild, org.openmuc.jeebus.spine.xsd.v1.EntityAddressType entityAddressParent)Is entityAddressChild a direct child of entityAddressParent?- Parameters:
entityAddressChild- proposed childentityAddressParent- proposed parent- Returns:
- true if entityAddressChild is a direct child of entityAddressParent, else false
-
isSubAddress
public static boolean isSubAddress(org.openmuc.jeebus.spine.xsd.v1.EntityAddressType parentAddress, org.openmuc.jeebus.spine.xsd.v1.FeatureAddressType childAddress)
-
isFilterPartialSet
public static boolean isFilterPartialSet(org.openmuc.jeebus.spine.xsd.v1.CmdType cmdType)
-
isFilterDeleteSet
public static boolean isFilterDeleteSet(org.openmuc.jeebus.spine.xsd.v1.CmdType cmdType)
-
supportsPartialRead
public static boolean supportsPartialRead(org.openmuc.jeebus.spine.xsd.v1.NodeManagementDetailedDiscoveryDataType detailedDiscoveryData, java.lang.String featureName, java.lang.String functionName)
-
isValidEnumValue
public static <E extends java.lang.Enum<E>> boolean isValidEnumValue(java.lang.Class<E> clazz, java.lang.String name)Returns if a string is a valid value of a given enum. Only works if the enum has a value parameter and a fromValue method, else throws a Runtime Exception. The method is currently generated in the SPINE generated classes.- Type Parameters:
E- extends Enum- Parameters:
clazz- enum classname- value name- Returns:
- true if is valid enum value of given enum class
-
getCalculatedScaledValue
public static java.lang.Double getCalculatedScaledValue(org.openmuc.jeebus.spine.xsd.v1.ScaledNumberType scaledNumberObject)
Returns the actual value of a ScaledNumberType object as Double.- Parameters:
scaledNumberObject- the ScaledNumberType object- Returns:
- number * 10 ^ scale
-
timestampIsInInterval
public static boolean timestampIsInInterval(java.lang.String timestampString, org.openmuc.jeebus.spine.xsd.v1.TimestampIntervalType interval)Checks if a given timestamp is in given interval.- Parameters:
timestampString- timestamp as stringinterval- interval to check- Returns:
- true if in interval or if interval is null, else false
-
-