Class SSSOMUtils

java.lang.Object
org.incenp.obofoundry.sssom.SSSOMUtils

public class SSSOMUtils extends Object
Helper methods for SSSOM.

This class is intended to group various static methods that may be used throughout the library.

  • Constructor Details

    • SSSOMUtils

      public SSSOMUtils()
  • Method Details

    • format

      public static String format(Double value)
      Formats a double value.

      In an attempt to reduce serialisation differences across implementations, the SSSOM specification, and especially the specification for the “canonical SSSOM/TSV format”, recommends that values of double-typed slots (e.g. confidence) be written with up to three digits after the decimal point as needed, rounding to the nearest neighbour (rounding up if both neighbours are equidistant). This is what this method does.

      Parameters:
      value - The double value to format as a string.
      Returns:
      A string serialisation of the value, compliant with the format recommendations from the SSSOM specification.
    • format

      public static String format(LocalDate value)
      Formats a date value.

      The SSSOM specification says nothing on how to serialise date-typed slots, but LinkML says “for xsd dates, datetimes, and times, [the value] must be a string conforming to the relevant ISO type”. Presumably this means ISO-8601.

      Parameters:
      value - The date value to format as a string.
      Returns:
      A string serialisation of the value.
    • format

      public static String format(ZonedDateTime value)
      Formats a date and time value.

      There are no date-time slots in SSSOM, but SSSOM-Java supports extension values with such a type.

      Parameters:
      value - The date-time value to format.
      Returns:
      A string serialisation of the value.
    • format

      public static String format(Object value)
      Formats a value of an unknown type.

      This is a convenience method to format an object whose type is not known at compile-time. It merely checks the runtime type of the object then calls the appropriate formatting method.

      Parameters:
      value - The object to format.
      Returns:
      A string serialisation of the value (or null if the value itself is null).