Class EnumeratedProperty<E>

  • Type Parameters:
    E - Type of the values
    All Implemented Interfaces:
    java.lang.Comparable<PropertyDescriptor<?>>, EnumeratedPropertyDescriptor<E,​E>, PropertyDescriptor<E>, SingleValuePropertyDescriptor<E>

    @Deprecated
    public final class EnumeratedProperty<E>
    extends java.lang.Object
    implements EnumeratedPropertyDescriptor<E,​E>
    Deprecated.
    Use a PropertyDescriptor<E> instead. A builder is available from PropertyFactory.enumProperty(String, Map). This class will be removed in 7.0.0.
    Property which can take only a fixed set of values of any type, then selected via String labels. The mappings method returns the set of mappings between the labels and their values.

    This property currently doesn't support serialization and cannot be defined in a ruleset file.z

    Version:
    Refactored June 2017 (6.0.0)
    Author:
    Brian Remedios, Clément Fournier
    • Constructor Detail

      • EnumeratedProperty

        @Deprecated
        public EnumeratedProperty​(java.lang.String theName,
                                  java.lang.String theDescription,
                                  java.lang.String[] theLabels,
                                  E[] theChoices,
                                  int defaultIndex,
                                  java.lang.Class<E> valueType,
                                  float theUIOrder)
        Constructor using arrays to define the label-value mappings. The correct construction of the property depends on the correct ordering of the arrays.
        Parameters:
        theName - Name
        theDescription - Description
        theLabels - Labels of the choices
        theChoices - Values that can be chosen
        defaultIndex - The index of the default value
        valueType - Type of the values
        theUIOrder - UI order
      • EnumeratedProperty

        @Deprecated
        public EnumeratedProperty​(java.lang.String theName,
                                  java.lang.String theDescription,
                                  java.lang.String[] theLabels,
                                  E[] theChoices,
                                  int defaultIndex,
                                  float theUIOrder)
        Constructor using arrays to define the label-value mappings. The correct construction of the property depends on the correct ordering of the arrays.
        Parameters:
        theName - Name
        theDescription - Description
        theLabels - Labels of the choices
        theChoices - Values that can be chosen
        defaultIndex - Index of the default value
        theUIOrder - UI order
      • EnumeratedProperty

        @Deprecated
        public EnumeratedProperty​(java.lang.String theName,
                                  java.lang.String theDescription,
                                  java.util.Map<java.lang.String,​E> labelsToChoices,
                                  E defaultValue,
                                  java.lang.Class<E> valueType,
                                  float theUIOrder)
        Constructor using a map to define the label-value mappings.
        Parameters:
        theName - Name
        theDescription - Description
        labelsToChoices - Map of labels to values
        defaultValue - Default value
        valueType - Type of the values
        theUIOrder - UI order
    • Method Detail

      • type

        public java.lang.Class<E> type()
        Deprecated.
        Description copied from interface: PropertyDescriptor
        Denotes the value datatype. For multi value properties, this is not the List class but the list's component class.
        Specified by:
        type in interface PropertyDescriptor<E>
        Specified by:
        type in interface SingleValuePropertyDescriptor<E>
        Returns:
        Class literal of the value type
      • errorFor

        public java.lang.String errorFor​(E value)
        Deprecated.
        Description copied from interface: PropertyDescriptor
        Validation function that returns a diagnostic error message for a sample property value. Returns null if the value is acceptable.
        Specified by:
        errorFor in interface PropertyDescriptor<E>
        Parameters:
        value - The value to check.
        Returns:
        A diagnostic message.
      • createFrom

        public E createFrom​(java.lang.String value)
                     throws java.lang.IllegalArgumentException
        Deprecated.
        Parse a string and returns an instance of a value.
        Parameters:
        value - String to parse
        Returns:
        An instance of a value
        Throws:
        java.lang.IllegalArgumentException
      • asString

        public java.lang.String asString​(E value)
        Deprecated.
        Returns a string representation of the value, even if it's null.
        Parameters:
        value - The value to describe
        Returns:
        A string representation of the value
      • mappings

        public java.util.Map<java.lang.String,​E> mappings()
        Deprecated.
        Description copied from interface: EnumeratedPropertyDescriptor
        Returns an immutable map of the label - value mappings defined by this descriptor.
        Specified by:
        mappings in interface EnumeratedPropertyDescriptor<E,​E>
        Returns:
        an immutable map of the label - value mappings defined by this descriptor.
      • defaultValue

        public final T defaultValue()
        Deprecated.
        Description copied from interface: PropertyDescriptor
        Default value to use when the user hasn't specified one or when they wish to revert to a known-good state.
        Specified by:
        defaultValue in interface PropertyDescriptor<T>
        Returns:
        Object
      • isMultiValue

        public final boolean isMultiValue()
        Deprecated.
        Description copied from interface: PropertyDescriptor
        Returns whether the property is multi-valued, i.e. an array of strings,

        As unary property rule properties will return a value of one, you must use the get/setProperty accessors when working with the actual values. When working with multi-value properties then the get/setProperties accessors must be used.

        Specified by:
        isMultiValue in interface PropertyDescriptor<T>
        Returns:
        boolean
      • asDelimitedString

        public java.lang.String asDelimitedString​(T value)
        Deprecated.
        Description copied from interface: PropertyDescriptor
        Formats the object onto a string suitable for storage within the property map.
        Specified by:
        asDelimitedString in interface PropertyDescriptor<T>
        Parameters:
        value - Object
        Returns:
        String
      • propertyErrorFor

        public java.lang.String propertyErrorFor​(Rule rule)
        Deprecated.
        Description copied from interface: PropertyDescriptor
        A convenience method that returns an error string if the rule holds onto a property value that has a problem. Returns null otherwise.
        Specified by:
        propertyErrorFor in interface PropertyDescriptor<T>
        Parameters:
        rule - Rule
        Returns:
        String
      • valueErrorFor

        protected java.lang.String valueErrorFor​(T value)
        Deprecated.
        Checks the value for an error.
        Parameters:
        value - Value to check
        Returns:
        A diagnostic error message, or null if there's no problem
      • defaultAsString

        protected final java.lang.String defaultAsString()
        Deprecated.
        Returns a string representation of the default value.
        Returns:
        A string representation of the default value.
      • valueFrom

        public final T valueFrom​(java.lang.String valueString)
                          throws java.lang.IllegalArgumentException
        Deprecated.
        Description copied from interface: PropertyDescriptor
        Returns the value represented by this string.
        Specified by:
        valueFrom in interface PropertyDescriptor<T>
        Parameters:
        valueString - The string to parse
        Returns:
        The value represented by the string
        Throws:
        java.lang.IllegalArgumentException - if the given string cannot be parsed
      • description

        public java.lang.String description()
        Description copied from interface: PropertyDescriptor
        Describes the property and the role it plays within the rule it is specified for. Could be used in a tooltip.
        Specified by:
        description in interface PropertyDescriptor<T>
        Returns:
        String
      • uiOrder

        public float uiOrder()
        Description copied from interface: PropertyDescriptor
        Denotes the relative order the property field should occupy if we are using an auto-generated UI to display and edit property values. If the value returned has a non-zero fractional part then this is can be used to place adjacent fields on the same row.
        Specified by:
        uiOrder in interface PropertyDescriptor<T>
        Returns:
        The relative order compared to other properties of the same rule
      • preferredRowCount

        public int preferredRowCount()
        Description copied from interface: PropertyDescriptor
        If the datatype is a String then return the preferred number of rows to allocate in the text widget, returns a value of one for all other types. Useful for multi-line XPATH editors.
        Specified by:
        preferredRowCount in interface PropertyDescriptor<T>
        Returns:
        int
      • equals

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • name

        public java.lang.String name()
        Description copied from interface: PropertyDescriptor
        The name of the property without spaces as it serves as the key into the property map.
        Specified by:
        name in interface PropertyDescriptor<T>
        Returns:
        String
      • addAttributesTo

        protected void addAttributesTo​(java.util.Map<PropertyDescriptorField,​java.lang.String> attributes)
        Adds this property's attributes to the map. Subclasses can override this to add more PropertyDescriptorField.
        Parameters:
        attributes - The map to fill
      • isDefinedExternally

        public boolean isDefinedExternally()
        Description copied from interface: PropertyDescriptor
        True if this descriptor was defined in the ruleset xml. This precision is necessary for the RuleSetWriter to write out the property correctly: if it was defined externally, then its definition must be written out, otherwise only its value.
        Specified by:
        isDefinedExternally in interface PropertyDescriptor<T>
        Returns:
        True if the descriptor was defined in xml