- 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
.T
get()
Return the contentsT
of the wrapped value.boolean
isSingleValued()
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:Value
Return the contentsT
of the wrapped value.This can throw a
NoSuchElementException
if no value is present.
-
isSingleValued
public boolean isSingleValued()
Description copied from interface:Value
Is this instance single-valued or not.- Specified by:
isSingleValued
in interfaceValue<T>
- Returns:
true
if single-valued, otherwisefalse
-
filter
public Value<T> filter(java.util.function.Predicate<T> predicate)
Description copied from interface:Streamable
Filter 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 returnstrue
for.- Specified by:
filter
in 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:Streamable
Perform a mapping operation on the elements in the stream.This operation will loop over all elements in the stream and apply the
mapper
method. The mapped values will be returned in as a new stream of elements.- Specified by:
map
in interfaceStreamable<T>
- Type Parameters:
U
- the type of object expected as a result- Parameters:
mapper
- the mapping functionality- Returns:
- the mapped object
-
-