Class MultiValue<T>

  • Type Parameters:
    T - is the type of the value.
    All Implemented Interfaces:
    Serializable

    public class MultiValue<T>
    extends Object
    implements Serializable
    Utilities class that permits to represent a collection of values and indicating if they are all the same or not.
    Version:
    17.0 2020-01-04 14:41:38
    Author:
    Stéphane GALLAND
    See Also:
    Serialized Form
    Maven Group Id:
    org.arakhne.afc.core
    Maven Artifact Id:
    util
    • Constructor Detail

      • MultiValue

        public MultiValue​(T initialValue)
        Constructor.
        Parameters:
        initialValue - is the initial value of the output parameter.
      • MultiValue

        public MultiValue()
        Create empty output parameter.
    • Method Detail

      • toString

        @Pure
        public String toString​(String multiValueLabel)
        Replies a string representation of the value in this object. If this object is set and has multiple different values, the parameter multiValueLabel is replied. If this object is not set or equals to null, the empty string is replied. Otherwise the value is replied.
        Parameters:
        multiValueLabel - is the label to reply if this object is containing many different values.
        Returns:
        the string representation of this object.
      • get

        @Pure
        public T get()
        Replies the value.
        Returns:
        the value embedded inside this object.
      • getValueType

        @Pure
        public Class<? extends T> getValueType()
        Replies the type of the value.
        Returns:
        the type or null if there is no value.
      • add

        public void add​(T newValue)
        Add the given value to the styored value.
        Parameters:
        newValue - the new value.
      • clear

        public void clear()
        Clear this multi-value.
      • isSet

        @Pure
        public boolean isSet()
        Replies if the value was set.
        Returns:
        true is the value was set, otherwise false
      • isMultipleDifferentValues

        @Pure
        public boolean isMultipleDifferentValues()
        Replies if this MultiValue contains different values.
        Returns:
        true is values are different, otherwise false
      • setMultipleDifferentValues

        public void setMultipleDifferentValues​(boolean multiple)
        Set if this MultiValue contains different values.
        Parameters:
        multiple - is true is values are different, otherwise false
      • equals

        @Pure
        public boolean equals​(Object obj)
        Overrides:
        equals in class Object
      • hashCode

        @Pure
        public int hashCode()
        Overrides:
        hashCode in class Object