Class Value

    • Constructor Detail

      • Value

        public Value()
    • Method Detail

      • toString

        public abstract String toString()
        Values must override the default method to return a string representation that is immutable.
        Overrides:
        toString in class Object
        Returns:
        String representation
      • hashCode

        public abstract int hashCode()
        Values must override the default hashcode method.
        Overrides:
        hashCode in class Object
        Returns:
        int hashcode
      • equals

        public abstract boolean equals​(Object obj)
        Values must override the default equals method. This method should only return true if the supplied Object is of the same type as the implementing Value. Values of an unknown type should be coerced before calling this method. This method does not have to guarantee that this.equals(that) == this.toString().equals(that.toString())
        Overrides:
        equals in class Object
        Parameters:
        obj -
        Returns:
        boolean
      • isEmpty

        public boolean isEmpty()
        Check whether this Value is an empty value and has a zero length string representation. Subclasses may wish to override this for efficiency if the String representation is lazily created.
        Returns:
        boolean true if empty
      • equivalent

        public boolean equivalent​(Value value)
        Indicates whether some other Value is equivalent to this one. Unlike equals(java.lang.Object) this method is not symmetric - a value of a different type might be equivalent to this without the other type considering the reverse to be true.

        The default implementation uses identity or String equality.

        Parameters:
        value - value to test for equivalence
        Returns:
        true if value is equivalent to this
      • info

        public static ArgumentInfo info()
        Use this method to return an ArgumentInfo argument that can be used to refer to ANY Value subclass. Usually, you will want to get an ArgumentInfo object directly from a specific Value subclass.
        Returns:
        ArgumentInfo info
      • ofObject

        public static Value ofObject​(Object obj)
        Convert the provided Object into a Value. This is a lightweight conversion, primarily to map Java literals to the right Value type, rather than a general purpose mapping API.

        Any instance of a Value subclass is returned as is. Booleans are converted to PBoolean. Numbers are converted to PNumber. null is converted to PString.EMPTY. All other types are converted to a PString of their String representation.

        Parameters:
        obj - object to convert
        Returns:
        value