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