nl.jqno.equalsverifier.util.annotations
Class AnnotationAccessor

java.lang.Object
  extended by nl.jqno.equalsverifier.util.annotations.AnnotationAccessor

public class AnnotationAccessor
extends Object

Provides access to the annotations that are defined on a class and its fields.

Author:
Jan Ouwens

Constructor Summary
AnnotationAccessor(Annotation[] supportedAnnotations, Class<?> type, boolean ignoreFailure)
          Constructor
 
Method Summary
 boolean fieldHas(String fieldName, Annotation annotation)
          Determines whether type has a particular annotation on a particular field.
 boolean typeHas(Annotation annotation)
          Determines whether type has a particular annotation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AnnotationAccessor

public AnnotationAccessor(Annotation[] supportedAnnotations,
                          Class<?> type,
                          boolean ignoreFailure)
Constructor

Parameters:
supportedAnnotations - Collection of annotations to query.
type - The class whose annotations need to be queried.
ignoreFailure - Ignore when processing annotations fails when the class file cannot be read.
Method Detail

typeHas

public boolean typeHas(Annotation annotation)
Determines whether type has a particular annotation.

Parameters:
annotation - The annotation we want to find.
Returns:
True if type has an annotation with the supplied name.

fieldHas

public boolean fieldHas(String fieldName,
                        Annotation annotation)
Determines whether type has a particular annotation on a particular field.

Parameters:
fieldName - The name of the field for which we want to know if it has the annotation.
annotation - The annotation we want to find.
Returns:
True if the specified field in type has the specified annotation.
Throws:
ReflectionException - if type does not have the specified field.


Copyright © 2015. All Rights Reserved.