author | chegar |
Sun, 17 Aug 2014 15:54:13 +0100 | |
changeset 25859 | 3317bb8137f4 |
parent 22080 | jdk/src/share/classes/java/lang/annotation/Annotation.java@18a23ba7dd38 |
child 32033 | bf24e33c7919 |
permissions | -rw-r--r-- |
2 | 1 |
/* |
18546
862067c6481c
8017550: Fix doclint issues in java.lang and subpackages
darcy
parents:
14342
diff
changeset
|
2 |
* Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. |
2 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
5506 | 7 |
* published by the Free Software Foundation. Oracle designates this |
2 | 8 |
* particular file as subject to the "Classpath" exception as provided |
5506 | 9 |
* by Oracle in the LICENSE file that accompanied this code. |
2 | 10 |
* |
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
15 |
* accompanied this code). |
|
16 |
* |
|
17 |
* You should have received a copy of the GNU General Public License version |
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
20 |
* |
|
5506 | 21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
22 |
* or visit www.oracle.com if you need additional information or have any |
|
23 |
* questions. |
|
2 | 24 |
*/ |
25 |
||
26 |
package java.lang.annotation; |
|
27 |
||
28 |
/** |
|
29 |
* The common interface extended by all annotation types. Note that an |
|
30 |
* interface that manually extends this one does <i>not</i> define |
|
31 |
* an annotation type. Also note that this interface does not itself |
|
32 |
* define an annotation type. |
|
33 |
* |
|
9266
121fb370f179
7032960: API files in java.awt need to be updated for references to JVM Spec with editions/hyperlinks
jjh
parents:
5506
diff
changeset
|
34 |
* More information about annotation types can be found in section 9.6 of |
121fb370f179
7032960: API files in java.awt need to be updated for references to JVM Spec with editions/hyperlinks
jjh
parents:
5506
diff
changeset
|
35 |
* <cite>The Java™ Language Specification</cite>. |
1938 | 36 |
* |
22080
18a23ba7dd38
8023471: Add compatibility note to AnnotatedElement
darcy
parents:
18546
diff
changeset
|
37 |
* The {@link java.lang.reflect.AnnotatedElement} interface discusses |
18a23ba7dd38
8023471: Add compatibility note to AnnotatedElement
darcy
parents:
18546
diff
changeset
|
38 |
* compatibility concerns when evolving an annotation type from being |
18a23ba7dd38
8023471: Add compatibility note to AnnotatedElement
darcy
parents:
18546
diff
changeset
|
39 |
* non-repeatable to being repeatable. |
18a23ba7dd38
8023471: Add compatibility note to AnnotatedElement
darcy
parents:
18546
diff
changeset
|
40 |
* |
2 | 41 |
* @author Josh Bloch |
42 |
* @since 1.5 |
|
43 |
*/ |
|
44 |
public interface Annotation { |
|
45 |
/** |
|
46 |
* Returns true if the specified object represents an annotation |
|
47 |
* that is logically equivalent to this one. In other words, |
|
48 |
* returns true if the specified object is an instance of the same |
|
49 |
* annotation type as this instance, all of whose members are equal |
|
50 |
* to the corresponding member of this annotation, as defined below: |
|
51 |
* <ul> |
|
52 |
* <li>Two corresponding primitive typed members whose values are |
|
53 |
* <tt>x</tt> and <tt>y</tt> are considered equal if <tt>x == y</tt>, |
|
54 |
* unless their type is <tt>float</tt> or <tt>double</tt>. |
|
55 |
* |
|
56 |
* <li>Two corresponding <tt>float</tt> members whose values |
|
57 |
* are <tt>x</tt> and <tt>y</tt> are considered equal if |
|
58 |
* <tt>Float.valueOf(x).equals(Float.valueOf(y))</tt>. |
|
59 |
* (Unlike the <tt>==</tt> operator, NaN is considered equal |
|
60 |
* to itself, and <tt>0.0f</tt> unequal to <tt>-0.0f</tt>.) |
|
61 |
* |
|
62 |
* <li>Two corresponding <tt>double</tt> members whose values |
|
63 |
* are <tt>x</tt> and <tt>y</tt> are considered equal if |
|
64 |
* <tt>Double.valueOf(x).equals(Double.valueOf(y))</tt>. |
|
65 |
* (Unlike the <tt>==</tt> operator, NaN is considered equal |
|
66 |
* to itself, and <tt>0.0</tt> unequal to <tt>-0.0</tt>.) |
|
67 |
* |
|
68 |
* <li>Two corresponding <tt>String</tt>, <tt>Class</tt>, enum, or |
|
69 |
* annotation typed members whose values are <tt>x</tt> and <tt>y</tt> |
|
70 |
* are considered equal if <tt>x.equals(y)</tt>. (Note that this |
|
71 |
* definition is recursive for annotation typed members.) |
|
72 |
* |
|
73 |
* <li>Two corresponding array typed members <tt>x</tt> and <tt>y</tt> |
|
74 |
* are considered equal if <tt>Arrays.equals(x, y)</tt>, for the |
|
75 |
* appropriate overloading of {@link java.util.Arrays#equals}. |
|
76 |
* </ul> |
|
77 |
* |
|
78 |
* @return true if the specified object represents an annotation |
|
79 |
* that is logically equivalent to this one, otherwise false |
|
80 |
*/ |
|
81 |
boolean equals(Object obj); |
|
82 |
||
83 |
/** |
|
84 |
* Returns the hash code of this annotation, as defined below: |
|
85 |
* |
|
86 |
* <p>The hash code of an annotation is the sum of the hash codes |
|
87 |
* of its members (including those with default values), as defined |
|
88 |
* below: |
|
89 |
* |
|
90 |
* The hash code of an annotation member is (127 times the hash code |
|
91 |
* of the member-name as computed by {@link String#hashCode()}) XOR |
|
92 |
* the hash code of the member-value, as defined below: |
|
93 |
* |
|
94 |
* <p>The hash code of a member-value depends on its type: |
|
95 |
* <ul> |
|
96 |
* <li>The hash code of a primitive value <tt><i>v</i></tt> is equal to |
|
97 |
* <tt><i>WrapperType</i>.valueOf(<i>v</i>).hashCode()</tt>, where |
|
98 |
* <tt><i>WrapperType</i></tt> is the wrapper type corresponding |
|
99 |
* to the primitive type of <tt><i>v</i></tt> ({@link Byte}, |
|
100 |
* {@link Character}, {@link Double}, {@link Float}, {@link Integer}, |
|
101 |
* {@link Long}, {@link Short}, or {@link Boolean}). |
|
102 |
* |
|
103 |
* <li>The hash code of a string, enum, class, or annotation member-value |
|
104 |
I <tt><i>v</i></tt> is computed as by calling |
|
105 |
* <tt><i>v</i>.hashCode()</tt>. (In the case of annotation |
|
106 |
* member values, this is a recursive definition.) |
|
107 |
* |
|
108 |
* <li>The hash code of an array member-value is computed by calling |
|
109 |
* the appropriate overloading of |
|
110 |
* {@link java.util.Arrays#hashCode(long[]) Arrays.hashCode} |
|
111 |
* on the value. (There is one overloading for each primitive |
|
112 |
* type, and one for object reference types.) |
|
113 |
* </ul> |
|
114 |
* |
|
115 |
* @return the hash code of this annotation |
|
116 |
*/ |
|
117 |
int hashCode(); |
|
118 |
||
119 |
/** |
|
120 |
* Returns a string representation of this annotation. The details |
|
121 |
* of the representation are implementation-dependent, but the following |
|
122 |
* may be regarded as typical: |
|
123 |
* <pre> |
|
124 |
* @com.acme.util.Name(first=Alfred, middle=E., last=Neuman) |
|
125 |
* </pre> |
|
126 |
* |
|
127 |
* @return a string representation of this annotation |
|
128 |
*/ |
|
129 |
String toString(); |
|
130 |
||
131 |
/** |
|
132 |
* Returns the annotation type of this annotation. |
|
18546
862067c6481c
8017550: Fix doclint issues in java.lang and subpackages
darcy
parents:
14342
diff
changeset
|
133 |
* @return the annotation type of this annotation |
2 | 134 |
*/ |
135 |
Class<? extends Annotation> annotationType(); |
|
136 |
} |