Class SpineUtilities


  • public class SpineUtilities
    extends java.lang.Object
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.time.format.DateTimeFormatter FORMATTER  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.Long dateTimeToRelativeMilliseconds​(java.lang.String dateTime)  
      static java.lang.Long durationToRelativeMilliseconds​(java.lang.String duration)  
      static org.openmuc.jeebus.spine.xsd.v1.EntityAddressType extractEntityAddress​(org.openmuc.jeebus.spine.xsd.v1.EntityAddressType address)  
      static org.openmuc.jeebus.spine.xsd.v1.FeatureAddressType getAddressCopy​(org.openmuc.jeebus.spine.xsd.v1.FeatureAddressType address)  
      static java.lang.Double getCalculatedScaledValue​(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.CmdControlType getDeleteCmdControl()  
      static java.lang.String getNowTimestamp()
      Use this method to get the current timestamp in UTC.
      static org.openmuc.jeebus.spine.xsd.v1.CmdControlType getPartialCmdControl()  
      static java.lang.String getThreadName​(java.lang.String useCaseName, java.lang.String actor)  
      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?
      static boolean isFilterDeleteSet​(org.openmuc.jeebus.spine.xsd.v1.CmdType cmdType)  
      static boolean isFilterPartialSet​(org.openmuc.jeebus.spine.xsd.v1.CmdType cmdType)  
      static boolean isSubAddress​(org.openmuc.jeebus.spine.xsd.v1.EntityAddressType parentAddress, org.openmuc.jeebus.spine.xsd.v1.FeatureAddressType childAddress)  
      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.
      static java.lang.String simplifyCmd​(org.openmuc.jeebus.spine.xsd.v1.CmdType what)  
      static java.lang.String simplifyCmds​(org.openmuc.jeebus.spine.xsd.v1.DatagramType what)  
      static java.lang.String simplifyDatagram​(org.openmuc.jeebus.spine.xsd.v1.DatagramType what)  
      static boolean supportsPartialRead​(org.openmuc.jeebus.spine.xsd.v1.NodeManagementDetailedDiscoveryDataType detailedDiscoveryData, java.lang.String featureName, java.lang.String functionName)  
      static boolean timestampIsInInterval​(java.lang.String timestampString, org.openmuc.jeebus.spine.xsd.v1.TimestampIntervalType interval)
      Checks if a given timestamp is in given interval.
      static java.lang.Long toRelativeMilliseconds​(java.lang.String time)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • FORMATTER

        public static final java.time.format.DateTimeFormatter FORMATTER
    • Method Detail

      • getNowTimestamp

        public static java.lang.String getNowTimestamp()
        Use this method to get the current timestamp in UTC. It is formatted with FORMATTER using the pattern yyyy-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 child
        entityAddressParent - 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 class
        name - 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 string
        interval - interval to check
        Returns:
        true if in interval or if interval is null, else false