Package org.jeasy.random
Class FieldPredicates
java.lang.Object
org.jeasy.random.FieldPredicates
Common predicates to identify fields. Usually used in combination to define a field
in an object graph. For example:
Predicate<Field> predicate = named("name").and(ofType(String.class)).and(inClass(Person.class));
- Author:
- Mahmoud Ben Hassine ([email protected])
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic java.util.function.Predicate<Field>
hasModifiers
(Integer modifiers) Create a predicate to check that a field has a given set of modifiers.static java.util.function.Predicate<Field>
Create a predicate to check that a field is defined in a given class.static java.util.function.Predicate<Field>
isAnnotatedWith
(Class<? extends Annotation>... annotations) Create a predicate to check that a field is annotated with one of the given annotations.static java.util.function.Predicate<Field>
Create a predicate to check that a field has a certain name pattern.static java.util.function.Predicate<Field>
Create a predicate to check that a field has a certain type.
-
Constructor Details
-
FieldPredicates
public FieldPredicates()
-
-
Method Details
-
named
Create a predicate to check that a field has a certain name pattern.- Parameters:
name
- pattern of the field name to check- Returns:
- Predicate to check that a field has a certain name pattern
-
ofType
Create a predicate to check that a field has a certain type.- Parameters:
type
- of the field to check- Returns:
- Predicate to check that a field has a certain type
-
inClass
Create a predicate to check that a field is defined in a given class.- Parameters:
clazz
- enclosing type of the field to check- Returns:
- Predicate to check that a field is defined in a given class.
-
isAnnotatedWith
public static java.util.function.Predicate<Field> isAnnotatedWith(Class<? extends Annotation>... annotations) Create a predicate to check that a field is annotated with one of the given annotations.- Parameters:
annotations
- present on the field- Returns:
- Predicate to check that a field is annotated with one of the given annotations.
-
hasModifiers
Create a predicate to check that a field has a given set of modifiers.- Parameters:
modifiers
- of the field to check- Returns:
- Predicate to check that a field has a given set of modifiers
-