Class Mapper
java.lang.Object
com.apptasticsoftware.rssreader.util.Mapper
Provides methods for mapping field
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> TcreateIfNull(Supplier<Optional<T>> getter, Consumer<T> setter, Supplier<T> factory) Create a new instance if a getter returns optional empty and assigns the field the new instance.static <T> Optional<T> createIfNullOptional(Supplier<Optional<T>> getter, Consumer<T> setter, Supplier<T> factory) Create a new instance if a getter returns optional empty and assigns the field the new instance.static <T> List<T> emptyListIfNull(List<T> list) Returns an empty list if the provided list is null.static voidmapBoolean(String text, Consumer<Boolean> func) Maps a boolean text value (true, false, no or yes) to a boolean field.static <T> voidmapIfEmpty(String text, Supplier<T> getter, Consumer<String> setter) Map value if field has not been mapped beforestatic voidmapInteger(String text, Consumer<Integer> func) Maps a integer text value to a integer field.static voidMaps a long text value to a long field.
-
Method Details
-
mapBoolean
-
mapInteger
-
mapLong
-
mapIfEmpty
-
createIfNull
public static <T> T createIfNull(Supplier<Optional<T>> getter, Consumer<T> setter, Supplier<T> factory) Create a new instance if a getter returns optional empty and assigns the field the new instance.- Type Parameters:
T- any class- Parameters:
getter- getter methodsetter- setter methodfactory- factory for creating a new instance if field is not set before- Returns:
- existing or new instance
-
createIfNullOptional
public static <T> Optional<T> createIfNullOptional(Supplier<Optional<T>> getter, Consumer<T> setter, Supplier<T> factory) Create a new instance if a getter returns optional empty and assigns the field the new instance.- Type Parameters:
T- any class- Parameters:
getter- getter methodsetter- setter methodfactory- factory for creating a new instance if field is not set before- Returns:
- existing or new instance
-
emptyListIfNull
-