Class PArray

    • Field Detail

      • EMPTY

        public static final PArray EMPTY
        An empty PArray.
    • Method Detail

      • get

        public Value get​(int index)
        Query the value at the given index in the list. If the index is negative or greater than size, the index is modulated into range rather than throwing an exception - useful for cycling. If this PArray is empty, this is returned.
        Parameters:
        index - position of value
        Returns:
        value at index
      • size

        public int size()
        Query the number of values in the list.
        Returns:
        size of list
      • toString

        public String toString()
        Description copied from class: Value
        Values must override the default method to return a string representation that is immutable.
        Specified by:
        toString in class Value
        Returns:
        String representation
      • isEmpty

        public boolean isEmpty()
        Description copied from class: Value
        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.
        Overrides:
        isEmpty in class Value
        Returns:
        boolean true if empty
      • equivalent

        public boolean equivalent​(Value arg)
        Description copied from class: Value
        Indicates whether some other Value is equivalent to this one. Unlike Value.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.

        Overrides:
        equivalent in class Value
        Parameters:
        arg - value to test for equivalence
        Returns:
        true if value is equivalent to this
      • hashCode

        public int hashCode()
        Description copied from class: Value
        Values must override the default hashcode method.
        Specified by:
        hashCode in class Value
        Returns:
        int hashcode
      • equals

        public boolean equals​(Object obj)
        Description copied from class: Value
        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())
        Specified by:
        equals in class Value
        Returns:
        boolean
      • stream

        public Stream<Value> stream()
        An ordered stream over the list of values.
        Returns:
        stream of values
      • asList

        public List<Value> asList()
        An unmodifiable List view of this list of values.
        Returns:
        view as unmodifiable list
      • of

        public static PArray of​(Collection<? extends Value> collection)
        Create a PArray from the given collection of values.
        Parameters:
        collection - collection of values
        Returns:
        new PArray
      • of

        public static PArray of​(Value... values)
        Create a PArray from the given collection of values.
        Parameters:
        values - array of values
        Returns:
        new PArray
      • from

        public static Optional<PArray> from​(Value value)
        Cast or convert the provided value into a PArray, wrapped in an Optional. If the value is already a PArray, the Optional will wrap the existing value. If the value is not a PArray and cannot be converted into one, an empty Optional is returned.
        Parameters:
        value - value
        Returns:
        optional PArray
      • info

        public static ArgumentInfo info()
        Utility method to create an ArgumentInfo for arguments of type PArray.
        Returns:
        argument info
      • collector

        public static <T extends ValueCollector<T,​?,​PArray> collector()
        Create a Collector that can create a PArray from a Stream of Values.
        Type Parameters:
        T - Value type
        Returns:
        new PArray collector