Top Description Fields Constructors Methods
com.google.common.reflect

public final Class Parameter

extends Object
implements AnnotatedElement
Class Inheritance
All Implemented Interfaces
java.lang.reflect.AnnotatedElement
Annotations
@ElementTypesAreNonnullByDefault
Static Imports
com.google.common.base.Preconditions.checkNotNull, java.util.Objects.requireNonNull

Represents a method or constructor parameter.
Author
Ben Yu
Since
14.0

Field Summary

Modifier and TypeField and Description
private final @Nullable Object
annotatedType

An AnnotatedType instance, or null under Android VMs (possible only when using the Android flavor of Guava).

private final ImmutableList<Annotation>
private final Invokable<?, ?>
private final int
private final TypeToken<?>

Constructor Summary

AccessConstructor and Description
pack-priv
Parameter(Invokable<?, ?> declaration, int position, TypeToken<?> type, Annotation[] annotations, @Nullable Object annotatedType)

Method Summary

Modifier and TypeMethod and Description
public boolean
equals(Object
the reference object with which to compare.
obj
)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.
public AnnotatedType
getAnnotatedType()

Returns the AnnotatedType of the parameter.

public <A extends Annotation> A
getAnnotation(Class<A>
the Class object corresponding to the annotation type
annotationType
)

Implements java.lang.reflect.AnnotatedElement.getAnnotation.

Returns this element's annotation for the specified type if such an annotation is present, else null.
public Annotation[]
getAnnotations()

Implements java.lang.reflect.AnnotatedElement.getAnnotations.

Returns annotations that are present on this element.
public <A extends Annotation> A[]
getAnnotationsByType(Class<A>
the Class object corresponding to the annotation type
annotationType
)

Overrides default java.lang.reflect.AnnotatedElement.getAnnotationsByType.

Returns annotations that are associated with this element.
public <A extends Annotation> A
getDeclaredAnnotation(Class<A>
the Class object corresponding to the annotation type
annotationType
)

Overrides default java.lang.reflect.AnnotatedElement.getDeclaredAnnotation.

Returns this element's annotation for the specified type if such an annotation is directly present, else null.
public Annotation[]
getDeclaredAnnotations()

Implements java.lang.reflect.AnnotatedElement.getDeclaredAnnotations.

Returns annotations that are directly present on this element.
public <A extends Annotation> A[]
getDeclaredAnnotationsByType(Class<A>
the Class object corresponding to the annotation type
annotationType
)

Overrides default java.lang.reflect.AnnotatedElement.getDeclaredAnnotationsByType.

Returns this element's annotation(s) for the specified type if such annotations are either directly present or indirectly present.
public Invokable<?, ?>
getDeclaringInvokable()

Returns the Invokable that declares this parameter.

public TypeToken<?>
getType()

Returns the type of the parameter.

public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for this object.
public boolean
isAnnotationPresent(Class<? extends Annotation>
the Class object corresponding to the annotation type
annotationType
)

Overrides default java.lang.reflect.AnnotatedElement.isAnnotationPresent.

Returns true if an annotation for the specified type is present on this element, else false.
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

annotatedTypeback to summary
private final @Nullable Object annotatedType

An AnnotatedType instance, or null under Android VMs (possible only when using the Android flavor of Guava). The field is declared with a type of Object to avoid compatibility problems on Android VMs. The corresponding accessor method, however, can have the more specific return type as long as users are careful to guard calls to it with version checks or reflection: Android VMs ignore the types of elements that aren't used.

annotationsback to summary
private final ImmutableList<Annotation> annotations
declarationback to summary
private final Invokable<?, ?> declaration
positionback to summary
private final int position
typeback to summary
private final TypeToken<?> type

Constructor Detail

Parameterback to summary
pack-priv Parameter(Invokable<?, ?> declaration, int position, TypeToken<?> type, Annotation[] annotations, @Nullable Object annotatedType)

Method Detail

equalsback to summary
public boolean equals(Object obj)

Overrides java.lang.Object.equals.

Doc from java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Parameters
obj:Object

the reference object with which to compare.

Returns:boolean

true if this object is the same as the obj argument; false otherwise.

Annotations
@Override
getAnnotatedTypeback to summary
public AnnotatedType getAnnotatedType()

Returns the AnnotatedType of the parameter.

Annotations
@SuppressWarnings:Java7ApiChecker
Since
25.1 for guava-jre
getAnnotationback to summary
public <A extends Annotation> A getAnnotation(Class<A> annotationType)

Implements java.lang.reflect.AnnotatedElement.getAnnotation.

Doc from java.lang.reflect.AnnotatedElement.getAnnotation.

Returns this element's annotation for the specified type if such an annotation is present, else null.

Parameters
<A>
the type of the annotation to query for and return if present
annotationType:Class<A>

the Class object corresponding to the annotation type

Returns:A

this element's annotation for the specified annotation type if present on this element, else null

Annotations
@Override
@CheckForNull
getAnnotationsback to summary
public Annotation[] getAnnotations()

Implements java.lang.reflect.AnnotatedElement.getAnnotations.

Doc from java.lang.reflect.AnnotatedElement.getAnnotations.

Returns annotations that are present on this element. If there are no annotations present on this element, the return value is an array of length 0. The caller of this method is free to modify the returned array; it will have no effect on the arrays returned to other callers.

Returns:Annotation[]

annotations present on this element

Annotations
@Override
getAnnotationsByTypeback to summary
public <A extends Annotation> A[] getAnnotationsByType(Class<A> annotationType)

Overrides default java.lang.reflect.AnnotatedElement.getAnnotationsByType.

Doc from java.lang.reflect.AnnotatedElement.getAnnotationsByType.

Returns annotations that are associated with this element. If there are no annotations associated with this element, the return value is an array of length 0. The difference between this method and getAnnotation(Class) is that this method detects if its argument is a repeatable annotation type (JLS 9.6), and if so, attempts to find one or more annotations of that type by "looking through" a container annotation. The caller of this method is free to modify the returned array; it will have no effect on the arrays returned to other callers.

Parameters
<A>
the type of the annotation to query for and return if present
annotationType:Class<A>

the Class object corresponding to the annotation type

Returns:A[]

all this element's annotations for the specified annotation type if associated with this element, else an array of length zero

Annotations
@Override
Since
18.0
getDeclaredAnnotationback to summary
public <A extends Annotation> A getDeclaredAnnotation(Class<A> annotationType)

Overrides default java.lang.reflect.AnnotatedElement.getDeclaredAnnotation.

Doc from java.lang.reflect.AnnotatedElement.getDeclaredAnnotation.

Returns this element's annotation for the specified type if such an annotation is directly present, else null. This method ignores inherited annotations. (Returns null if no annotations are directly present on this element.)

Parameters
<A>
the type of the annotation to query for and return if directly present
annotationType:Class<A>

the Class object corresponding to the annotation type

Returns:A

this element's annotation for the specified annotation type if directly present on this element, else null

Annotations
@Override
@CheckForNull
Since
18.0
getDeclaredAnnotationsback to summary
public Annotation[] getDeclaredAnnotations()

Implements java.lang.reflect.AnnotatedElement.getDeclaredAnnotations.

Doc from java.lang.reflect.AnnotatedElement.getDeclaredAnnotations.

Returns annotations that are directly present on this element. This method ignores inherited annotations. If there are no annotations directly present on this element, the return value is an array of length 0. The caller of this method is free to modify the returned array; it will have no effect on the arrays returned to other callers.

Returns:Annotation[]

annotations directly present on this element

Annotations
@Override
Since
18.0
getDeclaredAnnotationsByTypeback to summary
public <A extends Annotation> A[] getDeclaredAnnotationsByType(Class<A> annotationType)

Overrides default java.lang.reflect.AnnotatedElement.getDeclaredAnnotationsByType.

Doc from java.lang.reflect.AnnotatedElement.getDeclaredAnnotationsByType.

Returns this element's annotation(s) for the specified type if such annotations are either directly present or indirectly present. This method ignores inherited annotations. If there are no specified annotations directly or indirectly present on this element, the return value is an array of length 0. The difference between this method and getDeclaredAnnotation(Class) is that this method detects if its argument is a repeatable annotation type (JLS 9.6), and if so, attempts to find one or more annotations of that type by "looking through" a container annotation if one is present. The caller of this method is free to modify the returned array; it will have no effect on the arrays returned to other callers.

Parameters
<A>
the type of the annotation to query for and return if directly or indirectly present
annotationType:Class<A>

the Class object corresponding to the annotation type

Returns:A[]

all this element's annotations for the specified annotation type if directly or indirectly present on this element, else an array of length zero

Annotations
@Override
Since
18.0
getDeclaringInvokableback to summary
public Invokable<?, ?> getDeclaringInvokable()

Returns the Invokable that declares this parameter.

getTypeback to summary
public TypeToken<?> getType()

Returns the type of the parameter.

hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for this object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Returns:int

a hash code value for this object

Annotations
@Override
isAnnotationPresentback to summary
public boolean isAnnotationPresent(Class<? extends Annotation> annotationType)

Overrides default java.lang.reflect.AnnotatedElement.isAnnotationPresent.

Doc from java.lang.reflect.AnnotatedElement.isAnnotationPresent.

Returns true if an annotation for the specified type is present on this element, else false. This method is designed primarily for convenient access to marker annotations.

The truth value returned by this method is equivalent to: getAnnotation(annotationClass) != null

Parameters
annotationType:Class<? extends Annotation>

the Class object corresponding to the annotation type

Returns:boolean

true if an annotation for the specified annotation type is present on this element, else false

Annotations
@Override
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object

Annotations
@Override