- java.lang.Object
-
- org.praxislive.core.Value
-
- org.praxislive.core.types.PArray
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.praxislive.core.Value
Value.Type<T extends Value>
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description List<Value>
asList()
An unmodifiableList
view of this list of values.static <T extends Value>
Collector<T,?,PArray>collector()
Create aCollector
that can create a PArray from a Stream of Values.boolean
equals(Object obj)
Values must override the default equals method.boolean
equivalent(Value arg)
Indicates whether some other Value is equivalent to this one.static Optional<PArray>
from(Value value)
Cast or convert the provided value into a PArray, wrapped in an Optional.Value
get(int index)
Query the value at the given index in the list.int
hashCode()
Values must override the default hashcode method.static ArgumentInfo
info()
Utility method to create anArgumentInfo
for arguments of type PArray.boolean
isEmpty()
Check whether this Value is an empty value and has a zero length string representation.Iterator<Value>
iterator()
static PArray
of(Collection<? extends Value> collection)
Create a PArray from the given collection of values.static PArray
of(Value... values)
Create a PArray from the given collection of values.static PArray
parse(String text)
Parse the given text into a PArray.int
size()
Query the number of values in the list.Stream<Value>
stream()
An ordered stream over the list of values.String
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, wait
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
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.
-
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.
-
equivalent
public boolean equivalent(Value arg)
Description copied from class:Value
Indicates 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:
equivalent
in classValue
- 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.
-
equals
public boolean equals(Object obj)
Description copied from class:Value
Values must override the default equals method. This method should only returntrue
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 thatthis.equals(that) == this.toString().equals(that.toString())
-
stream
public Stream<Value> stream()
An ordered stream over the list of values.- Returns:
- stream of values
-
asList
public List<Value> asList()
An unmodifiableList
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
-
parse
public static PArray parse(String text) throws ValueFormatException
Parse the given text into a PArray.- Parameters:
text
- text to parse- Returns:
- parsed PArray
- Throws:
ValueFormatException
-
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 anArgumentInfo
for arguments of type PArray.- Returns:
- argument info
-
-