Class FieldPredicates

  • All Implemented Interfaces:

    
    public class 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])

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • Field Summary

      Fields 
      Modifier and Type Field Description
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Method Summary

      Modifier and Type Method Description
      static Predicate<Field> named(String name) Create a predicate to check that a field has a certain name pattern.
      static Predicate<Field> ofType(Class<out Object> type) Create a predicate to check that a field has a certain type.
      static Predicate<Field> inClass(Class<out Object> clazz) Create a predicate to check that a field is defined in a given class.
      static Predicate<Field> isAnnotatedWith(Array<Class<out Annotation>> annotations) Create a predicate to check that a field is annotated with one of the given annotations.
      static Predicate<Field> hasModifiers(Integer modifiers) Create a predicate to check that a field has a given set of modifiers.
      • Methods inherited from class java.lang.Object

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

      • FieldPredicates

        FieldPredicates()
    • Method Detail

      • named

         static 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

         static Predicate<Field> ofType(Class<out Object> 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

         static Predicate<Field> inClass(Class<out Object> 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

         static Predicate<Field> isAnnotatedWith(Array<Class<out 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

         static 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