Class RConverter.CollectingConverter<X,Y>

java.lang.Object
uk.co.terminological.rjava.RConverter.CollectingConverter<X,Y>
Type Parameters:
X - - source datatype which will usually be a java primitive type or similar
Y - - target datatype which will usually be an RVector of some kind
Enclosing class:
RConverter

public static class RConverter.CollectingConverter<X,Y> extends Object
The ConvertingCollector interface allows us to reuse stream collectors for other non stream data types by apply these to streams, iterators, arrays, collections, and iterables, as well as plain instances. By default all of these conversions are handled through streams. The target data type is in our case usually an RVector
Author:
terminological
  • Constructor Details

    • CollectingConverter

      public CollectingConverter(Collector<X,?,Y> collector)
      Instantiates a new collecting converter.
      Parameters:
      collector - the collector
  • Method Details

    • convert

      public Y convert(X instance)
      Convert an instance of type X to Y.
      Parameters:
      instance - a singleton of type X
      Returns:
      a list or array
    • convert

      public Y convert(Stream<X> stream)
      Convert a stream of type X to Y.
      Parameters:
      stream - a stream of type X
      Returns:
      a list or array
    • convert

      public Y convert(Collection<X> collection)
      Convert a collection of type X to Y.
      Parameters:
      collection - a collection of type X
      Returns:
      a list or array
    • convert

      public Y convert(Iterable<X> iterable)
      Convert a iterable of type X to Y.
      Parameters:
      iterable - the iterable
      Returns:
      the y
    • convert

      public Y convert(Iterator<X> iterator)
      Convert a iterator of type X to Y.
      Parameters:
      iterator - the iterator
      Returns:
      the y
    • convert

      public Y convert(X[] array)
      Convert a array of type X to Y.
      Parameters:
      array - the array
      Returns:
      the y
    • from

      public static <A, B> RConverter.CollectingConverter<A,B> from(Collector<A,?,B> collector)
      Static constructor using a collector.
      Type Parameters:
      A - the generic type
      B - the generic type
      Parameters:
      collector - the collector
      Returns:
      the collecting converter