Constructor getParameterTypes - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Constructor getParameterTypes method.

This code example shows how to use the following methods:getParameterTypes
import java.lang.reflect.InvocationTargetException; 
 
public class FastConstructor extends FastMember 
{ 
    FastConstructor(FastClass fc, Constructor constructor) {
        super(fc, constructor, fc.getIndex(constructor.getParameterTypes()));
    } 
 
    public Class[] getParameterTypes() {
        return ((Constructor)member).getParameterTypes();
    } 
 
    public Class[] getExceptionTypes() {
        return ((Constructor)member).getExceptionTypes();
    } 
 
    public Object newInstance() throws InvocationTargetException {
        return fc.newInstance(index, null); 
    } 
 
7
CodeRank
This code example shows how to use the following methods:getParameterTypes
				this.parameterType = (this.method != null ? this.method.getReturnType() : null);
			} 
			else { 
				this.parameterType = (this.method != null ?
					this.method.getParameterTypes()[this.parameterIndex] :
					this.constructor.getParameterTypes()[this.parameterIndex]);
			} 
		} 
		return this.parameterType;
	} 
 
	/** 
	 * Return the generic type of the method/constructor parameter. 
	 * @return the parameter type (never {@code null}) 
	 */ 
	public Type getGenericParameterType() {
		if (this.genericParameterType == null) {
			if (this.parameterIndex < 0) {
				this.genericParameterType = (this.method != null ? this.method.getGenericReturnType() : null);
			} 
7
CodeRank
This code example shows how to use the following methods:getParameterTypes, isVarArgs
	private final Integer varargsPosition;
 
 
	public ReflectiveConstructorExecutor(Constructor<?> ctor) {
		this.ctor = ctor;
		if (ctor.isVarArgs()) {
			Class<?>[] paramTypes = ctor.getParameterTypes();
			this.varargsPosition = paramTypes.length - 1;
		} 
		else { 
			this.varargsPosition = null;
		} 
	} 
 
	@Override 
	public TypedValue execute(EvaluationContext context, Object... arguments) throws AccessException {
		try { 
			if (arguments != null) { 
				ReflectionHelper.convertArguments(context.getTypeConverter(), arguments, this.ctor, this.varargsPosition);
			} 
8
CodeRank
This code example shows how to use the following methods:getGenericParameterTypes, getParameterAnnotations, getParameterTypes
        super(constructor, constructor.getDeclaringClass(), declaringType, sharedObjectCache);
    } 
 
    @Override 
    protected List<AnnotatedParameter<X>> initParameters(Constructor<X> member, SharedObjectCache sharedObjectCache) {
        int length = member.getParameterTypes().length;
        if (length == member.getGenericParameterTypes().length && length == member.getParameterAnnotations().length) {
            return BackedAnnotatedParameter.forExecutable(member, this, sharedObjectCache);
        } else { 
            /* 
             * We are seeing either http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6520205 or 
             * http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=5087240 or both. 
             * 
             * It is difficult to detect and adapt to these bugs properly. Therefore, we pretend to see a no-args constructor. Although misleading, it is quite 
             * safe to do that since non-static inner classes are not CDI-managed beans anyway and CDI constructor injection into Enums is not supported. 
             */ 
            return Collections.emptyList();
        } 
 
    } 
7
CodeRank
This code example shows how to use the following methods:setAccessible, getModifiers, getParameterTypes, newInstance
 
  @SuppressWarnings("unchecked") 
  public void test_constructor() throws Exception {
    Constructor<?>[] cons = InetAddressUtils.class.getDeclaredConstructors();
    assertEquals(1, cons.length);
    assertEquals(0, cons[0].getParameterTypes().length);
    assertEquals(true, Modifier.isPrivate(cons[0].getModifiers()));
    Constructor<InetAddressUtils> con = (Constructor<InetAddressUtils>) cons[0];
    con.setAccessible(true);
    con.newInstance();
  } 
 
  //------------------------------------------------------------------------- 
  public void test_strip() { 
    assertNotNull(InetAddressUtils.getLocalHostName());
  } 
 
} 
7
CodeRank
This code example shows how to use the following methods:getDeclaringClass, getExceptionTypes, getModifiers, getParameterTypes
        return getSimpleClassName(c);
    } 
 
    private Object preprocess(Constructor<?> method) {
        try { 
            return preprocessMethodOrConstructor(method.getModifiers(), null, method.getDeclaringClass(), null,
                                                 method.getParameterTypes(), method.getExceptionTypes());
        } catch (Exception e) {
            return "<" + e + ">";
        } 
    } 
 
    private Object preprocess(Method method) {
        try { 
            return preprocessMethodOrConstructor(method.getModifiers(), method.getReturnType(),
                                                 method.getDeclaringClass(), method.getName(), method.getParameterTypes(),
                                                 method.getExceptionTypes());
        } catch (Exception e) {
            return "<" + e + ">";
        } 
7
CodeRank
This code example shows how to use the following methods:getParameterTypes
		} 
		else if (member instanceof Field) {
			source = JdtUtils.getField(type, ((Field) member).getName());
		} 
		else if (member instanceof Constructor<?>) {
			source = JdtUtils.getConstructor(type, ((Constructor<?>) member).getParameterTypes());
		} 
		return source;
	} 
	 
}	 
7
CodeRank
This code example shows how to use the following methods:getParameterTypes
 
	@SuppressWarnings({ "rawtypes" }) 
	private Constructor checkIfThereIsOnlyOneNonDefaultConstructor(Class beanClass) {
	Constructor[] constructors = beanClass.getDeclaredConstructors();
	if (constructors.length == 1) {
		if (constructors[0].getParameterTypes().length > 0) {
		return constructors[0];
		} 
	} 
	return null; 
	} 
} 
7
CodeRank
This code example shows how to use the following methods:getDeclaringClass, getName, getParameterTypes, hashCode
This code example shows how to use the following methods:setAccessible, getModifiers, getParameterTypes, newInstance
 
  @SuppressWarnings("unchecked") 
  public void test_constructor() throws Exception {
    Constructor<?>[] cons = JdkUtils.class.getDeclaredConstructors();
    assertEquals(1, cons.length);
    assertEquals(0, cons[0].getParameterTypes().length);
    assertEquals(true, Modifier.isPrivate(cons[0].getModifiers()));
    Constructor<JdkUtils> con = (Constructor<JdkUtils>) cons[0];
    con.setAccessible(true);
    con.newInstance();
  } 
 
  //------------------------------------------------------------------------- 
  public void test_strip() { 
    assertEquals(BigDecimal.valueOf(0, 0), JdkUtils.stripTrailingZeros(BigDecimal.valueOf(0, 2)));
    assertEquals(BigDecimal.valueOf(1, 0), JdkUtils.stripTrailingZeros(BigDecimal.valueOf(1, 0)));
  } 
 
} 
7
CodeRank
getParameterTypes Method Overview
Returns an array of Class objects that represent the formal parameter types, in declaration order, of the executable represented by this object.
See Code Examples for other Java 8 Constructor Methods: