java.lang.Object
com.genologics.ri.userdefined.UDF
All Implemented Interfaces:
Serializable

public class UDF extends Object implements Serializable
Field is the value and data type of a user-defined field.
See Also:
  • Field Details

  • Constructor Details

  • Method Details

    • getValue

      public String getValue()
    • setValue

      public void setValue(Object value)
    • getUnit

      public String getUnit()
    • getName

      public String getName()
    • setName

      public void setName(String name)
    • getType

      public FieldType getType()
    • setType

      public void setType(FieldType type)
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getUDF

      public static UDF getUDF(Collection<UDF> udfs, String name)
      Finds a UDF by name in a collection of UDF objects.
      Parameters:
      udfs - The collection to search.
      name - The name of the UDF to find.
      Returns:
      The UDF object with the same name, or null if there is no matching UDF.
      Throws:
      IllegalArgumentException - if name is null.
    • getUDFValue

      public static String getUDFValue(Collection<UDF> udfs, String name)
      Finds a UDF by name in a collection of UDF objects and, if found, returns its value.
      Parameters:
      udfs - The collection to search.
      name - The name of the UDF to find.
      Returns:
      The value of the UDF, or null if there is no matching UDF.
      Throws:
      IllegalArgumentException - if name is null.
    • getUDFValue

      public static String getUDFValue(Collection<UDF> udfs, String name, String defaultValue)
      Finds a UDF by name in a collection of UDF objects and, if found, returns its value.
      Parameters:
      udfs - The collection to search.
      name - The name of the UDF to find.
      defaultValue - The value to return if there is no matching UDF.
      Returns:
      The value of the UDF, or defaultValue if there is no matching UDF.
      Throws:
      IllegalArgumentException - if name is null.
      Since:
      2.22
    • getUDF

      public static UDF getUDF(Collection<UDF> udfs, String name, boolean fail)
      Finds a UDF by name in a collection of UDF objects.
      Parameters:
      udfs - The collection to search.
      name - The name of the UDF to find.
      fail - Whether to fail with a MissingUDFException if the field is not found.
      Returns:
      The UDF object with the same name, or null if there is no matching UDF and fail is false.
      Throws:
      IllegalArgumentException - if name is null.
      MissingUDFException - if fail is true and there is no matching UDF.
    • getUDFValue

      public static String getUDFValue(Collection<UDF> udfs, String name, boolean fail)
      Finds a UDF by name in a collection of UDF objects and returns its value.
      Parameters:
      udfs - The collection to search.
      name - The name of the UDF to find.
      fail - Whether to fail with a MissingUDFException if the field is not found.
      Returns:
      The value of the UDF, or null if there is no matching UDF and fail is false.
      Throws:
      IllegalArgumentException - if name is null.
      MissingUDFException - if fail is true and there is no matching UDF.
    • getUDF

      public static UDF getUDF(Collection<UDF> udfs, String name, boolean fail, String failMessage)
      Finds a UDF by name in a collection of UDF objects.
      Parameters:
      udfs - The collection to search.
      name - The name of the UDF to find.
      fail - Whether to fail with a MissingUDFException if the field is not found.
      failMessage - The message to put in the MissingUDFException when such an exception is raised.
      Returns:
      The UDF object with the same name, or null if there is no matching UDF and fail is false.
      Throws:
      IllegalArgumentException - if name is null.
      MissingUDFException - if fail is true and there is no matching UDF.
    • getUDFValue

      public static String getUDFValue(Collection<UDF> udfs, String name, boolean fail, String failMessage)
      Finds a UDF by name in a collection of UDF objects and returns its value.
      Parameters:
      udfs - The collection to search.
      name - The name of the UDF to find.
      fail - Whether to fail with a MissingUDFException if the field is not found.
      failMessage - The message to put in the MissingUDFException when such an exception is raised.
      Returns:
      The value of the UDF, or null if there is no matching UDF and fail is false.
      Throws:
      IllegalArgumentException - if name is null.
      MissingUDFException - if fail is true and there is no matching UDF.
    • getUDF

      public static UDF getUDF(UDFHolder thing, String name)
      Finds a UDF by name in the UDFs of the given object.
      Parameters:
      thing - The object that holds UDFs.
      name - The name of the UDF to find.
      Returns:
      The UDF object with the same name, or null if there is no matching UDF.
      Throws:
      IllegalArgumentException - if name is null.
    • getUDFValue

      public static String getUDFValue(UDFHolder thing, String name)
      Finds a UDF by name in the UDFs of the given object and, if found, returns its value.
      Parameters:
      thing - The object that holds UDFs.
      name - The name of the UDF to find.
      Returns:
      The value of the UDF, or null if there is no matching UDF.
      Throws:
      IllegalArgumentException - if name is null.
    • getUDFValue

      public static String getUDFValue(UDFHolder thing, String name, String defaultValue)
      Finds a UDF by name in the UDFs of the given object and, if found, returns its value.
      Parameters:
      thing - The object that holds UDFs.
      name - The name of the UDF to find.
      defaultValue - The value to return if there is no matching UDF.
      Returns:
      The value of the UDF, or defaultValue if there is no matching UDF.
      Throws:
      IllegalArgumentException - if name is null.
      Since:
      2.22
    • getUDF

      public static UDF getUDF(UDFHolder thing, String name, boolean fail)
      Finds a UDF by name in the UDFs of the given object.
      Parameters:
      thing - The object that holds UDFs.
      name - The name of the UDF to find.
      fail - Whether to fail with a MissingUDFException if the field is not found.
      Returns:
      The UDF object with the same name, or null if there is no matching UDF and fail is false.
      Throws:
      IllegalArgumentException - if name is null.
      MissingUDFException - if fail is true and there is no matching UDF.
    • getUDFValue

      public static String getUDFValue(UDFHolder thing, String name, boolean fail)
      Finds a UDF by name in the UDFs of the given object and returns its value.
      Parameters:
      thing - The object that holds UDFs.
      name - The name of the UDF to find.
      fail - Whether to fail with a MissingUDFException if the field is not found.
      Returns:
      The value of the UDF, or null if there is no matching UDF and fail is false.
      Throws:
      IllegalArgumentException - if name is null.
      MissingUDFException - if fail is true and there is no matching UDF.
    • getUDF

      public static UDF getUDF(UDFHolder thing, String name, boolean fail, String failMessage)
      Finds a UDF by name in the UDFs of the given object.
      Parameters:
      thing - The object that holds UDFs.
      name - The name of the UDF to find.
      fail - Whether to fail with a MissingUDFException if the field is not found.
      failMessage - The message to put in the MissingUDFException when such an exception is raised.
      Returns:
      The UDF object with the same name, or null if there is no matching UDF and fail is false.
      Throws:
      IllegalArgumentException - if name is null.
      MissingUDFException - if fail is true and there is no matching UDF.
    • getUDFValue

      public static String getUDFValue(UDFHolder thing, String name, boolean fail, String failMessage)
      Finds a UDF by name in the UDFs of the given object and returns its value.
      Parameters:
      thing - The object that holds UDFs.
      name - The name of the UDF to find.
      fail - Whether to fail with a MissingUDFException if the field is not found.
      failMessage - The message to put in the MissingUDFException when such an exception is raised.
      Returns:
      The value of the UDF, or null if there is no matching UDF and fail is false.
      Throws:
      IllegalArgumentException - if name is null.
      MissingUDFException - if fail is true and there is no matching UDF.
    • setUDF

      public static UDF setUDF(UDFHolder thing, String name, Object value)
      Adds, sets or removes a UDF from the collection of fields on the given object. If the named UDF exists in the collection, it either has its value set (if "value" is not null) or is removed (if "value" is null). If it doesn't exist, a new UDF object is created for the field and is added to the collection.
      Parameters:
      thing - The object containing UDFs.
      name - The name of the field to change.
      value - The value to set the field to.
      Returns:
      The UDF object found or created, or null if it is removed or not found.
      Throws:
      IllegalArgumentException - if either of thing or name are null.
    • setUDF

      public static UDF setUDF(Collection<UDF> udfs, String name, Object value)
      Adds, sets or removes a UDF from the given collection of fields. If the named UDF exists in the collection, it either has its value set (if "value" is not null) or is removed (if "value" is null). If it doesn't exist, a new UDF object is created for the field and is added to the collection.
      Parameters:
      udfs - The collection of UDF objects.
      name - The name of the field to change.
      value - The value to set the field to.
      Returns:
      The UDF object found or created, or null if it is removed or not found.
      Throws:
      IllegalArgumentException - if either of udfs or name are null.