Java Reflection Constructor Get getConstructor(final Class clazz, final Class... parameterTypes)

Here you can find the source of getConstructor(final Class clazz, final Class... parameterTypes)

Description

Returns the public constructor of the specified class or null if no such constructor

License

Apache License

Parameter

Parameter Description
clazz The represented class
parameterTypes The parameter types of constructor

Return

the matched constructor or null if not found

Declaration

public static <T> Constructor<T> getConstructor(final Class<T> clazz, final Class<?>... parameterTypes) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.lang.reflect.Constructor;

public class Main {
    /**/* w w w  .j  a  v a2s . c om*/
     * Returns the public constructor of the specified class or null if no such
     * constructor
     * 
     * @param clazz
     *            The represented class
     * @param parameterTypes
     *            The parameter types of constructor
     * @return the matched constructor or null if not found
     */
    public static <T> Constructor<T> getConstructor(final Class<T> clazz, final Class<?>... parameterTypes) {
        try {
            return clazz.getConstructor(parameterTypes);
        } catch (final Exception e) {
            return null;
        }
    }
}

Related

  1. getConstructor(final Class theClass, final Class... parameterTypes)
  2. getConstructor(final Class clazz, final Class... parameterTypes)
  3. getConstructor(final Class clazz, final Class[] paramTypes)
  4. getConstructor(final Class valueClass, final Class parameter)
  5. getConstructor(final Class clazz, final Class... parametertypes)
  6. getConstructor(final Class clazz, final Object... constructorArgs)
  7. getConstructor(final Class clazz, final Object... objs)
  8. getConstructor(final Class instantiableClass, final Class... classes)
  9. getConstructor(String className, Class... argClasses)