org.junit.runners.model
Class FrameworkField

java.lang.Object
  extended by org.junit.runners.model.FrameworkMember<FrameworkField>
      extended by org.junit.runners.model.FrameworkField
All Implemented Interfaces:
Annotatable

public class FrameworkField
extends FrameworkMember<FrameworkField>

Represents a field on a test class (currently used only for Rules in BlockJUnit4ClassRunner, but custom runners can make other uses)

Since:
4.7

Constructor Summary
FrameworkField(Field field)
          Returns a new FrameworkField for field.
 
Method Summary
 Object get(Object target)
          Attempts to retrieve the value of this field on target
<T extends Annotation>
T
getAnnotation(Class<T> annotationType)
          Returns the annotation on the model element of the given type, or @code{null}
 Annotation[] getAnnotations()
          Returns the model elements' annotations.
 Class<?> getDeclaringClass()
           
 Field getField()
           
protected  int getModifiers()
           
 String getName()
           
 Class<?> getType()
           
 boolean isShadowedBy(FrameworkField otherMember)
           
 String toString()
           
 
Methods inherited from class org.junit.runners.model.FrameworkMember
isPublic, isStatic
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FrameworkField

public FrameworkField(Field field)
Returns a new FrameworkField for field.

Access relaxed to public since version 4.13.1.

Method Detail

getName

public String getName()
Specified by:
getName in class FrameworkMember<FrameworkField>

getAnnotations

public Annotation[] getAnnotations()
Description copied from interface: Annotatable
Returns the model elements' annotations.


getAnnotation

public <T extends Annotation> T getAnnotation(Class<T> annotationType)
Description copied from interface: Annotatable
Returns the annotation on the model element of the given type, or @code{null}


isShadowedBy

public boolean isShadowedBy(FrameworkField otherMember)

getModifiers

protected int getModifiers()
Specified by:
getModifiers in class FrameworkMember<FrameworkField>

getField

public Field getField()
Returns:
the underlying java Field

getType

public Class<?> getType()
Specified by:
getType in class FrameworkMember<FrameworkField>
Returns:
the underlying Java Field type
See Also:
Field.getType()

getDeclaringClass

public Class<?> getDeclaringClass()
Specified by:
getDeclaringClass in class FrameworkMember<FrameworkField>

get

public Object get(Object target)
           throws IllegalArgumentException,
                  IllegalAccessException
Attempts to retrieve the value of this field on target

Throws:
IllegalArgumentException
IllegalAccessException

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2002–2020 JUnit. All rights reserved.