Class FieldPredicates

java.lang.Object
org.jeasy.random.FieldPredicates

public class FieldPredicates extends Object
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
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static 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>
    inClass(Class<?> clazz)
    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>
    named(String name)
    Create a predicate to check that a field has a certain name pattern.
    static java.util.function.Predicate<Field>
    ofType(Class<?> type)
    Create a predicate to check that a field has a certain type.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • FieldPredicates

      public FieldPredicates()
  • Method Details

    • named

      public static java.util.function.Predicate<Field> named(String name)
      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

      public static java.util.function.Predicate<Field> ofType(Class<?> type)
      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

      public static java.util.function.Predicate<Field> inClass(Class<?> clazz)
      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

      public static java.util.function.Predicate<Field> hasModifiers(Integer modifiers)
      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