java.lang.annotation.Annotation.equals()方法的使用及代码示例

x33g5p2x  于2022-01-15 转载在 其他  
字(6.2k)|赞(0)|评价(0)|浏览(222)

本文整理了Java中java.lang.annotation.Annotation.equals()方法的一些代码示例,展示了Annotation.equals()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Annotation.equals()方法的具体详情如下:
包路径:java.lang.annotation.Annotation
类名称:Annotation
方法名:equals

Annotation.equals介绍

[英]Determines whether or not this annotation is equivalent to the annotation passed. This is determined according to the following rules:

  • Two annotations x and y are equal if and only if they are members of the same annotation type and all the member values of x are equal to the corresponding member values of y.
  • The equality of primitive member values x and yis determined (in a way similar to) using the corresponding wrapper classes. For example, Integer.valueOf(x).equals(Integer.valueOf(y) is used for int values. Note: The behavior is identical to the == operator for all but the floating point type, so the implementation may as well use == in these cases for performance reasons. Only for the float and doubletypes the result will be slightly different: NaN is equal to NaN, and -0.0 is equal to 0.0, both of which is normally not the case.
  • The equality of two array member values x and yis determined using the corresponding equals(x, y)helper function in java.util.Arrays.
  • The hash code for all other member values is determined by simply calling their equals() method.
    [中]确定此批注是否等效于传递的批注。这是根据以下规则确定的:
    *两个注释x和y相等,当且仅当它们是相同注释类型的成员且x的所有成员值都等于y的相应成员值时。
    *原始成员值x和yis的相等性是使用相应的包装器类确定的(以类似的方式)。例如,整数。(x)的值。等于(整数)。valueOf(y)用于int值。注意:除了浮点类型外,所有类型的行为都与==运算符相同,因此出于性能原因,在这些情况下,实现也可以使用==运算符。仅对于float和doubleType,结果略有不同:NaN等于NaN,-0.0等于0.0,这两种情况通常都不是这样。
    *两个数组成员值x和yis的相等性是使用java中相应的equals(x,y)helper函数确定的。util。数组。
    *所有其他成员值的哈希代码只需调用其equals()方法即可确定。

代码示例

代码示例来源:origin: spring-projects/spring-framework

@Override
public boolean equals(Object other) {
  if (this == other) {
    return true;
  }
  AnnotationConverterKey otherKey = (AnnotationConverterKey) other;
  return (this.fieldType == otherKey.fieldType && this.annotation.equals(otherKey.annotation));
}

代码示例来源:origin: redisson/redisson

/**
 * {@inheritDoc}
 */
public boolean represents(Object value) {
  return annotation.equals(value);
}

代码示例来源:origin: org.springframework/spring-context

@Override
public boolean equals(Object other) {
  if (this == other) {
    return true;
  }
  AnnotationConverterKey otherKey = (AnnotationConverterKey) other;
  return (this.fieldType == otherKey.fieldType && this.annotation.equals(otherKey.annotation));
}

代码示例来源:origin: com.google.inject/guice

@Override
public boolean equals(Object o) {
 if (!(o instanceof AnnotationInstanceStrategy)) {
  return false;
 }
 AnnotationInstanceStrategy other = (AnnotationInstanceStrategy) o;
 return annotation.equals(other.annotation);
}

代码示例来源:origin: spring-projects/spring-framework

private boolean annotationEquals(Annotation ann, Annotation otherAnn) {
  // Annotation.equals is reflective and pretty slow, so let's check identity and proxy type first.
  return (ann == otherAnn || (ann.getClass() == otherAnn.getClass() && ann.equals(otherAnn)));
}

代码示例来源:origin: com.google.inject/guice

@Override
public boolean equals(Object other) {
 return other instanceof AnnotatedWith
   && ((AnnotatedWith) other).annotation.equals(annotation);
}

代码示例来源:origin: prestodb/presto

protected final boolean _add(Annotation ann) {
    if (_annotations == null) {
      _annotations = new HashMap<Class<?>,Annotation>();
    }
    Annotation previous = _annotations.put(ann.annotationType(), ann);
    return (previous == null) || !previous.equals(ann);
  }
}

代码示例来源:origin: redisson/redisson

protected final boolean _add(Annotation ann) {
    if (_annotations == null) {
      _annotations = new HashMap<Class<?>,Annotation>();
    }
    Annotation previous = _annotations.put(ann.annotationType(), ann);
    return (previous == null) || !previous.equals(ann);
  }
}

代码示例来源:origin: org.springframework/spring-core

private boolean annotationEquals(Annotation ann, Annotation otherAnn) {
  // Annotation.equals is reflective and pretty slow, so let's check identity and proxy type first.
  return (ann == otherAnn || (ann.getClass() == otherAnn.getClass() && ann.equals(otherAnn)));
}

代码示例来源:origin: jersey/jersey

@Override
public boolean equals(Object o) {
  if (this == o) {
    return true;
  }
  if (o == null || getClass() != o.getClass()) {
    return false;
  }
  BindingModel that = (BindingModel) o;
  return annotation != null ? annotation.equals(that.annotation) : that.annotation == null;
}

代码示例来源:origin: jersey/jersey

@Override
public boolean equals(Object o) {
  if (this == o) {
    return true;
  }
  if (o == null || getClass() != o.getClass()) {
    return false;
  }
  BindingModel that = (BindingModel) o;
  return annotation != null ? annotation.equals(that.annotation) : that.annotation == null;
}

代码示例来源:origin: com.google.inject/guice

@Override
public boolean matches(AnnotatedElement element) {
 Annotation fromElement = element.getAnnotation(annotation.annotationType());
 return fromElement != null && annotation.equals(fromElement);
}

代码示例来源:origin: com.google.inject/guice

@Override
public boolean equals(Object obj) {
 if (obj instanceof ProviderMethod) {
  ProviderMethod<?> o = (ProviderMethod<?>) obj;
  return method.equals(o.method)
    && instance.equals(o.instance)
    && annotation.equals(o.annotation);
 } else {
  return false;
 }
}

代码示例来源:origin: apache/drill

protected final boolean _add(Annotation ann) {
    if (_annotations == null) {
      _annotations = new HashMap<Class<?>,Annotation>();
    }
    Annotation previous = _annotations.put(ann.annotationType(), ann);
    return (previous == null) || !previous.equals(ann);
  }
}

代码示例来源:origin: jersey/jersey

return false;
if (sourceAnnotation != null ? !sourceAnnotation.equals(parameter.sourceAnnotation) : parameter.sourceAnnotation
    != null) {
  return false;

代码示例来源:origin: jersey/jersey

return false;
if (sourceAnnotation != null ? !sourceAnnotation.equals(parameter.sourceAnnotation) : parameter.sourceAnnotation
    != null) {
  return false;

代码示例来源:origin: redisson/redisson

@Override
public boolean equals(Object other) {
  if (this == other) {
    return true;
  } else if (!(other instanceof AnnotationValue.Loaded<?>)) {
    return false;
  }
  AnnotationValue.Loaded<?> annotationValue = (AnnotationValue.Loaded<?>) other;
  return annotationValue.getState().isResolved() && annotation.equals(annotationValue.resolve());
}

代码示例来源:origin: spring-projects/spring-framework

if (targetAnnotation != null && targetAnnotation.equals(annotation)) {
  return true;

代码示例来源:origin: org.springframework/spring-beans

if (targetAnnotation != null && targetAnnotation.equals(annotation)) {
  return true;

代码示例来源:origin: org.elasticsearch/elasticsearch

@Override
public boolean equals(Object o) {
  if (!(o instanceof AnnotationInstanceStrategy)) {
    return false;
  }
  AnnotationInstanceStrategy other = (AnnotationInstanceStrategy) o;
  return annotation.equals(other.annotation);
}

相关文章