Package java.lang.annotation
Interface Annotation
-
- All Known Implementing Classes:
Deprecated,Documented,Override,Retention,SuppressWarnings,Target
public interface AnnotationDefines the interface implemented by all annotations. Note that the interface itself is not an annotation, and neither is an interface that simply extends this one. Only the compiler is able to create proper annotation types.- Since:
- 1.5
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description Class<? extends Annotation>annotationType()Returns the type of this annotation.booleanequals(Object obj)Determines whether or not this annotation is equivalent to the annotation passed.inthashCode()Returns the hash code of this annotation.StringtoString()Returns aStringrepresentation of this annotation.
-
-
-
Method Detail
-
annotationType
Class<? extends Annotation> annotationType()
Returns the type of this annotation.- Returns:
- A
Classinstance representing the annotation type.
-
equals
boolean equals(Object obj)
Determines whether or not this annotation is equivalent to the annotation passed. This is determined according to the following rules:-
Two annotations
xandyare equal if and only if they are members of the same annotation type and all the member values ofxare equal to the corresponding member values ofy. -
The equality of primitive member values
xandyis determined (in a way similar to) using the corresponding wrapper classes. For example,Integer.valueOf(x).equals(Integer.valueOf(y)is used forintvalues. Note: The behavior is identical to the==operator for all but the floating point type, so the implementation may as well use==in these cases for performance reasons. Only for thefloatanddoubletypes the result will be slightly different:NaNis equal toNaN, and-0.0is equal to0.0, both of which is normally not the case. -
The equality of two array member values
xandyis determined using the correspondingequals(x, y)helper function inArrays. -
The hash code for all other member values is determined by simply
calling their
equals()method.
- Overrides:
equalsin classObject- Parameters:
obj- The object to compare to.- Returns:
trueifobjis equal to this annotation,falseotherwise.- See Also:
Object.hashCode()
-
Two annotations
-
hashCode
int hashCode()
Returns the hash code of this annotation. The hash code is determined according to the following rules:- The hash code of an annotation is the sum of the hash codes of its annotation members.
-
The hash code of an annotation member is calculated as
(0x7f * n.hashCode()) ^ v.hashCode()), wherenis the name of the member (as aString) andvits value. -
The hash code for a primitive member value is determined using
the corresponding wrapper type. For example,
Integer.valueOf(v).hashCode()is used for anintvaluev. -
The hash code for an array member value
vis determined using the correspondinghashCode(v)helper function inArrays. -
The hash code for all other member values is determined by simply
calling their
hashCodemethod.
- Overrides:
hashCodein classObject- Returns:
- the hash code.
- See Also:
Object.equals(java.lang.Object)
-
toString
String toString()
Returns aStringrepresentation of this annotation. It is not strictly defined what the representation has to look like, but it usually consists of the name of the annotation, preceded by a "@". If the annotation contains field members, their names and values are also included in the result.
-
-