Add methods in KiwiReflection to ignore or include specific properties to nullify #522
Labels
new feature
A new feature such as a new class, method, package, group of classes, etc.
Milestone
KiwiReflection has the
invokeMutatorMethodsWithNull
method which is primarily useful in tests to set all mutable properties to null (e.g. when testing validations). However, sometimes this doesn't work for whatever reason, or you want to nullify only certain properties. This will add three new methods:static void invokeMutatorMethodsWithNullIgnoringProperties(Object target, String... properties)
static void invokeMutatorMethodsWithNullIncludingOnlyProperties(Object target, String... properties)
static void invokeMutatorMethodsWithNullSatisfying(Object target, Predicate<Method> methodPredicate)
The last method was added b/c it was created to be generic and used by the first two methods, and by itself is also useful, e.g. you could exclude setting properties that are
Optional
orIterable
tonull
.The
properties
arguments define the name of the logical property, e.g. "firstName" rather than the setter method name. The setter method name will be constructed by prepending "set" and capitalizing the first letter of the property.The text was updated successfully, but these errors were encountered: