java.lang.Object
org.praxislive.core.Value
org.praxislive.core.types.PArray
An ordered list of Values.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classAn abstract superclass for values that are backed solely by a PArray.Nested classes/interfaces inherited from class org.praxislive.core.Value
Value.Type<T extends Value> -
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionasList()An unmodifiableListview of this list of values.<T> List<T> Access an unmodifiableListview of this PArray as a list of the provided value type.Create aCollectorthat can create a PArray from a Stream of Values.booleanValues must override the default equals method.booleanequivalent(Value arg) Indicates whether some other Value is equivalent to this one.Cast or convert the provided value into a PArray, wrapped in an Optional.get(int index) Query the value at the given index in the list.inthashCode()Values must override the default hashcode method.static ArgumentInfoinfo()Utility method to create anArgumentInfofor arguments of type PArray.booleanisEmpty()Check whether this Value is an empty value and has a zero length string representation.iterator()static PArrayof(Collection<? extends Value> collection) Create a PArray from the given collection of values.static PArrayCreate a PArray from the given collection of values.static PArrayParse the given text into a PArray.intsize()Query the number of values in the list.stream()An ordered stream over the list of values.toString()Values must override the default method to return a string representation that is immutable.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Field Details
-
TYPE_NAME
Value type name.- See Also:
-
EMPTY
An empty PArray.
-
-
Method Details
-
get
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
Description copied from class:ValueValues must override the default method to return a string representation that is immutable. -
isEmpty
public boolean isEmpty()Description copied from class:ValueCheck 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. -
equivalent
Description copied from class:ValueIndicates whether some other Value is equivalent to this one. UnlikeValue.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:
equivalentin classValue- Parameters:
arg- value to test for equivalence- Returns:
- true if value is equivalent to this
-
hashCode
public int hashCode()Description copied from class:ValueValues must override the default hashcode method. -
equals
Description copied from class:ValueValues must override the default equals method. This method should only returntrueif 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 thatthis.equals(that) == this.toString().equals(that.toString()) -
iterator
-
stream
An ordered stream over the list of values.- Returns:
- stream of values
-
asList
An unmodifiableListview of this list of values.- Returns:
- view as unmodifiable list
-
asListOf
Access an unmodifiableListview of this PArray as a list of the provided value type.If the provided type is
Valuethen this method acts the same as callingasList().If the provided type is a Value subclass and all values in the list returned by
asList()are of this type, then the list is cast and returned.If the provided type is a Value subclass or any other type supported by
ValueMapperthen a new list will be returned with the values converted to the required type.This method throws an
IllegalArgumentExceptionif no value mapper exists for the provided type, of if not all list values can be converted to the provided type.- Type Parameters:
T- value type- Parameters:
type- class of the value type- Returns:
- list view of the provided value type
- Throws:
IllegalArgumentException- if there is no mapper for the provided type, or if all values cannot be converted to the provided type
-
of
Create a PArray from the given collection of values.- Parameters:
collection- collection of values- Returns:
- new PArray
-
of
Create a PArray from the given collection of values.- Parameters:
values- array of values- Returns:
- new PArray
-
parse
Parse the given text into a PArray.- Parameters:
text- text to parse- Returns:
- parsed PArray
- Throws:
ValueFormatException
-
from
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
Utility method to create anArgumentInfofor arguments of type PArray.- Returns:
- argument info
-
collector
Create aCollectorthat can create a PArray from a Stream of Values.- Type Parameters:
T- Value type- Returns:
- new PArray collector
-