You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This field definition is static and independent from any randomization context.
The idea of this new feature is to introduce a strategy interface that allows for field/type exclusion dynamically depending on the randomization context. This new API could be something like:
/** * Strategy interface for field/type exclusion. */publicinterfaceExclusionPolicy {
/** * Given the current randomization context, should the field be excluded? * * @param field the field to check * @param context the current randomization context * @return true if the field should be excluded, false otherwise */booleanshouldBeExcluded(finalFieldfield, finalRandomizerContextcontext);
/** * Given the current randomization context, should the type be excluded? * * @param type the type to check * @param context the current randomization context * @return true if the type should be excluded, false otherwise */booleanshouldBeExcluded(finalClass<?> type, finalRandomizerContextcontext);
}
The text was updated successfully, but these errors were encountered:
As of v3.9, field/type exclusion was possible through
EnhancedRandomBuilder.exclude
methods:public EnhancedRandomBuilder excludeField(Predicate<Field> predicate)
public EnhancedRandomBuilder excludeType(Predicate<Class<?>> predicate)
Those methods take a predicate which can be something like:
FieldPredicates.named("name").and(ofType(String.class)).and(inClass(Human.class)
This field definition is static and independent from any randomization context.
The idea of this new feature is to introduce a strategy interface that allows for field/type exclusion dynamically depending on the randomization context. This new API could be something like:
The text was updated successfully, but these errors were encountered: