Package org.dspace.util
Class FunctionalUtils
java.lang.Object
org.dspace.util.FunctionalUtils
These methods are linked to the functional paradigm and use
Functional interfaces of java 8+, all the main
interfaces are in the package java.util.function.- Author:
- Vincenzo Mecca (vins01-4science - vincenzo.mecca at 4science.com)
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> TgetCheckDefaultOrBuild(Predicate<T> defaultValueChecker, T defaultValue, Supplier<T> builder) Tests thedefaultValueusing thedefaultValueChecker.static <T> TgetDefaultOrBuild(T defaultValue, Supplier<T> builder) Tests thatdefaultValueisn't null.
-
Method Details
-
getDefaultOrBuild
Tests thatdefaultValueisn't null. If this test is positive, then returns thedefaultValue; Otherwise builds a new instance using thebuilder- Parameters:
defaultValue- default instance valuebuilder- instance generator- Returns:
- corresponding non-null instance
-
getCheckDefaultOrBuild
public static <T> T getCheckDefaultOrBuild(Predicate<T> defaultValueChecker, T defaultValue, Supplier<T> builder) Tests thedefaultValueusing thedefaultValueChecker. If its test is positive, then returns thedefaultValue; Otherwise builds a new instance using thebuilder- Parameters:
defaultValueChecker- checker that tests the defaultValuedefaultValue- default instance valuebuilder- supplier that generates a typed instance- Returns:
- corresponding instance after check
-