java new的本质_沉淀再出发:java中注解的本质和使用

1 /*

2 * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.3 * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.4 *5 *6 *7 *8 *9 *10 *11 *12 *13 *14 *15 *16 *17 *18 *19 *20 *21 *22 *23 *24 */

25

26 packagejava.lang.annotation;27

28 /**

29 * The common interface extended by all annotation types. Note that an30 * interface that manually extends this one does not define31 * an annotation type. Also note that this interface does not itself32 * define an annotation type.33 *34 * More information about annotation types can be found in section 9.6 of35 * The Java™ Language Specification.36 *37 * The {@linkjava.lang.reflect.AnnotatedElement} interface discusses38 * compatibility concerns when evolving an annotation type from being39 * non-repeatable to being repeatable.40 *41 *@authorJosh Bloch42 *@since1.543 */

44 public interfaceAnnotation {45 /**

46 * Returns true if the specified object represents an annotation47 * that is logically equivalent to this one. In other words,48 * returns true if the specified object is an instance of the same49 * annotation type as this instance, all of whose members are equal50 * to the corresponding member of this annotation, as defined below:51 *

  • 52 *
  • Two corresponding primitive typed members whose values are53 * x and y are considered equal if x == y,54 * unless their type is float or double.55 *56 *
  • Two corresponding float members whose values57 * are x and y are considered equal if58 * Float.valueOf(x).equals(Float.valueOf(y)).59 * (Unlike the == operator, NaN is considered equal60 * to itself, and 0.0f unequal to -0.0f.)61 *62 *
  • Two corresponding double members whose values63 * are x and y are considered equal if64 * Double.valueOf(x).equals(Double.valueOf(y)).65 * (Unlike the == operator, NaN is considered equal66 * to itself, and 0.0 unequal to -0.0.)67 *68 *
  • Two corresponding String, Class, enum, or69 * annotation typed members whose values are x and y70 * are considered equal if x.equals(y). (Note that this71 * definition is recursive for annotation typed members.)72 *73 *
  • Two corresponding array typed members x and y74 * are considered equal if Arrays.equals(x, y), for the75 * appropriate overloading of {@linkjava.util.Arrays#equals}.76 *
77 *78 *@returntrue if the specified object represents an annotation79 * that is logically equivalent to this one, otherwise false80 */

81 booleanequals(Object obj);82

83 /**

84 * Returns the hash code of this annotation, as defined below:85 *86 *

The hash code of an annotation is the sum of the hash codes87 * of its members (including those with default values), as defined88 * below:89 *90 * The hash code of an annotation member is (127 times the hash code91 * of the member-name as computed by {@linkString#hashCode()}) XOR92 * the hash code of the member-value, as defined below:93 *94 *

The hash code of a member-value depends on its type:95 *

  • 96 *
  • The hash code of a primitive value v is equal to97 * WrapperType.valueOf(v).hashCode(), where98 * WrapperType is the wrapper type corresponding99 * to the primitive type of v ({@linkByte},100 * {@linkCharacter}, {@linkDouble}, {@linkFloat}, {@linkInteger},101 * {@linkLong}, {@linkShort}, or {@linkBoolean}).102 *103 *
  • The hash code of a string, enum, class, or annotation member-value104 I v is computed as by calling105 * v.hashCode(). (In the case of annotation106 * member values, this is a recursive definition.)107 *108 *
  • The hash code of an array member-value is computed by calling109 * the appropriate overloading of110 * {@linkjava.util.Arrays#hashCode(long[]) Arrays.hashCode}111 * on the value. (There is one overloading for each primitive112 * type, and one for object reference types.)113 *
114 *115 *@returnthe hash code of this annotation116 */

117 inthashCode();118

119 /**

120 * Returns a string representation of this annotation. The details121 * of the representation are implementation-dependent, but the following122 * may be regarded as typical:123 *

124 *   @com.acme.util.Name(first=Alfred, middle=E., last=Neuman)125 * 
126 *127 *@returna string representation of this annotation128 */

129 String toString();130

131 /**

132 * Returns the annotation type of this annotation.133 *@returnthe annotation type of this annotation134 */

135 Class extends Annotation>annotationType();136 }

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值