/** * Builds Key from Type and annotation types * * @param type target type * @param annTypes associated annotations * @param <T> type * @return instance of a Key */ public static <T> Key<T> of(Type type, Class<? extends Annotation> []annTypes) { return new Key<>(type, annTypes); }
/** * Builds key from a Class * * @param type target class * @param <T> target type * @return instance of a Key */ public static <T> Key<T> of(Class<T> type) { return new Key<>(type); }
/** * Builds key from a Type * * @param type target type * @param <T> type * @return instance of a Key */ public static <T> Key<T> of(Type type) { return new Key<>(type); }
/** * Builds Key from Class and annotation type * * @param type target type * @param annType associated annotation * @param <T> type * @return instance of a Key */ public static <T> Key<T> of(Class<T> type, Class<? extends Annotation> annType) { Objects.requireNonNull(type); Objects.requireNonNull(annType); return new Key<>(type, new Class[] { annType }); }
/** * Builds Key from a Class and annotation * * @param type target class * @param ann associated annotation * @param <T> target type * @return instance of a Key */ public static <T> Key<T> of(Class<T> type, Annotation ann) { Objects.requireNonNull(type); Objects.requireNonNull(ann); return new Key<>(type, new Annotation[] { ann }); }
/** * Builds Key from field's generic type and field's qualifying annotations. * A qualifying annotation is marked with a {@code @Qualifier}. * * @param field field for deriving type and annotation from * @param <T> target type * @return instance of a Key */ public static <T> Key<T> of(Field field) { return new Key(field.getGenericType(), qualifiers(field.getAnnotations())); }
/** * Builds Key from method's generic return type and method's qualifying * annotations. A qualifying annotation is marked with a {@code @Qualifier}. * * @param method method for deriving return type and annotations from * @param <T> target type * @return instance of a Key */ public static <T> Key<T> of(Method method) { return new Key(method.getGenericReturnType(), qualifiers(method.getAnnotations())); }
/** * Builds Key from constructor's declaring class and constructor's qualifying * annotations. A qualifying annotation is marked with a {@code @Qualifier}. * * @param ctor constructor for deriving type and annotations from * @param <T> target type * @return instance of a Key */ public static <T> Key<T> of(Constructor ctor) { return new Key(ctor.getDeclaringClass(), qualifiers(ctor.getAnnotations())); }
/** * Builds Key from parameter's parameterized type and and qualifying annotations * found on the parameter and its declaring executable (e.g. Method) * * @param parameter parameter for deriving type and annotations from * @return instance of a key */ public static Key<?> of(Parameter parameter) { return new Key(parameter.getParameterizedType(), qualifiers(parameter.getAnnotations(), parameter.getDeclaringExecutable().getAnnotations())); }