Class 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
    • Constructor Summary

      Constructors 
      Constructor Description
      ValueType​(T value)  
    • 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 supplied predicate.
      T get()
      Return the contents T 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.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface java.lang.Iterable

        forEach, spliterator
    • Constructor Detail

      • ValueType

        public ValueType​(T value)
    • Method Detail

      • get

        public T get()
        Description copied from interface: Value
        Return the contents T of the wrapped value.

        This can throw a NoSuchElementException if no value is present.

        Specified by:
        get in interface Value<T>
        Returns:
        returns the object wrapped in this value
      • isSingleValued

        public boolean isSingleValued()
        Description copied from interface: Value
        Is this instance single-valued or not.
        Specified by:
        isSingleValued in interface Value<T>
        Returns:
        true if single-valued, otherwise false
      • 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 supplied predicate. This operation will iterate over all elements and return a new set containing only the elements where the predicate returns true for.
        Specified by:
        filter in interface Streamable<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 interface Streamable<T>
        Type Parameters:
        U - the type of object expected as a result
        Parameters:
        mapper - the mapping functionality
        Returns:
        the mapped object
      • iterator

        public java.util.Iterator<T> iterator()
        Specified by:
        iterator in interface java.lang.Iterable<T>