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

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

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

Constructor.getName介绍

[英]Returns the name of this constructor.
[中]返回此构造函数的名称。

代码示例

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

/**
 * {@inheritDoc}
 */
public String getName() {
  return constructor.getName();
}

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

/**
 * Returns constructor name.
 */
@Override
public String getName() {
  return constructor.getName();
}

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

@Override
public String getName() { return _constructor.getName(); }

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

@Override
public String getName() { return _constructor.getName(); }

代码示例来源:origin: oblac/jodd

/**
 * Returns constructor name.
 */
@Override
public String getName() {
  return constructor.getName();
}

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

public static String callGetName(Constructor thiz) {
  return thiz.getName();
}

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

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

代码示例来源:origin: org.codehaus.jackson/jackson-mapper-asl

@Override
public String getName() { return _constructor.getName(); }

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

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

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

public LambdaExecutable(Constructor<?> constructor) {
  this.parameterTypes = constructor.getGenericParameterTypes();
  this.returnType = constructor.getDeclaringClass();
  this.name = constructor.getName();
  this.executable = constructor;
}

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

/**
 * Compares constructor signatures: names and parameters.
 */
public static boolean compareSignatures(Constructor first, Constructor second) {
  if (!first.getName().equals(second.getName())) {
    return false;
  }
  return compareParameters(first.getParameterTypes(), second.getParameterTypes());
}

代码示例来源:origin: opentripplanner/OpenTripPlanner

@Override
  public String toString () {
    return String.format("%s(%s('%s'))", target.getName(), constructor.getName(), name);
  }
}

代码示例来源:origin: oblac/jodd

/**
 * Compares constructor signatures: names and parameters.
 */
public static boolean compareSignatures(final Constructor first, final Constructor second) {
  if (!first.getName().equals(second.getName())) {
    return false;
  }
  return compareParameters(first.getParameterTypes(), second.getParameterTypes());
}

代码示例来源:origin: opentripplanner/OpenTripPlanner

@Override
  public String toString () {
    return String.format("%s %s = %s('%s')", target.getType().getSimpleName(), 
        target.getName(), constructor.getName(), name);
  }
}

代码示例来源:origin: ronmamo/reflections

public static String name(Constructor constructor) {
  return constructor.getName() + "." + "<init>" + "(" + Joiner.on(", ").join(names(constructor.getParameterTypes())) + ")";
}

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

@Override
 public Object newInstance(Constructor constructor, Object... params) {
  if (constructor == null) {
   throw new IllegalArgumentException("Constructor cannot be null.");
  }
  try {
   constructor.setAccessible(true);
   return constructor.newInstance(params);
  } catch (IllegalAccessException | InstantiationException ex) {
   return ClassHelper.tryOtherConstructor(constructor.getDeclaringClass());
  } catch (SecurityException e) {
   throw new TestNGException(constructor.getName() + " must be public", e);
  } catch(Exception ex) {
   throw new TestNGException("Cannot instantiate class " + constructor.getDeclaringClass().getName(), ex);
  }
 }
}

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

static String generateMessage(final String message, final Constructor constructor, final Object[] args) {
 Parameter[] parameter = null;
 String name = null;
 if (constructor != null) {
  parameter = ReflectionRecipes.getConstructorParameters(constructor);
  name = constructor.getName();
 }
 return generateMessage(message, name, "Constructor", parameter, args);
}

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

@SuppressWarnings("unchecked")
public static <T> T invoke(Constructor<?> constructor, Object... args) {
  try {
    constructor.setAccessible(true);
    return (T) constructor.newInstance(args);
  } catch (Exception e) {
    throw U.rte("Cannot invoke constructor '%s' with args: %s", e, constructor.getName(), U.str(args));
  }
}

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

public String getName() {
 return getMethod() != null ? getMethod().getName() : getConstructor().getName();
}

代码示例来源:origin: google/guava

static Element constructor() throws Exception {
 Constructor<?> constructor = A.class.getDeclaredConstructor(Object.class);
 Element element = new Element(constructor);
 assertEquals(constructor.getName(), element.getName());
 assertEquals(A.class, element.getDeclaringClass());
 return element;
}

相关文章