Package swiss.trustbroker.util
Class PropertyUtil
java.lang.Object
swiss.trustbroker.util.PropertyUtil
Java bean property utilities.
-
Method Summary
Modifier and TypeMethodDescriptionstatic <X> booleancopyAttributeIfBlank(BiConsumer<X, String> setter, Function<X, String> getter, X target, X base) Copy attribute from base to target if set in base, but not in target (blank check).static <X,Y> boolean copyAttributeIfMissing(BiConsumer<X, Y> setter, Function<X, Y> getter, X target, X base) Copy attribute from base to target if set in base, but not in target (null check).static <X,Y> boolean copyAttributeIfRequired(BiConsumer<X, Y> setter, Function<X, Y> getter, X target, X base, Predicate<Y> copyCondition) Copy attribute from base to target if set in base, but not in target (using copyCondition Predicate).static <X> voidcopyMissingAttributes(Set<String> propertyNames, X target, X base) Copy all attributes from base to target if set in base, but not in target.static <X> voidcopyMissingAttributes(X target, X base) Copy all attributes from base to target if set in base, but not in target.static <C,T extends Number>
TevaluatePositiveNumberProperty(C instance, Function<C, T> policy, Supplier<T> defaultValue) static <C,T> T evaluateProperty(C instance, Function<C, T> policy, Supplier<T> defaultValue)
-
Method Details
-
copyMissingAttributes
public static <X> void copyMissingAttributes(X target, X base) Copy all attributes from base to target if set in base, but not in target. Note: Careful if you have aBooleanwith getterBoolean getPropertyandsetProperty(Boolean)and a convenience overrideboolean isPropertya property descriptor is produced for theboolean isPropertywithout a setter and the propagation fails! I.e. don't name the convenience accessors 'is', but leave the 'is' out. -
copyMissingAttributes
Copy all attributes from base to target if set in base, but not in target. -
copyAttributeIfBlank
public static <X> boolean copyAttributeIfBlank(BiConsumer<X, String> setter, Function<X, String> getter, X target, X base) Copy attribute from base to target if set in base, but not in target (blank check).- Returns:
- true if copying was done, false if a merge of the values is needed
-
copyAttributeIfMissing
public static <X,Y> boolean copyAttributeIfMissing(BiConsumer<X, Y> setter, Function<X, Y> getter, X target, X base) Copy attribute from base to target if set in base, but not in target (null check).- Returns:
- true if copying was done, false if a merge of the values is needed
-
copyAttributeIfRequired
public static <X,Y> boolean copyAttributeIfRequired(BiConsumer<X, Y> setter, Function<X, Y> getter, X target, X base, Predicate<Y> copyCondition) Copy attribute from base to target if set in base, but not in target (using copyCondition Predicate).- Returns:
- true if copying was done, false if a merge of the values is needed
-
evaluateProperty
-
evaluatePositiveNumberProperty
-