Most visited

Recently visited

Added in API level 1

Annotation

public interface Annotation

java.lang.annotation.Annotation
Known Indirect Subclasses


所有注释类型扩展的通用接口。 请注意,手动扩展此接口的接口定义注释类型。 另请注意,此接口本身并未定义注释类型。 关于注释类型的更多信息可以在The Java™ Language Specification的 9.6节中找到

Summary

Public methods

abstract Class<? extends Annotation> annotationType()

返回此注释的注释类型。

abstract boolean equals(Object obj)

如果指定的对象表示与此逻辑等效的注释,则返回true。

abstract int hashCode()

返回此注释的哈希码,如下定义:

注释的哈希码是其成员(包括具有默认值的那些哈希码)的哈希码的总和,如下所定义:注释成员的哈希码是(由计算出的成员名的哈希码的127倍) hashCode() )XOR成员值的哈希码,如下所定义:

成员值的哈希码取决于其类型:

abstract String toString()

返回此批注的字符串表示形式。

Public methods

annotationType

Added in API level 1
Class<? extends Annotation> annotationType ()

返回此注释的注释类型。

Returns
Class<? extends Annotation>

equals

Added in API level 1
boolean equals (Object obj)

如果指定的对象表示与此逻辑等效的注释,则返回true。 换句话说,如果指定的对象是与此实例相同的注释类型的实例,则返回true,其所有成员均等于此注释的相应成员,如下所示:

  • Two corresponding primitive typed members whose values are x and y are considered equal if x == y, unless their type is float or double.
  • Two corresponding float members whose values are x and y are considered equal if Float.valueOf(x).equals(Float.valueOf(y)). (Unlike the == operator, NaN is considered equal to itself, and 0.0f unequal to -0.0f.)
  • Two corresponding double members whose values are x and y are considered equal if Double.valueOf(x).equals(Double.valueOf(y)). (Unlike the == operator, NaN is considered equal to itself, and 0.0 unequal to -0.0.)
  • Two corresponding String, Class, enum, or annotation typed members whose values are x and y are considered equal if x.equals(y). (Note that this definition is recursive for annotation typed members.)
  • Two corresponding array typed members x and y are considered equal if Arrays.equals(x, y), for the appropriate overloading of equals(boolean[], boolean[]).

Parameters
obj Object: the reference object with which to compare.
Returns
boolean true if the specified object represents an annotation that is logically equivalent to this one, otherwise false

hashCode

Added in API level 1
int hashCode ()

返回此注释的哈希码,如下定义:

注释的哈希码是其成员(包括具有默认值的那些哈希码)的哈希码的总和,如下所定义:注释成员的哈希码是(由计算出的成员名的哈希码的127倍) hashCode() )XOR成员值的哈希码,如下所定义:

成员值的哈希码取决于其类型:

  • The hash code of a primitive value v is equal to WrapperType.valueOf(v).hashCode(), where WrapperType is the wrapper type corresponding to the primitive type of v (Byte, Character, Double, Float, Integer, Long, Short, or Boolean).
  • The hash code of a string, enum, class, or annotation member-value I v is computed as by calling v.hashCode(). (In the case of annotation member values, this is a recursive definition.)
  • The hash code of an array member-value is computed by calling the appropriate overloading of Arrays.hashCode on the value. (There is one overloading for each primitive type, and one for object reference types.)

Returns
int the hash code of this annotation

toString

Added in API level 1
String toString ()

返回此批注的字符串表示形式。 表示的细节取决于实现,但以下内容可能被认为是典型的:

   @com.acme.util.Name(first=Alfred, middle=E., last=Neuman)
 

Returns
String a string representation of this annotation

Hooray!