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

x33g5p2x  于2022-01-17 转载在 其他  
字(7.4k)|赞(0)|评价(0)|浏览(110)

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

Constructor.equals介绍

[英]Indicates whether or not the specified object is equal to this constructor. To be equal, the specified object must be an instance of Constructor with the same declaring class and parameter types as this constructor.
[中]指示指定的对象是否等于此构造函数。若要相等,指定的对象必须是与此构造函数具有相同声明类和参数类型的构造函数实例。

代码示例

代码示例来源:origin: hibernate/hibernate-orm

/**
   * 2 AliasToBeanConstructorResultTransformer are considered equal if they have the same
   * defined constructor.
   *
   * @param other The other instance to check for equality.
   * @return True if both have the same defined constuctor; false otherwise.
   */
  @Override
  public boolean equals(Object other) {
    return other instanceof AliasToBeanConstructorResultTransformer
        && constructor.equals( ( ( AliasToBeanConstructorResultTransformer ) other ).constructor );
  }
}

代码示例来源:origin: oldmanpushcart/greys-anatomy

@Override
public boolean equals(Object obj) {
  return target.equals(obj);
}

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

public static boolean callEquals(Constructor thiz, Object a0) {
  return thiz.equals(a0);
}

代码示例来源:origin: alibaba/jvm-sandbox

@Override
public boolean equals(Object obj) {
  return target.equals(obj);
}

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

/**
 * {@inheritDoc}
 */
public boolean represents(Constructor<?> constructor) {
  return this.constructor.equals(constructor) || equals(new MethodDescription.ForLoadedConstructor(constructor));
}

代码示例来源:origin: org.codehaus.groovy/groovy

public static CachedConstructor find(Constructor constructor) {
  CachedConstructor[] constructors = ReflectionCache.getCachedClass(constructor.getDeclaringClass()).getConstructors();
  for (int i = 0; i < constructors.length; i++) {
    CachedConstructor cachedConstructor = constructors[i];
    if (cachedConstructor.cachedConstructor.equals(constructor))
      return cachedConstructor;
  }
  throw new RuntimeException("Couldn't find method: " + constructor);
}

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

private Constructor<?> getConstructor(Class<?> cl) throws HiveException {
 try {
  Constructor<?> [] ctors = cl.getDeclaredConstructors();
  if (ctors.length == 1) {
   return ctors[0];
  }
  Constructor<?> defaultCtor = cl.getConstructor();
  for (Constructor<?> ctor : ctors) {
   if (!ctor.equals(defaultCtor)) {
    return ctor;
   }
  }
  throw new HiveException("Only default constructor found");
 } catch (Exception ex) {
  throw new HiveException(ex);
 }
}

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

private Constructor<?> getConstructor(Class<?> cl) throws HiveException {
 try {
  Constructor<?> [] ctors = cl.getDeclaredConstructors();
  if (ctors.length == 1) {
   return ctors[0];
  }
  Constructor<?> defaultCtor = cl.getConstructor();
  for (Constructor<?> ctor : ctors) {
   if (!ctor.equals(defaultCtor)) {
    return ctor;
   }
  }
  throw new HiveException("Only default constructor found");
 } catch (Exception ex) {
  throw new HiveException(ex);
 }
}

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

defaultConstructor != null && !primaryConstructor.equals(defaultConstructor)) {
candidateConstructors = new Constructor<?>[] {primaryConstructor, defaultConstructor};

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

for (int i = 0; i < constructors.length; ++i) {
  Constructor<?> constructor = constructors[i];
  if (constructor.equals(constructorToUse)) {
    if (i > (int)Byte.MAX_VALUE) {
      throw new IllegalArgumentException(

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

@Override
public boolean equals(Object obj) {
 if (this == obj)
  return true;
 if (obj == null)
  return false;
 if (getClass() != obj.getClass())
  return false;
 ConstructorOrMethod other = (ConstructorOrMethod) obj;
 if (getConstructor() == null) {
  if (other.getConstructor() != null)
   return false;
 } else if (!getConstructor().equals(other.getConstructor()))
  return false;
 if (getMethod() == null) {
  if (other.getMethod() != null)
   return false;
 } else if (!getMethod().equals(other.getMethod()))
  return false;
 return true;
}

代码示例来源:origin: cbeust/testng

@Override
public boolean equals(Object obj) {
 if (this == obj) return true;
 if (obj == null) return false;
 if (getClass() != obj.getClass()) return false;
 ConstructorOrMethod other = (ConstructorOrMethod) obj;
 if (getConstructor() == null) {
  if (other.getConstructor() != null) return false;
 } else if (!getConstructor().equals(other.getConstructor())) return false;
 if (getMethod() == null) {
  if (other.getMethod() != null) return false;
 } else if (!getMethod().equals(other.getMethod())) return false;
 return true;
}

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

defaultConstructor != null && !primaryConstructor.equals(defaultConstructor)) {
candidateConstructors = new Constructor<?>[] {primaryConstructor, defaultConstructor};

代码示例来源:origin: INRIA/spoon

/**
 * Compares based on the executable and the index.
 *
 * @param obj
 *         The object to compare.
 * @return Whether or not this is equal to the argument.
 */
public boolean equals(Object obj) {
  if (obj instanceof RtParameter) {
    RtParameter other = (RtParameter) obj;
    if (method == null) {
      return (other.constructor.equals(constructor) && other.index == index);
    }
    return (other.method.equals(method) && other.index == index);
  }
  return false;
}

代码示例来源:origin: org.jboss.aop/jboss-aop

public boolean equals(Object o)
{
 if (o == null) return false;
 if (o == this) return true;
 if (!(o instanceof ConstructorCalledByConstructorJoinpoint)) return false;
 ConstructorCalledByConstructorJoinpoint jp = (ConstructorCalledByConstructorJoinpoint)o;
 if (!jp.calling.equals(this.calling)) return false;
 if (!jp.called.equals(this.called)) return false;
 return true;
}

代码示例来源:origin: org.jboss.aop/jboss-aop

public boolean equals(Object o)
{
 if (o == null) return false;
 if (o == this) return true;
 if (!(o instanceof MethodCalledByConstructorJoinpoint)) return false;
 MethodCalledByConstructorJoinpoint jp = (MethodCalledByConstructorJoinpoint)o;
 if (!jp.calling.equals(this.calling)) return false;
 if (!jp.called.equals(this.called)) return false;
 return true;
}

代码示例来源:origin: com.fitbur.external/external-bytebuddy

@Override
public boolean equals(Object other) {
  if (this == other) return true;
  if (other == null || getClass() != other.getClass()) return false;
  if (!super.equals(other)) return false;
  ForJava7CapableVm that = (ForJava7CapableVm) other;
  return methodInfo.equals(that.methodInfo);
}

代码示例来源:origin: org.apache.tomee.patch/bval-jsr

private <T> boolean computeIsConstructorValidated(Class<T> targetClass, Constructor<T> ctor) {
  final AnnotatedType<T> annotatedType =
    CDI.current().getBeanManager().createAnnotatedType(ctor.getDeclaringClass());
  final ValidateOnExecution annotation =
    annotatedType.getConstructors().stream().filter(ac -> ctor.equals(ac.getJavaMember())).findFirst()
      .map(ac -> ac.getAnnotation(ValidateOnExecution.class))
      .orElseGet(() -> ctor.getAnnotation(ValidateOnExecution.class));
  final Set<ExecutableType> validatedExecutableTypes =
    annotation == null ? classConfiguration : ExecutableTypes.interpret(annotation.type());
  return validatedExecutableTypes.contains(ExecutableType.CONSTRUCTORS);
}

代码示例来源:origin: weld/core

@Override
  protected boolean matches(InjectionPoint ip, AnnotatedCallable<?> annotatedCallable) {
    if (annotatedCallable instanceof AnnotatedConstructor<?>) {
      AnnotatedConstructor<?> annotatedConstructor = Reflections.cast(annotatedCallable);
      return constructor.get().equals(annotatedConstructor.getJavaMember());
    }
    return false;
  }
}

代码示例来源:origin: org.jboss.weld.se/weld-se

@Override
  protected boolean matches(InjectionPoint ip, AnnotatedCallable<?> annotatedCallable) {
    if (annotatedCallable instanceof AnnotatedConstructor<?>) {
      AnnotatedConstructor<?> annotatedConstructor = Reflections.cast(annotatedCallable);
      return constructor.get().equals(annotatedConstructor.getJavaMember());
    }
    return false;
  }
}

相关文章

微信公众号

最新文章

更多