Class CommonTools

java.lang.Object
de.aristaflow.adept2.model.common.tools.CommonTools

public class CommonTools extends Object
This class offers tool methods for several models.
  • Constructor Details

    • CommonTools

      public CommonTools()
  • Method Details

    • getTypeAsString

      public static String getTypeAsString(ProcessConstants.AdeptDataType adt, String udtName)
      Gets a string representation of the designated ProcessConstants.AdeptDataType. In case of a ProcessConstants.AdeptDataType.USERDEFINED type, the UDT name will be appended if not null.
      Parameters:
      adt - The data type for which to get a string representation. This must not be null.
      udtName - The name of the user-defined type or null.
      Returns:
      A string representation for the designated data type.
    • getTypeAsString

      public static String getTypeAsString(ProcessConstants.AdeptDataType adt, String udtName, String any)
      Gets a string representation of the designated ProcessConstants.AdeptDataType. In case of a ProcessConstants.AdeptDataType.USERDEFINED type, the UDT name will be appended if not null. If the designated data type is null or if it is ProcessConstants.AdeptDataType.USERDEFINED and the UDT name is null, the designated any string will be used. This is especially for parameter templates of which the data type/UDT name does not matter.
      Parameters:
      adt - The data type for which to get a string representation. This may be null in case any is provided.
      udtName - The name of the user-defined type or null.
      any - The string representation for when the data type/UDT name does not matter. This must not be null if either adt or udtName are null.
      Returns:
      A string representation for the designated data type including "do not care".
    • dateTimeToOffsetString

      public static String dateTimeToOffsetString(ZonedDateTime dateTime)
      Gets the designated date-time as ISO-8601 text with its offset, e. g. 2026-10-01T06:00:00+02:00, the form of xs:dateTime. The text does not keep the region of the date-time.
      Parameters:
      dateTime - The date-time to convert to text. This must not be null.
      Returns:
      The designated date-time as ISO-8601 text with its offset.
    • dateTimeToZonedString

      public static String dateTimeToZonedString(ZonedDateTime dateTime)
      Gets the designated date-time as ISO-8601 text with its offset and, if it has one, its region, e. g. 2026-10-01T06:00:00+02:00[Europe/Berlin]. Unlike the offset, the region determines the offsets of later times across a change of daylight saving time.
      Parameters:
      dateTime - The date-time to convert to text. This must not be null.
      Returns:
      The designated date-time as ISO-8601 text with its offset and its region.
    • parseDateTime

      public static ZonedDateTime parseDateTime(String dateTime)
      Parses an ISO-8601 date-time with its offset, e. g. 2026-10-01T06:00:00+02:00, or with its offset and its region, e. g. 2026-10-01T06:00:00+02:00[Europe/Berlin]. A date-time without an offset is taken as UTC.
      Parameters:
      dateTime - The ISO-8601 date-time to parse. This must not be null.
      Returns:
      The date-time in the region of the designated text if it has one, otherwise at its offset.
      Throws:
      DateTimeParseException - If the designated text is no ISO-8601 date-time, a DateTimeParseException will be thrown.
    • timeAmountToString

      public static String timeAmountToString(TemporalAmount period)
      Gets the designated period as ISO-8601 text, e. g. PT2H or P1M.
      Parameters:
      period - The period to convert to text. This must not be null.
      Returns:
      The designated period as ISO-8601 text.
    • parseTimeAmount

      public static TemporalAmount parseTimeAmount(String period)
      Parses an ISO-8601 period. A text with a time part is a Duration, a fixed length of time whose days count as 24 hours, e. g. PT2H or P1DT12H. Any other text is a Period of calendar days, weeks, months or years, e. g. P1D or P1M, so that a day may last 23 or 25 hours across a change to or from daylight saving time. This reads the text of timeAmountToString(TemporalAmount) back as the same type.
      Parameters:
      period - The ISO-8601 period to parse. This must not be null.
      Returns:
      The designated period as Duration or Period.
      Throws:
      DateTimeParseException - If the designated text is no ISO-8601 period, a DateTimeParseException will be thrown.