Class PropertyUtil

java.lang.Object
swiss.trustbroker.util.PropertyUtil

public class PropertyUtil extends Object
Java bean property utilities.
  • 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 a Boolean with getter Boolean getProperty and setProperty(Boolean) and a convenience override boolean isProperty a property descriptor is produced for the boolean isProperty without a setter and the propagation fails! I.e. don't name the convenience accessors 'is', but leave the 'is' out.
    • copyMissingAttributes

      public static <X> void copyMissingAttributes(Set<String> propertyNames, X target, X base)
      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

      public static <C, T> T evaluateProperty(C instance, Function<C,T> policy, Supplier<T> defaultValue)
    • evaluatePositiveNumberProperty

      public static <C, T extends Number> T evaluatePositiveNumberProperty(C instance, Function<C,T> policy, Supplier<T> defaultValue)