rt/emul/mini/src/main/java/java/lang/annotation/Annotation.java
changeset 772 d382dacfd73f
parent 554 05224402145d
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/rt/emul/mini/src/main/java/java/lang/annotation/Annotation.java	Tue Feb 26 16:54:16 2013 +0100
     1.3 @@ -0,0 +1,131 @@
     1.4 +/*
     1.5 + * Copyright (c) 2003, 2009, Oracle and/or its affiliates. All rights reserved.
     1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.7 + *
     1.8 + * This code is free software; you can redistribute it and/or modify it
     1.9 + * under the terms of the GNU General Public License version 2 only, as
    1.10 + * published by the Free Software Foundation.  Oracle designates this
    1.11 + * particular file as subject to the "Classpath" exception as provided
    1.12 + * by Oracle in the LICENSE file that accompanied this code.
    1.13 + *
    1.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
    1.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    1.16 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    1.17 + * version 2 for more details (a copy is included in the LICENSE file that
    1.18 + * accompanied this code).
    1.19 + *
    1.20 + * You should have received a copy of the GNU General Public License version
    1.21 + * 2 along with this work; if not, write to the Free Software Foundation,
    1.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    1.23 + *
    1.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    1.25 + * or visit www.oracle.com if you need additional information or have any
    1.26 + * questions.
    1.27 + */
    1.28 +
    1.29 +package java.lang.annotation;
    1.30 +
    1.31 +/**
    1.32 + * The common interface extended by all annotation types.  Note that an
    1.33 + * interface that manually extends this one does <i>not</i> define
    1.34 + * an annotation type.  Also note that this interface does not itself
    1.35 + * define an annotation type.
    1.36 + *
    1.37 + * More information about annotation types can be found in section 9.6 of
    1.38 + * <cite>The Java&trade; Language Specification</cite>.
    1.39 + *
    1.40 + * @author  Josh Bloch
    1.41 + * @since   1.5
    1.42 + */
    1.43 +public interface Annotation {
    1.44 +    /**
    1.45 +     * Returns true if the specified object represents an annotation
    1.46 +     * that is logically equivalent to this one.  In other words,
    1.47 +     * returns true if the specified object is an instance of the same
    1.48 +     * annotation type as this instance, all of whose members are equal
    1.49 +     * to the corresponding member of this annotation, as defined below:
    1.50 +     * <ul>
    1.51 +     *    <li>Two corresponding primitive typed members whose values are
    1.52 +     *    <tt>x</tt> and <tt>y</tt> are considered equal if <tt>x == y</tt>,
    1.53 +     *    unless their type is <tt>float</tt> or <tt>double</tt>.
    1.54 +     *
    1.55 +     *    <li>Two corresponding <tt>float</tt> members whose values
    1.56 +     *    are <tt>x</tt> and <tt>y</tt> are considered equal if
    1.57 +     *    <tt>Float.valueOf(x).equals(Float.valueOf(y))</tt>.
    1.58 +     *    (Unlike the <tt>==</tt> operator, NaN is considered equal
    1.59 +     *    to itself, and <tt>0.0f</tt> unequal to <tt>-0.0f</tt>.)
    1.60 +     *
    1.61 +     *    <li>Two corresponding <tt>double</tt> members whose values
    1.62 +     *    are <tt>x</tt> and <tt>y</tt> are considered equal if
    1.63 +     *    <tt>Double.valueOf(x).equals(Double.valueOf(y))</tt>.
    1.64 +     *    (Unlike the <tt>==</tt> operator, NaN is considered equal
    1.65 +     *    to itself, and <tt>0.0</tt> unequal to <tt>-0.0</tt>.)
    1.66 +     *
    1.67 +     *    <li>Two corresponding <tt>String</tt>, <tt>Class</tt>, enum, or
    1.68 +     *    annotation typed members whose values are <tt>x</tt> and <tt>y</tt>
    1.69 +     *    are considered equal if <tt>x.equals(y)</tt>.  (Note that this
    1.70 +     *    definition is recursive for annotation typed members.)
    1.71 +     *
    1.72 +     *    <li>Two corresponding array typed members <tt>x</tt> and <tt>y</tt>
    1.73 +     *    are considered equal if <tt>Arrays.equals(x, y)</tt>, for the
    1.74 +     *    appropriate overloading of {@link java.util.Arrays#equals}.
    1.75 +     * </ul>
    1.76 +     *
    1.77 +     * @return true if the specified object represents an annotation
    1.78 +     *     that is logically equivalent to this one, otherwise false
    1.79 +     */
    1.80 +    boolean equals(Object obj);
    1.81 +
    1.82 +    /**
    1.83 +     * Returns the hash code of this annotation, as defined below:
    1.84 +     *
    1.85 +     * <p>The hash code of an annotation is the sum of the hash codes
    1.86 +     * of its members (including those with default values), as defined
    1.87 +     * below:
    1.88 +     *
    1.89 +     * The hash code of an annotation member is (127 times the hash code
    1.90 +     * of the member-name as computed by {@link String#hashCode()}) XOR
    1.91 +     * the hash code of the member-value, as defined below:
    1.92 +     *
    1.93 +     * <p>The hash code of a member-value depends on its type:
    1.94 +     * <ul>
    1.95 +     * <li>The hash code of a primitive value <tt><i>v</i></tt> is equal to
    1.96 +     *     <tt><i>WrapperType</i>.valueOf(<i>v</i>).hashCode()</tt>, where
    1.97 +     *     <tt><i>WrapperType</i></tt> is the wrapper type corresponding
    1.98 +     *     to the primitive type of <tt><i>v</i></tt> ({@link Byte},
    1.99 +     *     {@link Character}, {@link Double}, {@link Float}, {@link Integer},
   1.100 +     *     {@link Long}, {@link Short}, or {@link Boolean}).
   1.101 +     *
   1.102 +     * <li>The hash code of a string, enum, class, or annotation member-value
   1.103 +     I     <tt><i>v</i></tt> is computed as by calling
   1.104 +     *     <tt><i>v</i>.hashCode()</tt>.  (In the case of annotation
   1.105 +     *     member values, this is a recursive definition.)
   1.106 +     *
   1.107 +     * <li>The hash code of an array member-value is computed by calling
   1.108 +     *     the appropriate overloading of
   1.109 +     *     {@link java.util.Arrays#hashCode(long[]) Arrays.hashCode}
   1.110 +     *     on the value.  (There is one overloading for each primitive
   1.111 +     *     type, and one for object reference types.)
   1.112 +     * </ul>
   1.113 +     *
   1.114 +     * @return the hash code of this annotation
   1.115 +     */
   1.116 +    int hashCode();
   1.117 +
   1.118 +    /**
   1.119 +     * Returns a string representation of this annotation.  The details
   1.120 +     * of the representation are implementation-dependent, but the following
   1.121 +     * may be regarded as typical:
   1.122 +     * <pre>
   1.123 +     *   &#064;com.acme.util.Name(first=Alfred, middle=E., last=Neuman)
   1.124 +     * </pre>
   1.125 +     *
   1.126 +     * @return a string representation of this annotation
   1.127 +     */
   1.128 +    String toString();
   1.129 +
   1.130 +    /**
   1.131 +     * Returns the annotation type of this annotation.
   1.132 +     */
   1.133 +    Class<? extends Annotation> annotationType();
   1.134 +}