KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > java > lang > annotation > Annotation


1 /*
2  * @(#)Annotation.java 1.9 04/06/18
3  *
4  * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
5  * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
6  */

7
8 package java.lang.annotation;
9
10 /**
11  * The common interface extended by all annotation types. Note that an
12  * interface that manually extends this one does <i>not</i> define
13  * an annotation type. Also note that this interface does not itself
14  * define an annotation type.
15  *
16  * @author Josh Bloch
17  * @since 1.5
18  */

19 public interface Annotation {
20     /**
21      * Returns true if the specified object represents an annotation
22      * that is logically equivalent to this one. In other words,
23      * returns true if the specified object is an instance of the same
24      * annotation type as this instance, all of whose members are equal
25      * to the corresponding member of this annotation, as defined below:
26      * <ul>
27      * <li>Two corresponding primitive typed members whose values are
28      * <tt>x</tt> and <tt>y</tt> are considered equal if <tt>x == y</tt>,
29      * unless their type is <tt>float</tt> or <tt>double</tt>.
30      *
31      * <li>Two corresponding <tt>float</tt> members whose values
32      * are <tt>x</tt> and <tt>y</tt> are considered equal if
33      * <tt>Float.valueOf(x).equals(Float.valueOf(y))</tt>.
34      * (Unlike the <tt>==</tt> operator, NaN is considered equal
35      * to itself, and <tt>0.0f</tt> unequal to <tt>-0.0f</tt>.)
36      *
37      * <li>Two corresponding <tt>double</tt> members whose values
38      * are <tt>x</tt> and <tt>y</tt> are considered equal if
39      * <tt>Double.valueOf(x).equals(Double.valueOf(y))</tt>.
40      * (Unlike the <tt>==</tt> operator, NaN is considered equal
41      * to itself, and <tt>0.0</tt> unequal to <tt>-0.0</tt>.)
42      *
43      * <li>Two corresponding <tt>String</tt>, <tt>Class</tt>, enum, or
44      * annotation typed members whose values are <tt>x</tt> and <tt>y</tt>
45      * are considered equal if <tt>x.equals(y)</tt>. (Note that this
46      * definition is recursive for annotation typed members.)
47      *
48      * <li>Two corresponding array typed members <tt>x</tt> and <tt>y</tt>
49      * are considered equal if <tt>Arrays.equals(x, y)</tt>, for the
50      * appropriate overloading of {@link java.util.Arrays#equals}.
51      * </ul>
52      *
53      * @return true if the specified object represents an annotation
54      * that is logically equivalent to this one, otherwise false
55      */

56     boolean equals(Object JavaDoc obj);
57
58     /**
59      * Returns the hash code of this annotation, as defined below:
60      *
61      * <p>The hash code of an annotation is the sum of the hash codes
62      * of its members (including those with default values), as defined
63      * below:
64      *
65      * The hash code of an annotation member is (127 times the hash code
66      * of the member-name as computed by {@link String#hashCode()}) XOR
67      * the hash code of the member-value, as defined below:
68      *
69      * <p>The hash code of a member-value depends on its type:
70      * <ul>
71      * <li>The hash code of a primitive value <tt><i>v</i></tt> is equal to
72      * <tt><i>WrapperType</i>.valueOf(<i>v</i>).hashCode()</tt>, where
73      * <tt><i>WrapperType</i></tt> is the wrapper type corresponding
74      * to the primitive type of <tt><i>v</i></tt> ({@link Byte},
75      * {@link Character}, {@link Double}, {@link Float}, {@link Integer},
76      * {@link Long}, {@link Short}, or {@link Boolean}).
77      *
78      * <li>The hash code of a string, enum, class, or annotation member-value
79      I <tt><i>v</i></tt> is computed as by calling
80      * <tt><i>v</i>.hashCode()</tt>. (In the case of annotation
81      * member values, this is a recursive definition.)
82      *
83      * <li>The hash code of an array member-value is computed by calling
84      * the appropriate overloading of
85      * {@link java.util.Arrays#hashCode(long[]) Arrays.hashCode}
86      * on the value. (There is one overloading for each primitive
87      * type, and one for object reference types.)
88      * </ul>
89      *
90      * @return the hash code of this annotation
91      */

92     int hashCode();
93
94     /**
95      * Returns a string representation of this annotation. The details
96      * of the representation are implementation-dependent, but the following
97      * may be regarded as typical:
98      * <pre>
99      * &#064;com.acme.util.Name(first=Alfred, middle=E., last=Neuman)
100      * </pre>
101      *
102      * @return a string representation of this annotation
103      */

104     String JavaDoc toString();
105
106     /**
107      * Returns the annotation type of this annotation.
108      */

109     Class JavaDoc<? extends Annotation JavaDoc> annotationType();
110 }
111
Popular Tags