/** * Returns a constructor with single argument. * @param <T> the type of the constructor * @param klass the class to be constructed * @param parameterType The constructor parameter type * @return null if matching accessible constructor can not be found. * @see Class#getConstructor * @see #getAccessibleConstructor(java.lang.reflect.Constructor) */ public static <T> Constructor<T> getAccessibleConstructor( final Class<T> klass, final Class<?> parameterType) { final Class<?>[] parameterTypes = { parameterType }; return getAccessibleConstructor(klass, parameterTypes); }
/** * Returns a constructor with single argument. * @param <T> the type of the constructor * @param klass the class to be constructed * @param parameterType The constructor parameter type * @return null if matching accessible constructor can not be found. * @see Class#getConstructor * @see #getAccessibleConstructor(java.lang.reflect.Constructor) */ public static <T> Constructor<T> getAccessibleConstructor( final Class<T> klass, final Class<?> parameterType) { final Class<?>[] parameterTypes = { parameterType }; return getAccessibleConstructor(klass, parameterTypes); }
/** * Returns a constructor given a class and signature. * @param <T> the type to be constructed * @param klass the class to be constructed * @param parameterTypes the parameter array * @return null if matching accessible constructor can not be found * @see Class#getConstructor * @see #getAccessibleConstructor(java.lang.reflect.Constructor) */ public static <T> Constructor<T> getAccessibleConstructor( final Class<T> klass, final Class<?>[] parameterTypes) { try { return getAccessibleConstructor( klass.getConstructor(parameterTypes)); } catch (final NoSuchMethodException e) { return (null); } }
/** * Returns a constructor given a class and signature. * @param <T> the type to be constructed * @param klass the class to be constructed * @param parameterTypes the parameter array * @return null if matching accessible constructor can not be found * @see Class#getConstructor * @see #getAccessibleConstructor(java.lang.reflect.Constructor) */ public static <T> Constructor<T> getAccessibleConstructor( final Class<T> klass, final Class<?>[] parameterTypes) { try { return getAccessibleConstructor( klass.getConstructor(parameterTypes)); } catch (final NoSuchMethodException e) { return (null); } }
final Constructor<?> ctor = getAccessibleConstructor(ctor2); if (ctor != null) { try {
final Constructor<?> ctor = getAccessibleConstructor(ctor2); if (ctor != null) { try {
final Constructor<T> ctor = getAccessibleConstructor(klass, parameterTypes); if (null == ctor) { throw new NoSuchMethodException(
final Constructor<T> ctor = getAccessibleConstructor(klass, parameterTypes); if (null == ctor) { throw new NoSuchMethodException(
ConstructorUtils.getAccessibleConstructor(source.getClass(), source.getClass()); if (copyConstructor != null) { try {
/** * Returns a constructor with single argument. * @param klass the class to be constructed * @param parameterType The constructor parameter type * @return null if matching accessible constructor can not be found. * @see Class#getConstructor * @see #getAccessibleConstructor(java.lang.reflect.Constructor) */ public static Constructor getAccessibleConstructor( Class klass, Class parameterType) { Class[] parameterTypes = { parameterType }; return getAccessibleConstructor(klass, parameterTypes); }
/** * Returns a constructor with single argument. * @param klass the class to be constructed * @param parameterType The constructor parameter type * @return null if matching accessible constructor can not be found. * @see Class#getConstructor * @see #getAccessibleConstructor(java.lang.reflect.Constructor) */ public static Constructor getAccessibleConstructor( Class klass, Class parameterType) { Class[] parameterTypes = { parameterType }; return getAccessibleConstructor(klass, parameterTypes); }
/** * Returns a constructor with single argument. * @param klass the class to be constructed * @param parameterType The constructor parameter type * @return null if matching accessible constructor can not be found. * @see Class#getConstructor * @see #getAccessibleConstructor(java.lang.reflect.Constructor) */ public static Constructor getAccessibleConstructor( Class klass, Class parameterType) { Class[] parameterTypes = { parameterType }; return getAccessibleConstructor(klass, parameterTypes); }
/** * Returns a constructor with single argument. * @param <T> the type of the constructor * @param klass the class to be constructed * @param parameterType The constructor parameter type * @return null if matching accessible constructor can not be found. * @see Class#getConstructor * @see #getAccessibleConstructor(java.lang.reflect.Constructor) */ public static <T> Constructor<T> getAccessibleConstructor( final Class<T> klass, final Class<?> parameterType) { final Class<?>[] parameterTypes = { parameterType }; return getAccessibleConstructor(klass, parameterTypes); }
/** * <p> Set and cache ActionContext class. </p><p> If there is a custom * class provided and if it uses our "preferred" constructor, cache a * reference to that constructor rather than looking it up every time. * </p> * * @param actionContextClass The ActionContext class to process */ private void setActionContextClass(Class actionContextClass) { this.actionContextClass = actionContextClass; if (actionContextClass != null) { this.servletActionContextConstructor = ConstructorUtils.getAccessibleConstructor(actionContextClass, SERVLET_ACTION_CONTEXT_CTOR_SIGNATURE); } else { this.servletActionContextConstructor = null; } }
private static boolean isInstantiable(Class<?> clazz) { boolean abs = Modifier.isAbstract(clazz.getModifiers()); boolean hasConstuctor = ConstructorUtils.getAccessibleConstructor(clazz, new Class[0]) != null; return !clazz.isInterface() && !abs && hasConstuctor; }
/** * Returns a constructor given a class and signature. * @param klass the class to be constructed * @param parameterTypes the parameter array * @return null if matching accessible constructor can not be found * @see Class#getConstructor * @see #getAccessibleConstructor(java.lang.reflect.Constructor) */ public static Constructor getAccessibleConstructor( Class klass, Class[] parameterTypes) { try { return getAccessibleConstructor( klass.getConstructor(parameterTypes)); } catch (NoSuchMethodException e) { return (null); } }
/** * Returns a constructor given a class and signature. * @param klass the class to be constructed * @param parameterTypes the parameter array * @return null if matching accessible constructor can not be found * @see Class#getConstructor * @see #getAccessibleConstructor(java.lang.reflect.Constructor) */ public static Constructor getAccessibleConstructor( Class klass, Class[] parameterTypes) { try { return getAccessibleConstructor( klass.getConstructor(parameterTypes)); } catch (NoSuchMethodException e) { return (null); } }
/** * Returns a constructor given a class and signature. * @param klass the class to be constructed * @param parameterTypes the parameter array * @return null if matching accessible constructor can not be found * @see Class#getConstructor * @see #getAccessibleConstructor(java.lang.reflect.Constructor) */ public static Constructor getAccessibleConstructor( Class klass, Class[] parameterTypes) { try { return getAccessibleConstructor( klass.getConstructor(parameterTypes)); } catch (NoSuchMethodException e) { return (null); } }
/** * Returns a constructor given a class and signature. * @param <T> the type to be constructed * @param klass the class to be constructed * @param parameterTypes the parameter array * @return null if matching accessible constructor can not be found * @see Class#getConstructor * @see #getAccessibleConstructor(java.lang.reflect.Constructor) */ public static <T> Constructor<T> getAccessibleConstructor( final Class<T> klass, final Class<?>[] parameterTypes) { try { return getAccessibleConstructor( klass.getConstructor(parameterTypes)); } catch (final NoSuchMethodException e) { return (null); } }
@Override protected Window<?> createMainWindow() { try { Constructor constructor = ConstructorUtils.getAccessibleConstructor(classOfWindow, WindowOwner.class); return (Window<?>) constructor.newInstance(this); } catch (Exception e) { throw new ArenaException("La clase de la ventana debe tener un constructor con un unico parametro de tipo 'WindowOwner'", e); } }