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

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

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

Annotation.hashCode介绍

[英]Returns the hash code of this annotation. The hash code is determined according to the following rules:

  • The hash code of an annotation is the sum of the hash codes of its annotation members.
  • The hash code of an annotation member is calculated as (0x7f * n.hashCode()) ^ v.hashCode()), where n is the name of the member (as a String) and v its value.
  • The hash code for a primitive member value is determined using the corresponding wrapper type. For example, Integer.valueOf(v).hashCode() is used for an int value v.
  • The hash code for an array member value v is determined using the corresponding hashCode(v) helper function in java.util.Arrays.
  • The hash code for all other member values is determined by simply calling their hashCode method.
    [中]返回此批注的哈希代码。哈希代码根据以下规则确定:
    *批注的哈希代码是其批注成员的哈希代码之和。
    注释成员的哈希代码计算为(0x7fn.hashCode())^v.hashCode()),其中n是成员的名称(作为字符串),v是其值。
    *原语成员值的哈希代码是使用相应的包装器类型确定的。例如,整数。(v)的价值。hashCode()用于int值v。
    *数组成员值v的哈希代码是使用java中相应的hashCode(v)helper函数确定的。util。数组。
    *所有其他成员值的哈希代码只需调用其哈希代码方法即可确定。

代码示例

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

@Override
  public int hashCode() {
    return (this.fieldType.hashCode() * 29 + this.annotation.hashCode());
  }
}

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

@Override
public int hashCode() {
  return annotation.hashCode();
}

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

@Override
public int hashCode() {
  return annotation != null ? annotation.hashCode() : 0;
}

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

@Override
public int hashCode() {
 return 37 * annotation.hashCode();
}

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

@Override
public int hashCode() {
  return annotation != null ? annotation.hashCode() : 0;
}

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

@Override
public int hashCode() {
 return annotation.hashCode();
}

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

@Override
  public int hashCode() {
    return (this.fieldType.hashCode() * 29 + this.annotation.hashCode());
  }
}

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

@Override
  public int hashCode() {
    int result = annotations != null ? Arrays.hashCode(annotations) : 0;
    result = 31 * result + (sourceAnnotation != null ? sourceAnnotation.hashCode() : 0);
    result = 31 * result + (source != null ? source.hashCode() : 0);
    result = 31 * result + (sourceName != null ? sourceName.hashCode() : 0);
    result = 31 * result + (encoded ? 1 : 0);
    result = 31 * result + (defaultValue != null ? defaultValue.hashCode() : 0);
    result = 31 * result + (rawType != null ? rawType.hashCode() : 0);
    result = 31 * result + (type != null ? type.hashCode() : 0);
    return result;
  }
}

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

@Override
  public int hashCode() {
    int result = annotations != null ? Arrays.hashCode(annotations) : 0;
    result = 31 * result + (sourceAnnotation != null ? sourceAnnotation.hashCode() : 0);
    result = 31 * result + (source != null ? source.hashCode() : 0);
    result = 31 * result + (sourceName != null ? sourceName.hashCode() : 0);
    result = 31 * result + (encoded ? 1 : 0);
    result = 31 * result + (defaultValue != null ? defaultValue.hashCode() : 0);
    result = 31 * result + (rawType != null ? rawType.hashCode() : 0);
    result = 31 * result + (type != null ? type.hashCode() : 0);
    return result;
  }
}

代码示例来源:origin: org.glassfish.jersey.media/jersey-media-json-jackson

private final static int calcHash(Annotation[] annotations)
{
  /* hmmh. Can't just base on Annotation type; chances are that Annotation
   * instances use identity hash, which has to do.
   */
  final int len = annotations.length;
  int hash = len;
  for (int i = 0; i < len; ++i) {
    hash = (hash * 31) + annotations[i].hashCode();
  }
  return hash;
}

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

@Override
public int hashCode() {
  return 37 * annotation.hashCode();
}

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

@Override
public int hashCode() {
  return annotation.hashCode();
}

代码示例来源:origin: org.glassfish.jersey.core/jersey-server

@Override
public int hashCode() {
  return annotation != null ? annotation.hashCode() : 0;
}

代码示例来源:origin: org.glassfish.jersey.core/jersey-server

@Override
  public int hashCode() {
    int result = annotations != null ? Arrays.hashCode(annotations) : 0;
    result = 31 * result + (sourceAnnotation != null ? sourceAnnotation.hashCode() : 0);
    result = 31 * result + (source != null ? source.hashCode() : 0);
    result = 31 * result + (sourceName != null ? sourceName.hashCode() : 0);
    result = 31 * result + (encoded ? 1 : 0);
    result = 31 * result + (defaultValue != null ? defaultValue.hashCode() : 0);
    result = 31 * result + (rawType != null ? rawType.hashCode() : 0);
    result = 31 * result + (type != null ? type.hashCode() : 0);
    return result;
  }
}

代码示例来源:origin: com.fasterxml.jackson.jaxrs/jackson-jaxrs-base

private final static int calcHash(Annotation[] annotations)
{
  /* hmmh. Can't just base on Annotation type; chances are that Annotation
   * instances use identity hash, which has to do.
   */
  final int len = annotations.length;
  int hash = len;
  for (int i = 0; i < len; ++i) {
    hash = (hash * 31) + annotations[i].hashCode();
  }
  return hash;
}

代码示例来源:origin: org.codehaus.griffon/griffon-core

@Override
public int hashCode() {
  int result = qualifier != null ? qualifier.hashCode() : 0;
  result = 31 * result + instance.hashCode();
  return result;
}

代码示例来源:origin: skadistats/clarity

@Override
public int hashCode() {
  int result = annotation.hashCode();
  result = 31 * result + processorClass.hashCode();
  result = 31 * result + (method != null ? method.hashCode() : 0);
  return result;
}

代码示例来源:origin: org.codehaus.griffon/griffon-core

@Override
public int hashCode() {
  int result = source.hashCode();
  if (annotation != null) {
    result = 31 * result + annotation.hashCode();
  } else {
    result = 31 * result + (annotationType != null ? annotationType.hashCode() : 0);
  }
  return result;
}

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

@Override
  public int hashCode()
  {
    int result = type != null ? type.hashCode() : 0;
    result = 31 * result + (member != null ? member.hashCode() : 0);
    result = 31 * result + (clazz != null ? clazz.hashCode() : 0);
    result = 31 * result + (annotation != null ? annotation.hashCode() : 0);
    return result;
  }
}

代码示例来源:origin: org.mule.runtime/mule-core

@Override
 public int hashCode() {
  int result = type != null ? type.hashCode() : 0;
  result = 31 * result + (member != null ? member.hashCode() : 0);
  result = 31 * result + (clazz != null ? clazz.hashCode() : 0);
  result = 31 * result + (annotation != null ? annotation.hashCode() : 0);
  return result;
 }
}

相关文章