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

    • name

      protected String name
      The name of the user-defined field.
    • type

      protected FieldType type
      The data type of the user-defined field.
    • unit

      protected String unit
      The unit of the user-defined field (if applicable).
    • value

      protected String value
      The value of the user-defined field.
  • Constructor Details

    • UDF

      public UDF()
      Default constructor.
    • UDF

      public UDF(String name, FieldType type)
      Constructor with name and type.
      Parameters:
      name - The name of the UDF.
      type - The type of the UDF.
    • UDF

      public UDF(String name, Object value)
      Constructor with name and value.
      Parameters:
      name - The name of the UDF.
      value - The value of the UDF.
    • UDF

      public UDF(String name, FieldType type, Object value)
      Constructor with name, type and value.
      Parameters:
      name - The name of the UDF.
      type - The type of the UDF.
      value - The value of the UDF.
  • Method Details

    • getValue

      public String getValue()
      Gets the value of the UDF.
      Returns:
      The value of the UDF.
    • setValue

      public void setValue(Object value)
      Sets the value of the UDF.
      Parameters:
      value - The value to set.
    • getUnit

      public String getUnit()
      Gets the unit of the UDF.
      Returns:
      The unit of the UDF.
    • getName

      public String getName()
      Gets the name of the UDF.
      Returns:
      The name of the UDF.
    • setName

      public void setName(String name)
      Sets the name of the UDF.
      Parameters:
      name - The name to set.
    • getType

      public FieldType getType()
      Gets the type of the UDF.
      Returns:
      The type of the UDF.
    • setType

      public void setType(FieldType type)
      Sets the type of the UDF.
      Parameters:
      type - The type to set.
    • toString

      public String toString()
      Returns the string representation of the UDF.
      Overrides:
      toString in class Object
      Returns:
      A string representation of the UDF.
    • 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.