Class MapperC<T>

java.lang.Object
com.rosetta.model.lib.mapper.MapperC<T>
All Implemented Interfaces:
Mapper<T>, MapperBuilder<T>

public class MapperC<T> extends Object implements MapperBuilder<T>
  • Constructor Details

  • Method Details

    • ofNull

      public static <T> MapperC<T> ofNull()
    • of

      @SafeVarargs public static <T> MapperC<T> of(MapperBuilder<? extends T>... ts)
    • of

      public static <T> MapperC<T> of(List<? extends T> ts)
    • map

      public <F> MapperC<F> map(String name, Function<T,F> mappingFunc)
      Description copied from interface: MapperBuilder
      Helper function to map a value with single cardinality
      Specified by:
      map in interface MapperBuilder<T>
    • map

      public <F> MapperC<F> map(NamedFunction<T,F> mappingFunc)
      Maps list parent item to single child item.
      Specified by:
      map in interface MapperBuilder<T>
    • mapC

      public <F> MapperC<F> mapC(String name, Function<T,List<? extends F>> mappingFunc)
      Description copied from interface: MapperBuilder
      Helper function to map a value with multiple cardinality
      Specified by:
      mapC in interface MapperBuilder<T>
    • mapC

      public <F> MapperC<F> mapC(NamedFunction<T,List<? extends F>> mappingFunc)
      Maps list parent item to list child item.
      Specified by:
      mapC in interface MapperBuilder<T>
    • filterItem

      public MapperC<T> filterItem(Predicate<MapperS<T>> predicate)
      Parameters:
      predicate - - test that determines whether to filter list item. True to include in list, and false to exclude.
      Returns:
      filtered list
    • filterItemNullSafe

      public MapperC<T> filterItemNullSafe(Function<MapperS<T>,Boolean> predicate)
      Filter items of list based on the given predicate.
      Parameters:
      predicate - - test that determines whether to filter list item. True to include in list, and false to exclude.
      Returns:
      filtered list
    • mapItem

      public <F> MapperC<F> mapItem(Function<MapperS<T>,MapperS<F>> mappingFunc)
      Map items of a list based on the given mapping function.
      Type Parameters:
      F -
      Parameters:
      mappingFunc -
      Returns:
      mapped list
    • mapItemToList

      public <F> MapperListOfLists<F> mapItemToList(Function<MapperS<T>,MapperC<F>> mappingFunc)
      Map items of a list based on the given mapping function.
      Type Parameters:
      F -
      Parameters:
      mappingFunc -
      Returns:
      mapped list
    • apply

      public <F> F apply(Function<MapperC<T>,F> f)
      Apply a function to this mapper
    • reduce

      public <F> MapperS<F> reduce(BinaryOperator<MapperS<F>> reduceFunc)
      Reduce list items to single item based on the given reduce function.
      Type Parameters:
      F -
      Parameters:
      reduceFunc -
      Returns:
      reduced item
    • reduce

      public <F> MapperS<F> reduce(MapperS<F> initial, BinaryOperator<MapperS<F>> reduceFunc)
      Reduce list items to single item based on the given reduce function.
      Type Parameters:
      F -
      Parameters:
      reduceFunc -
      Returns:
      reduced item
    • sumInteger

      public MapperS<Integer> sumInteger()
      Sum list of integers.
      Returns:
      total of summed integers.
    • sumLong

      public MapperS<Long> sumLong()
      Sum list of longs.
      Returns:
      total of summed longs.
    • sumBigInteger

      public MapperS<BigInteger> sumBigInteger()
      Sum list of numbers.
      Returns:
      total of summed numbers.
    • sumBigDecimal

      public MapperS<BigDecimal> sumBigDecimal()
      Sum list of numbers.
      Returns:
      total of summed numbers.
    • join

      public MapperS<String> join(MapperS<String> delimiter)
      Concatenate list of strings, separating each item with delimiter.
      Parameters:
      delimiter - - item separator
      Returns:
      concatenated string
    • min

      public <F extends Comparable<F>> MapperS<T> min()
      Get minimum item from a list of comparable items.
      Returns:
      minimum
    • min

      public <F extends Comparable<F>> MapperS<T> min(Function<MapperS<T>,MapperS<F>> comparableGetter)
      Get item from list based on minimum item attribute (provided by comparableGetter)
      Type Parameters:
      F -
      Parameters:
      comparableGetter - - getter for comparable attribute
      Returns:
      minimum
    • max

      public <F extends Comparable<F>> MapperS<T> max()
      Get maximum item from a list of comparable items.
      Returns:
      maximum
    • max

      public <F extends Comparable<F>> MapperS<T> max(Function<MapperS<T>,MapperS<F>> comparableGetter)
      Get item from list based on maximum item attribute (provided by comparableGetter)
      Type Parameters:
      F -
      Parameters:
      comparableGetter - - getter for comparable attribute
      Returns:
      maximum
    • sort

      public MapperC<T> sort()
      Sort list of comparable items.
      Returns:
      sorted list
    • sort

      public <F extends Comparable<F>> MapperC<T> sort(Function<MapperS<T>,MapperS<F>> comparableGetter)
      Sort list of items based on comparable attribute.
      Type Parameters:
      F - comparable type
      Parameters:
      comparableGetter - to get comparable item to sort by
      Returns:
      sorted list
    • reverse

      public MapperC<T> reverse()
      Reverse items of a list.
      Returns:
      reversed list
    • first

      public MapperS<T> first()
      Gets first item of the list.
      Returns:
      first list item
    • last

      public MapperS<T> last()
      Gets last item of the list.
      Returns:
      last list item
    • getItem

      public MapperS<T> getItem(MapperS<Integer> indexGetter)
      Get item at specified index, returns null if index out of bounds.
      Returns:
      list item at index
    • removeItem

      public MapperC<T> removeItem(MapperS<Integer> indexGetter)
      Remove item at specified index, returns list without removed item.
      Returns:
      list without specified item
    • nonErrorItems

      protected Stream<MapperItem<? extends T,?>> nonErrorItems()
    • get

      public T get()
      Specified by:
      get in interface Mapper<T>
    • getOrDefault

      public T getOrDefault(T defaultValue)
      Specified by:
      getOrDefault in interface Mapper<T>
    • getMulti

      public List<T> getMulti()
      Specified by:
      getMulti in interface Mapper<T>
    • getParent

      public Optional<?> getParent()
      Specified by:
      getParent in interface Mapper<T>
    • getParentMulti

      public List<?> getParentMulti()
      Specified by:
      getParentMulti in interface Mapper<T>
    • resultCount

      public int resultCount()
      Specified by:
      resultCount in interface Mapper<T>
    • getPaths

      public List<Mapper.Path> getPaths()
      Specified by:
      getPaths in interface Mapper<T>
    • getErrorPaths

      public List<Mapper.Path> getErrorPaths()
      Specified by:
      getErrorPaths in interface Mapper<T>
    • getErrors

      public List<String> getErrors()
      Specified by:
      getErrors in interface Mapper<T>
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • unionSame

      public MapperC<T> unionSame(MapperBuilder<T> other)
      Specified by:
      unionSame in interface MapperBuilder<T>
    • unionDifferent

      public MapperC<Object> unionDifferent(MapperBuilder<?> other)
      Specified by:
      unionDifferent in interface MapperBuilder<T>
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • getItems

      public Stream<MapperItem<? extends T,?>> getItems()
      Specified by:
      getItems in interface MapperBuilder<T>