Package org.dspace.util
Class FunctionalUtils
- java.lang.Object
-
- org.dspace.util.FunctionalUtils
-
public class FunctionalUtils extends Object
These methods are linked to the functional paradigm and useFunctionalinterfaces of java 8+, all the main interfaces are in the packagejava.util.function.- Author:
- Vincenzo Mecca (vins01-4science - vincenzo.mecca at 4science.com)
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <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 Detail
-
getDefaultOrBuild
public static <T> T getDefaultOrBuild(T defaultValue, Supplier<T> builder)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
-
-