Class Converters.Collection

  • Enclosing class:
    Converters

    public static class Converters.Collection
    extends Object
    Provides helper methods to create converters for collection.
    • Method Detail

      • map

        public static <S,​D> Converter<Collection<S>,​Collection<D>> map​(Converters.Converter<S,​D> elementConverter)
        Provides a helper method to create a collection converter that will map each element based on the elementConverter.
           using(Collection.map(String::toUpperCase)).map();
           using(Collection.map(ele -> new Destination(ele)).map();
         
        Type Parameters:
        S - the source element type
        D - the destination element type
        Parameters:
        elementConverter - the converter to map the source element to destination element
        Returns:
        a Converter
      • first

        public static <S> Converters.ChainableConverter<Collection<S>,​S> first()
        Provides a helper method to create a collection converter that will get the first element of source collect and convert it.
           using(Collection.first().to(Destination.class).map();
         
        Type Parameters:
        S - the source type
        Returns:
        a ChainableConverter