Source Home >> Java Source 1.6.0 >> java.lang.annotation.Annotation V 0.09
  • 001/*
  • 002 * @(#)Annotation.java 1.10 05/11/17
  • 003 *
  • 004 * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
  • 005 * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  • 006 */
  • 007
  • 008package java.lang.annotation;
  • 009
  • 010/**
  • 011 * The common interface extended by all annotation types. Note that an
  • 012 * interface that manually extends this one does <i>not</i> define
  • 013 * an annotation type. Also note that this interface does not itself
  • 014 * define an annotation type.
  • 015 *
  • 016 * @author Josh Bloch
  • 017 * @since 1.5
  • 018 */
  • 019public interface Annotation {
  • 020 /**
  • 021 * Returns true if the specified object represents an annotation
  • 022 * that is logically equivalent to this one. In other words,
  • 023 * returns true if the specified object is an instance of the same
  • 024 * annotation type as this instance, all of whose members are equal
  • 025 * to the corresponding member of this annotation, as defined below:
  • 026 * <ul>
  • 027 * <li>Two corresponding primitive typed members whose values are
  • 028 * <tt>x</tt> and <tt>y</tt> are considered equal if <tt>x == y</tt>,
  • 029 * unless their type is <tt>float</tt> or <tt>double</tt>.
  • 030 *
  • 031 * <li>Two corresponding <tt>float</tt> members whose values
  • 032 * are <tt>x</tt> and <tt>y</tt> are considered equal if
  • 033 * <tt>Float.valueOf(x).equals(Float.valueOf(y))</tt>.
  • 034 * (Unlike the <tt>==</tt> operator, NaN is considered equal
  • 035 * to itself, and <tt>0.0f</tt> unequal to <tt>-0.0f</tt>.)
  • 036 *
  • 037 * <li>Two corresponding <tt>double</tt> members whose values
  • 038 * are <tt>x</tt> and <tt>y</tt> are considered equal if
  • 039 * <tt>Double.valueOf(x).equals(Double.valueOf(y))</tt>.
  • 040 * (Unlike the <tt>==</tt> operator, NaN is considered equal
  • 041 * to itself, and <tt>0.0</tt> unequal to <tt>-0.0</tt>.)
  • 042 *
  • 043 * <li>Two corresponding <tt>String</tt>, <tt>Class</tt>, enum, or
  • 044 * annotation typed members whose values are <tt>x</tt> and <tt>y</tt>
  • 045 * are considered equal if <tt>x.equals(y)</tt>. (Note that this
  • 046 * definition is recursive for annotation typed members.)
  • 047 *
  • 048 * <li>Two corresponding array typed members <tt>x</tt> and <tt>y</tt>
  • 049 * are considered equal if <tt>Arrays.equals(x, y)</tt>, for the
  • 050 * appropriate overloading of {@link java.util.Arrays#equals}.
  • 051 * </ul>
  • 052 *
  • 053 * @return true if the specified object represents an annotation
  • 054 * that is logically equivalent to this one, otherwise false
  • 055 */
  • 056 boolean equals(Object obj);
  • 057
  • 058 /**
  • 059 * Returns the hash code of this annotation, as defined below:
  • 060 *
  • 061 * <p>The hash code of an annotation is the sum of the hash codes
  • 062 * of its members (including those with default values), as defined
  • 063 * below:
  • 064 *
  • 065 * The hash code of an annotation member is (127 times the hash code
  • 066 * of the member-name as computed by {@link String#hashCode()}) XOR
  • 067 * the hash code of the member-value, as defined below:
  • 068 *
  • 069 * <p>The hash code of a member-value depends on its type:
  • 070 * <ul>
  • 071 * <li>The hash code of a primitive value <tt><i>v</i></tt> is equal to
  • 072 * <tt><i>WrapperType</i>.valueOf(<i>v</i>).hashCode()</tt>, where
  • 073 * <tt><i>WrapperType</i></tt> is the wrapper type corresponding
  • 074 * to the primitive type of <tt><i>v</i></tt> ({@link Byte},
  • 075 * {@link Character}, {@link Double}, {@link Float}, {@link Integer},
  • 076 * {@link Long}, {@link Short}, or {@link Boolean}).
  • 077 *
  • 078 * <li>The hash code of a string, enum, class, or annotation member-value
  • 079 I <tt><i>v</i></tt> is computed as by calling
  • 080 * <tt><i>v</i>.hashCode()</tt>. (In the case of annotation
  • 081 * member values, this is a recursive definition.)
  • 082 *
  • 083 * <li>The hash code of an array member-value is computed by calling
  • 084 * the appropriate overloading of
  • 085 * {@link java.util.Arrays#hashCode(long[]) Arrays.hashCode}
  • 086 * on the value. (There is one overloading for each primitive
  • 087 * type, and one for object reference types.)
  • 088 * </ul>
  • 089 *
  • 090 * @return the hash code of this annotation
  • 091 */
  • 092 int hashCode();
  • 093
  • 094 /**
  • 095 * Returns a string representation of this annotation. The details
  • 096 * of the representation are implementation-dependent, but the following
  • 097 * may be regarded as typical:
  • 098 * <pre>
  • 099 * @com.acme.util.Name(first=Alfred, middle=E., last=Neuman)
  • 100 * </pre>
  • 101 *
  • 102 * @return a string representation of this annotation
  • 103 */
  • 104 String toString();
  • 105
  • 106 /**
  • 107 * Returns the annotation type of this annotation.
  • 108 */
  • 109 Class<? extends Annotation> annotationType();
  • 110}

文件:Annotation.java
包名:java.lang.annotation
类名:Annotation
继承:
接口: