Here you can find the source of getConstructor(final Class extends E> clazz, final Class>... parameterTypes)
Parameter | Description |
---|---|
E | a parameter |
clazz | a parameter |
parameterTypes | a parameter |
public static <E> Optional<Constructor<? extends E>> getConstructor(final Class<? extends E> clazz, final Class<?>... parameterTypes)
//package com.java2s; import java.lang.reflect.Constructor; import java.util.Optional; public class Main { /**//from w ww. j av a 2 s.co m * TODO: Documentation * @param <E> * @param clazz * @param parameterTypes * @return */ public static <E> Optional<Constructor<? extends E>> getConstructor(final Class<? extends E> clazz, final Class<?>... parameterTypes) { try { final Constructor<? extends E> c = clazz.getDeclaredConstructor(parameterTypes); return Optional.<Constructor<? extends E>>of(c); } catch (final Exception e) { return Optional.<Constructor<? extends E>>empty(); } } }