Class ParameterType<T>

    • Field Detail

      • items

        private List<T> items
        List of allowed values.
      • checkValues

        private boolean checkValues
      • clazz

        private final Class<T> clazz
        The class of allowed parameter values.
      • valueType

        private final Type valueType
        The matching type of parameter values (can be null)
      • defaultValue

        private final T defaultValue
        Default value of the parameter.
      • notNull

        private final boolean notNull
        If the parameter can be null or not.
      • height

        private final int height
        Height of the input field for the parameter in the GUI. Only used as a hint for the client.
      • width

        private final int width
        Width of the input field for the parameter in the GUI. Only used as a hint for the client.
      • multiplicity

        private final int multiplicity
        How many values that can be tied to this parameter. 0 is unlimited values and 1 is default.
    • Constructor Detail

      • ParameterType

        ParameterType​(Type valueType,
                      Class<T> clazz)
        Creates a parameter type with no default value and allowing null values.
        Parameters:
        clazz - The class of the parameters that this type holds
      • ParameterType

        ParameterType​(Type valueType,
                      Class<T> clazz,
                      T defaultValue,
                      boolean notNull)
        Creates a new parameter type.
        Parameters:
        clazz - The class of the parameters that this type holds.
        defaultValue - The parameters default value.
        notNull - If the parameter is allowed to be null.
      • ParameterType

        ParameterType​(Type valueType,
                      Class<T> clazz,
                      T defaultValue,
                      boolean notNull,
                      int multiplicity,
                      int width,
                      int height)
      • ParameterType

        ParameterType​(Type valueType,
                      Class<T> clazz,
                      T defaultValue,
                      boolean notNull,
                      int multiplicity,
                      int width,
                      int height,
                      List<T> items)
      • ParameterType

        ParameterType​(Type valueType,
                      Class<T> clazz,
                      T defaultValue,
                      boolean notNull,
                      int multiplicity,
                      int width,
                      int height,
                      Enumeration<T,​String> enumeration,
                      boolean checkValues)
    • Method Detail

      • getValueType

        public Type getValueType()
        Get the date type of values that can be stored in this parameter. May return null if there is no matching Type definition.
        Returns:
        A Type object or null
        Since:
        2.16
      • getParameterClass

        public Class<T> getParameterClass()
        Get the class a value must have to match this parameter type.
      • getHeight

        public int getHeight()
        Get the height of the input field for the parameter in the GUI. Only used as a hint for the client.
        Returns:
        The height of the input field.
      • getWidth

        public int getWidth()
        Get the width of the input field in the GUI. Only used as a hint for the client.
        Returns:
        The width of the input field.
      • getNotNull

        public boolean getNotNull()
        Check if the parameter can be null. Will return true if it can't be null.
        Returns:
        True if not null, otherwise false.
      • getMultiplicity

        public int getMultiplicity()
        Get how many values that can be tied to this parameter. 0 is unlimited values and 1 is default.
        Returns:
        The multiplicity.
      • isMasked

        public boolean isMasked()
        Should this parameter be masked in the GUI?
        Returns:
        FALSE, unless overridden by subclass
        Since:
        3.7
      • getDefaultValue

        public T getDefaultValue()
        Get the default value.
        Returns:
        The default value or null if none i set.
      • validate

        public void validate​(String name,
                             Object value)
                      throws InvalidDataException
        Check if a value is valid according to the settings of this parameter type.
        Parameters:
        name - The name of the parameter, used for better exception messages
        value - The value to test
        Throws:
        InvalidDataException - If the value is invalid
      • newParameterValueData

        abstract ParameterValueData<?> newParameterValueData()
        Create a new ParameterValueData subclass which is used to store values of this value type in the database.
      • validateValue

        abstract void validateValue​(String name,
                                    T value)
                             throws InvalidDataException
        Validate a value. The validate methods in this class checks for not-null and multiplicity (if needed). Each subclass must implement checks for other properties, such as maximum string length, lower and upper limits, etc. By the time this method is called, it is certain that the value is of the correct class and isn't null.
        Parameters:
        name - The name of the parameter, use the name if there is need to throw an exception
        value - The value
        Throws:
        InvalidDataException - If the value is not valid
      • isEnumeration

        public boolean isEnumeration()
        Check if the parameter type enumerates the allowed values or not. If the parameter is an enumeration the values can be retreived by getItems() or getEnumeration(). NOTE! If an Enumeration has been supplied the getItems method will return a list of the keys of the enumeration.
        Returns:
        TRUE if the parameter type is an enumeration, FALSE otherwise
      • getItems

        public List<T> getItems()
        Get the list of values to choose from.
        Returns:
        List of values
        See Also:
        getEnumeration()
      • getEnumeration

        public Enumeration<T,​String> getEnumeration()
        Get the list of values to choose from as an enumeration. An enumeration is different from the regular list returned by getItems() in that it has second value attached to each value. The second value should be used for display purposes only while the first value is the one that is used.
        Returns:
        The enumeration of values or null
        See Also:
        getItems()