Package com.google.common.reflect
Class Element
- java.lang.Object
-
- java.lang.reflect.AccessibleObject
-
- com.google.common.reflect.Element
-
- All Implemented Interfaces:
java.lang.reflect.AnnotatedElement
,java.lang.reflect.Member
- Direct Known Subclasses:
Invokable
class Element extends java.lang.reflect.AccessibleObject implements java.lang.reflect.Member
Represents either aField
, aMethod
or aConstructor
. Provides convenience methods such asisPublic()
andisPackagePrivate()
.
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.reflect.AccessibleObject
accessibleObject
private java.lang.reflect.Member
member
-
Constructor Summary
Constructors Constructor Description Element(M member)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(java.lang.Object obj)
<A extends java.lang.annotation.Annotation>
AgetAnnotation(java.lang.Class<A> annotationClass)
java.lang.annotation.Annotation[]
getAnnotations()
java.lang.annotation.Annotation[]
getDeclaredAnnotations()
java.lang.Class<?>
getDeclaringClass()
int
getModifiers()
java.lang.String
getName()
TypeToken<?>
getOwnerType()
int
hashCode()
boolean
isAbstract()
Returns true if the method is abstract.boolean
isAccessible()
boolean
isAnnotationPresent(java.lang.Class<? extends java.lang.annotation.Annotation> annotationClass)
boolean
isFinal()
Returnstrue
if this method is final, perModifier.isFinal(getModifiers())
.boolean
isNative()
Returns true if the element is native.boolean
isPackagePrivate()
Returns true if the element is package-private.boolean
isPrivate()
Returns true if the element is private.boolean
isProtected()
Returns true if the element is protected.boolean
isPublic()
Returns true if the element is public.boolean
isStatic()
Returns true if the element is static.boolean
isSynchronized()
Returns true if the method is synchronized.boolean
isSynthetic()
(package private) boolean
isTransient()
Returns true if the field is transient.(package private) boolean
isVolatile()
Returns true if the field is volatile.void
setAccessible(boolean flag)
java.lang.String
toString()
-
-
-
Method Detail
-
getOwnerType
public TypeToken<?> getOwnerType()
-
isAnnotationPresent
public final boolean isAnnotationPresent(java.lang.Class<? extends java.lang.annotation.Annotation> annotationClass)
- Specified by:
isAnnotationPresent
in interfacejava.lang.reflect.AnnotatedElement
- Overrides:
isAnnotationPresent
in classjava.lang.reflect.AccessibleObject
-
getAnnotation
public final <A extends java.lang.annotation.Annotation> A getAnnotation(java.lang.Class<A> annotationClass)
- Specified by:
getAnnotation
in interfacejava.lang.reflect.AnnotatedElement
- Overrides:
getAnnotation
in classjava.lang.reflect.AccessibleObject
-
getAnnotations
public final java.lang.annotation.Annotation[] getAnnotations()
- Specified by:
getAnnotations
in interfacejava.lang.reflect.AnnotatedElement
- Overrides:
getAnnotations
in classjava.lang.reflect.AccessibleObject
-
getDeclaredAnnotations
public final java.lang.annotation.Annotation[] getDeclaredAnnotations()
- Specified by:
getDeclaredAnnotations
in interfacejava.lang.reflect.AnnotatedElement
- Overrides:
getDeclaredAnnotations
in classjava.lang.reflect.AccessibleObject
-
setAccessible
public final void setAccessible(boolean flag) throws java.lang.SecurityException
- Overrides:
setAccessible
in classjava.lang.reflect.AccessibleObject
- Throws:
java.lang.SecurityException
-
isAccessible
public final boolean isAccessible()
- Overrides:
isAccessible
in classjava.lang.reflect.AccessibleObject
-
getDeclaringClass
public java.lang.Class<?> getDeclaringClass()
- Specified by:
getDeclaringClass
in interfacejava.lang.reflect.Member
-
getName
public final java.lang.String getName()
- Specified by:
getName
in interfacejava.lang.reflect.Member
-
getModifiers
public final int getModifiers()
- Specified by:
getModifiers
in interfacejava.lang.reflect.Member
-
isSynthetic
public final boolean isSynthetic()
- Specified by:
isSynthetic
in interfacejava.lang.reflect.Member
-
isPublic
public final boolean isPublic()
Returns true if the element is public.
-
isProtected
public final boolean isProtected()
Returns true if the element is protected.
-
isPackagePrivate
public final boolean isPackagePrivate()
Returns true if the element is package-private.
-
isPrivate
public final boolean isPrivate()
Returns true if the element is private.
-
isStatic
public final boolean isStatic()
Returns true if the element is static.
-
isFinal
public final boolean isFinal()
Returnstrue
if this method is final, perModifier.isFinal(getModifiers())
.Note that a method may still be effectively "final", or non-overridable when it has no
final
keyword. For example, it could be private, or it could be declared by a final class. To tell whether a method is overridable, useInvokable.isOverridable()
.
-
isAbstract
public final boolean isAbstract()
Returns true if the method is abstract.
-
isNative
public final boolean isNative()
Returns true if the element is native.
-
isSynchronized
public final boolean isSynchronized()
Returns true if the method is synchronized.
-
isVolatile
final boolean isVolatile()
Returns true if the field is volatile.
-
isTransient
final boolean isTransient()
Returns true if the field is transient.
-
equals
public boolean equals(@Nullable java.lang.Object obj)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-