Annotation (Java SE 15 & JDK 15) (original) (raw)
All Known Implementing Classes:
[BeanProperty](../../../../java.desktop/java/beans/BeanProperty.html "annotation in java.beans")
, [BooleanFlag](../../../../jdk.jfr/jdk/jfr/BooleanFlag.html "annotation in jdk.jfr")
, [Category](../../../../jdk.jfr/jdk/jfr/Category.html "annotation in jdk.jfr")
, [ConstructorParameters](../../../../java.management/javax/management/ConstructorParameters.html "annotation in javax.management")
, [ConstructorProperties](../../../../java.desktop/java/beans/ConstructorProperties.html "annotation in java.beans")
, [ContentType](../../../../jdk.jfr/jdk/jfr/ContentType.html "annotation in jdk.jfr")
, [DataAmount](../../../../jdk.jfr/jdk/jfr/DataAmount.html "annotation in jdk.jfr")
, [Deprecated](../Deprecated.html "annotation in java.lang")
, [Description](../../../../jdk.jfr/jdk/jfr/Description.html "annotation in jdk.jfr")
, [DescriptorKey](../../../../java.management/javax/management/DescriptorKey.html "annotation in javax.management")
, [Documented](Documented.html "annotation in java.lang.annotation")
, [Enabled](../../../../jdk.jfr/jdk/jfr/Enabled.html "annotation in jdk.jfr")
, [Experimental](../../../../jdk.jfr/jdk/jfr/Experimental.html "annotation in jdk.jfr")
, [Frequency](../../../../jdk.jfr/jdk/jfr/Frequency.html "annotation in jdk.jfr")
, [FunctionalInterface](../FunctionalInterface.html "annotation in java.lang")
, [Generated](../../../../java.compiler/javax/annotation/processing/Generated.html "annotation in javax.annotation.processing")
, [Inherited](Inherited.html "annotation in java.lang.annotation")
, [JavaBean](../../../../java.desktop/java/beans/JavaBean.html "annotation in java.beans")
, [Label](../../../../jdk.jfr/jdk/jfr/Label.html "annotation in jdk.jfr")
, [MemoryAddress](../../../../jdk.jfr/jdk/jfr/MemoryAddress.html "annotation in jdk.jfr")
, [MetadataDefinition](../../../../jdk.jfr/jdk/jfr/MetadataDefinition.html "annotation in jdk.jfr")
, [MXBean](../../../../java.management/javax/management/MXBean.html "annotation in javax.management")
, [Name](../../../../jdk.jfr/jdk/jfr/Name.html "annotation in jdk.jfr")
, [Native](Native.html "annotation in java.lang.annotation")
, [Override](../Override.html "annotation in java.lang")
, [Percentage](../../../../jdk.jfr/jdk/jfr/Percentage.html "annotation in jdk.jfr")
, [Period](../../../../jdk.jfr/jdk/jfr/Period.html "annotation in jdk.jfr")
, [Registered](../../../../jdk.jfr/jdk/jfr/Registered.html "annotation in jdk.jfr")
, [Relational](../../../../jdk.jfr/jdk/jfr/Relational.html "annotation in jdk.jfr")
, [Repeatable](Repeatable.html "annotation in java.lang.annotation")
, [Retention](Retention.html "annotation in java.lang.annotation")
, [SafeVarargs](../SafeVarargs.html "annotation in java.lang")
, [Serial](../../io/Serial.html "annotation in java.io")
, [SettingDefinition](../../../../jdk.jfr/jdk/jfr/SettingDefinition.html "annotation in jdk.jfr")
, [StackTrace](../../../../jdk.jfr/jdk/jfr/StackTrace.html "annotation in jdk.jfr")
, [SupportedAnnotationTypes](../../../../java.compiler/javax/annotation/processing/SupportedAnnotationTypes.html "annotation in javax.annotation.processing")
, [SupportedOptions](../../../../java.compiler/javax/annotation/processing/SupportedOptions.html "annotation in javax.annotation.processing")
, [SupportedSourceVersion](../../../../java.compiler/javax/annotation/processing/SupportedSourceVersion.html "annotation in javax.annotation.processing")
, [SuppressWarnings](../SuppressWarnings.html "annotation in java.lang")
, [SwingContainer](../../../../java.desktop/javax/swing/SwingContainer.html "annotation in javax.swing")
, [Target](Target.html "annotation in java.lang.annotation")
, [Threshold](../../../../jdk.jfr/jdk/jfr/Threshold.html "annotation in jdk.jfr")
, [Timespan](../../../../jdk.jfr/jdk/jfr/Timespan.html "annotation in jdk.jfr")
, [Timestamp](../../../../jdk.jfr/jdk/jfr/Timestamp.html "annotation in jdk.jfr")
, [Transient](../../../../java.desktop/java/beans/Transient.html "annotation in java.beans")
, [TransitionFrom](../../../../jdk.jfr/jdk/jfr/TransitionFrom.html "annotation in jdk.jfr")
, [TransitionTo](../../../../jdk.jfr/jdk/jfr/TransitionTo.html "annotation in jdk.jfr")
, [Unsigned](../../../../jdk.jfr/jdk/jfr/Unsigned.html "annotation in jdk.jfr")
public interface Annotation
The common interface extended by all annotation types. Note that an interface that manually extends this one does not define an annotation type. Also note that this interface does not itself define an annotation type. More information about annotation types can be found in section 9.6 ofThe Java Language Specification. The AnnotatedElement interface discusses compatibility concerns when evolving an annotation type from being non-repeatable to being repeatable.
Since:
1.5
Method Summary
Modifier and Type | Method | Description |
---|---|---|
Class<? extends Annotation> | annotationType() | Returns the annotation type of this annotation. |
boolean | equals(Object obj) | Returns true if the specified object represents an annotation that is logically equivalent to this one. |
int | hashCode() | Returns the hash code of this annotation, as defined below: |
String | toString() | Returns a string representation of this annotation. |
Method Details
equals
boolean equals(Object obj)
Returns true if the specified object represents an annotation that is logically equivalent to this one. In other words, returns true if the specified object is an instance of the same annotation type as this instance, all of whose members are equal to the corresponding member of this annotation, as defined below:
* Two corresponding primitive typed members whose values arex
andy
are considered equal ifx == y
, unless their type isfloat
ordouble
.
* Two correspondingfloat
members whose values arex
andy
are considered equal ifFloat.valueOf(x).equals(Float.valueOf(y))
. (Unlike the==
operator, NaN is considered equal to itself, and0.0f
unequal to-0.0f
.)
* Two correspondingdouble
members whose values arex
andy
are considered equal ifDouble.valueOf(x).equals(Double.valueOf(y))
. (Unlike the==
operator, NaN is considered equal to itself, and0.0
unequal to-0.0
.)
* Two correspondingString
,Class
, enum, or annotation typed members whose values arex
andy
are considered equal ifx.equals(y)
. (Note that this definition is recursive for annotation typed members.)
* Two corresponding array typed membersx
andy
are considered equal ifArrays.equals(x, y)
, for the appropriate overloading of Arrays.equals(long[], long[]).
Overrides:
[equals](../Object.html#equals%28java.lang.Object%29)
in class[Object](../Object.html "class in java.lang")
Parameters:
obj
- the reference object with which to compare.
Returns:
true if the specified object represents an annotation that is logically equivalent to this one, otherwise false
See Also:
Object.hashCode(), HashMaphashCode
int hashCode()
Returns the hash code of this annotation, as defined below:
The hash code of an annotation is the sum of the hash codes of its members (including those with default values), as defined below: The hash code of an annotation member is (127 times the hash code of the member-name as computed by String.hashCode()) XOR the hash code of the member-value, as defined below:
The hash code of a member-value depends on its type:
* The hash code of a primitive valuev
is equal to_WrapperType_.valueOf(_v_).hashCode()
, where_WrapperType
_ is the wrapper type corresponding to the primitive type ofv
(Byte,Character, Double, Float, Integer,Long, Short, or Boolean).
* The hash code of a string, enum, class, or annotation member-value_v
_ is computed as by calling_v_.hashCode()
. (In the case of annotation member values, this is a recursive definition.)
* The hash code of an array member-value is computed by calling the appropriate overloading ofArrays.hashCode on the value. (There is one overloading for each primitive type, and one for object reference types.)
Overrides:
[hashCode](../Object.html#hashCode%28%29)
in class[Object](../Object.html "class in java.lang")
Returns:
the hash code of this annotation
See Also:
Object.equals(java.lang.Object), System.identityHashCode(java.lang.Object)toString
Returns a string representation of this annotation. The details of the representation are implementation-dependent, but the following may be regarded as typical:
@com.acme.util.Name(first=Alfred, middle=E., last=Neuman)Overrides:
[toString](../Object.html#toString%28%29)
in class[Object](../Object.html "class in java.lang")
Returns:
a string representation of this annotationannotationType
Returns the annotation type of this annotation.
Returns:
the annotation type of this annotation