- java.lang.Object
-
- com.jongsoft.lang.ValueType<T>
-
- Type Parameters:
T- the contained data type
- All Implemented Interfaces:
Streamable<T>,Value<T>,java.io.Serializable,java.lang.Iterable<T>
public class ValueType<T> extends java.lang.Object implements Value<T>
The ValueType class represents an immutable wrapper around a data entity. The value type cannot be modified.- See Also:
- Serialized Form
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Value<T>filter(java.util.function.Predicate<T> predicate)Filter out an element if it does not match the suppliedpredicate.Tget()Return the contentsTof the wrapped value.booleanisSingleValued()Is this instance single-valued or not.java.util.Iterator<T>iterator()<U> Value<U>map(java.util.function.Function<T,U> mapper)Perform a mapping operation on the elements in the stream.
-
-
-
Constructor Detail
-
ValueType
public ValueType(T value)
-
-
Method Detail
-
get
public T get()
Description copied from interface:ValueReturn the contentsTof the wrapped value.This can throw a
NoSuchElementExceptionif no value is present.
-
isSingleValued
public boolean isSingleValued()
Description copied from interface:ValueIs this instance single-valued or not.- Specified by:
isSingleValuedin interfaceValue<T>- Returns:
trueif single-valued, otherwisefalse
-
filter
public Value<T> filter(java.util.function.Predicate<T> predicate)
Description copied from interface:StreamableFilter out an element if it does not match the suppliedpredicate. This operation will iterate over all elements and return a new set containing only the elements where the predicate returnstruefor.- Specified by:
filterin interfaceStreamable<T>- Parameters:
predicate- the predicate to apply to the contents of this- Returns:
- the filtered value
-
map
public <U> Value<U> map(java.util.function.Function<T,U> mapper)
Description copied from interface:StreamablePerform a mapping operation on the elements in the stream.This operation will loop over all elements in the stream and apply the
mappermethod. The mapped values will be returned in as a new stream of elements.- Specified by:
mapin interfaceStreamable<T>- Type Parameters:
U- the type of object expected as a result- Parameters:
mapper- the mapping functionality- Returns:
- the mapped object
-
-