/** * Returns the declaring {@link AnnotatedType} of a given annotated. * * For an {@link AnnotatedMember}, {@link AnnotatedMember#getDeclaringType()} is returned. * For an {@link AnnotatedParameter}, the declaring annotated type of {@link AnnotatedParameter#getDeclaringCallable()} is returned. * If the parameter is an {@link AnnotatedType}, it is returned. * * @throws IllegalArgumentException if the annotated parameter is an unknown non-standard {@link Annotated} subclass. */ public static AnnotatedType<?> getDeclaringAnnotatedType(Annotated annotated) { if (annotated == null) { throw new IllegalArgumentException("Annotated cannot be null"); } if (annotated instanceof AnnotatedType<?>) { return cast(annotated); } if (annotated instanceof AnnotatedMember<?>) { return Reflections.<AnnotatedMember<?>>cast(annotated).getDeclaringType(); } if (annotated instanceof AnnotatedParameter<?>) { return getDeclaringAnnotatedType(Reflections.<AnnotatedParameter<?>>cast(annotated).getDeclaringCallable()); } throw new IllegalArgumentException("Unrecognized annotated " + annotated); }
/** * Returns the declaring {@link AnnotatedType} of a given annotated. * * For an {@link AnnotatedMember}, {@link AnnotatedMember#getDeclaringType()} is returned. * For an {@link AnnotatedParameter}, the declaring annotated type of {@link AnnotatedParameter#getDeclaringCallable()} is returned. * If the parameter is an {@link AnnotatedType}, it is returned. * * @throws IllegalArgumentException if the annotated parameter is an unknown non-standard {@link Annotated} subclass. */ public static AnnotatedType<?> getDeclaringAnnotatedType(Annotated annotated) { if (annotated == null) { throw new IllegalArgumentException("Annotated cannot be null"); } if (annotated instanceof AnnotatedType<?>) { return cast(annotated); } if (annotated instanceof AnnotatedMember<?>) { return Reflections.<AnnotatedMember<?>>cast(annotated).getDeclaringType(); } if (annotated instanceof AnnotatedParameter<?>) { return getDeclaringAnnotatedType(Reflections.<AnnotatedParameter<?>>cast(annotated).getDeclaringCallable()); } throw new IllegalArgumentException("Unrecognized annotated " + annotated); }
/** * Returns the declaring {@link AnnotatedType} of a given annotated. * * For an {@link AnnotatedMember}, {@link AnnotatedMember#getDeclaringType()} is returned. * For an {@link AnnotatedParameter}, the declaring annotated type of {@link AnnotatedParameter#getDeclaringCallable()} is returned. * If the parameter is an {@link AnnotatedType}, it is returned. * * @throws IllegalArgumentException if the annotated parameter is an unknown non-standard {@link Annotated} subclass. */ public static AnnotatedType<?> getDeclaringAnnotatedType(Annotated annotated) { if (annotated == null) { throw new IllegalArgumentException("Annotated cannot be null"); } if (annotated instanceof AnnotatedType<?>) { return cast(annotated); } if (annotated instanceof AnnotatedMember<?>) { return Reflections.<AnnotatedMember<?>>cast(annotated).getDeclaringType(); } if (annotated instanceof AnnotatedParameter<?>) { return getDeclaringAnnotatedType(Reflections.<AnnotatedParameter<?>>cast(annotated).getDeclaringCallable()); } throw new IllegalArgumentException("Unrecognized annotated " + annotated); }
/** * Returns the declaring {@link AnnotatedType} of a given annotated. * * For an {@link AnnotatedMember}, {@link AnnotatedMember#getDeclaringType()} is returned. * For an {@link AnnotatedParameter}, the declaring annotated type of {@link AnnotatedParameter#getDeclaringCallable()} is returned. * If the parameter is an {@link AnnotatedType}, it is returned. * * @throws IllegalArgumentException if the annotated parameter is an unknown non-standard {@link Annotated} subclass. */ public static AnnotatedType<?> getDeclaringAnnotatedType(Annotated annotated) { if (annotated == null) { throw new IllegalArgumentException("Annotated cannot be null"); } if (annotated instanceof AnnotatedType<?>) { return cast(annotated); } if (annotated instanceof AnnotatedMember<?>) { return Reflections.<AnnotatedMember<?>>cast(annotated).getDeclaringType(); } if (annotated instanceof AnnotatedParameter<?>) { return getDeclaringAnnotatedType(Reflections.<AnnotatedParameter<?>>cast(annotated).getDeclaringCallable()); } throw new IllegalArgumentException("Unrecognized annotated " + annotated); }
/** * Returns the declaring {@link AnnotatedType} of a given annotated. * * For an {@link AnnotatedMember}, {@link AnnotatedMember#getDeclaringType()} is returned. * For an {@link AnnotatedParameter}, the declaring annotated type of {@link AnnotatedParameter#getDeclaringCallable()} is returned. * If the parameter is an {@link AnnotatedType}, it is returned. * * @throws IllegalArgumentException if the annotated parameter is an unknown non-standard {@link Annotated} subclass. */ public static AnnotatedType<?> getDeclaringAnnotatedType(Annotated annotated) { if (annotated == null) { throw new IllegalArgumentException("Annotated cannot be null"); } if (annotated instanceof AnnotatedType<?>) { return cast(annotated); } if (annotated instanceof AnnotatedMember<?>) { return Reflections.<AnnotatedMember<?>>cast(annotated).getDeclaringType(); } if (annotated instanceof AnnotatedParameter<?>) { return getDeclaringAnnotatedType(Reflections.<AnnotatedParameter<?>>cast(annotated).getDeclaringCallable()); } throw new IllegalArgumentException("Unrecognized annotated " + annotated); }
/** * Returns the declaring {@link AnnotatedType} of a given annotated. * * For an {@link AnnotatedMember}, {@link AnnotatedMember#getDeclaringType()} is returned. * For an {@link AnnotatedParameter}, the declaring annotated type of {@link AnnotatedParameter#getDeclaringCallable()} is returned. * If the parameter is an {@link AnnotatedType}, it is returned. * * @throws IllegalArgumentException if the annotated parameter is an unknown non-standard {@link Annotated} subclass. */ public static AnnotatedType<?> getDeclaringAnnotatedType(Annotated annotated) { if (annotated == null) { throw new IllegalArgumentException("Annotated cannot be null"); } if (annotated instanceof AnnotatedType<?>) { return cast(annotated); } if (annotated instanceof AnnotatedMember<?>) { return Reflections.<AnnotatedMember<?>>cast(annotated).getDeclaringType(); } if (annotated instanceof AnnotatedParameter<?>) { return getDeclaringAnnotatedType(Reflections.<AnnotatedParameter<?>>cast(annotated).getDeclaringCallable()); } throw new IllegalArgumentException("Unrecognized annotated " + annotated); }
public void validateMetadataInjectionPoint(InjectionPoint ij, Bean<?> bean, MessageCallback<DefinitionException> messageCallback) { // metadata injection points if (ij.getType().equals(InjectionPoint.class) && bean == null) { throw messageCallback.construct(ij, Formats.formatAsStackTraceElement(ij)); } if (ij.getType().equals(InjectionPoint.class) && !Dependent.class.equals(bean.getScope())) { throw ValidatorLogger.LOG.injectionIntoNonDependentBean(ij, Formats.formatAsStackTraceElement(ij)); } Class<?> rawType = Reflections.getRawType(ij.getType()); if (Bean.class.equals(rawType) || Interceptor.class.equals(rawType) || Decorator.class.equals(rawType)) { if (bean == null) { throw messageCallback.construct(ij, Formats.formatAsStackTraceElement(ij)); } if (bean instanceof AbstractClassBean<?>) { checkBeanMetadataInjectionPoint(bean, ij, AnnotatedTypes.getDeclaringAnnotatedType(ij.getAnnotated()).getBaseType()); } if (bean instanceof ProducerMethod<?, ?>) { ProducerMethod<?, ?> producerMethod = Reflections.cast(bean); checkBeanMetadataInjectionPoint(bean, ij, producerMethod.getAnnotated().getBaseType()); } } }
public void validateMetadataInjectionPoint(InjectionPoint ij, Bean<?> bean, MessageCallback<DefinitionException> messageCallback) { // metadata injection points if (ij.getType().equals(InjectionPoint.class) && bean == null) { throw messageCallback.construct(ij, Formats.formatAsStackTraceElement(ij)); } if (ij.getType().equals(InjectionPoint.class) && !Dependent.class.equals(bean.getScope())) { throw ValidatorLogger.LOG.injectionIntoNonDependentBean(ij, Formats.formatAsStackTraceElement(ij)); } Class<?> rawType = Reflections.getRawType(ij.getType()); if (Bean.class.equals(rawType) || Interceptor.class.equals(rawType) || Decorator.class.equals(rawType)) { if (bean == null) { throw messageCallback.construct(ij, Formats.formatAsStackTraceElement(ij)); } if (bean instanceof AbstractClassBean<?>) { checkBeanMetadataInjectionPoint(bean, ij, AnnotatedTypes.getDeclaringAnnotatedType(ij.getAnnotated()).getBaseType()); } if (bean instanceof ProducerMethod<?, ?>) { ProducerMethod<?, ?> producerMethod = Reflections.cast(bean); checkBeanMetadataInjectionPoint(bean, ij, producerMethod.getAnnotated().getBaseType()); } } }
public void validateMetadataInjectionPoint(InjectionPoint ij, Bean<?> bean, MessageCallback<DefinitionException> messageCallback) { // metadata injection points if (ij.getType().equals(InjectionPoint.class) && bean == null) { throw messageCallback.construct(ij, Formats.formatAsStackTraceElement(ij)); } if (ij.getType().equals(InjectionPoint.class) && !Dependent.class.equals(bean.getScope())) { throw ValidatorLogger.LOG.injectionIntoNonDependentBean(ij, Formats.formatAsStackTraceElement(ij)); } Class<?> rawType = Reflections.getRawType(ij.getType()); if (Bean.class.equals(rawType) || Interceptor.class.equals(rawType) || Decorator.class.equals(rawType)) { if (bean == null) { throw messageCallback.construct(ij, Formats.formatAsStackTraceElement(ij)); } if (bean instanceof AbstractClassBean<?>) { checkBeanMetadataInjectionPoint(bean, ij, AnnotatedTypes.getDeclaringAnnotatedType(ij.getAnnotated()).getBaseType()); } if (bean instanceof ProducerMethod<?, ?>) { ProducerMethod<?, ?> producerMethod = Reflections.cast(bean); checkBeanMetadataInjectionPoint(bean, ij, producerMethod.getAnnotated().getBaseType()); } } }
public void validateMetadataInjectionPoint(InjectionPoint ij, Bean<?> bean, MessageCallback<DefinitionException> messageCallback) { // metadata injection points if (ij.getType().equals(InjectionPoint.class) && bean == null) { throw messageCallback.construct(ij, Formats.formatAsStackTraceElement(ij)); } if (ij.getType().equals(InjectionPoint.class) && !Dependent.class.equals(bean.getScope())) { throw ValidatorLogger.LOG.injectionIntoNonDependentBean(ij, Formats.formatAsStackTraceElement(ij)); } Class<?> rawType = Reflections.getRawType(ij.getType()); if (Bean.class.equals(rawType) || Interceptor.class.equals(rawType) || Decorator.class.equals(rawType)) { if (bean == null) { throw messageCallback.construct(ij, Formats.formatAsStackTraceElement(ij)); } if (bean instanceof AbstractClassBean<?>) { checkBeanMetadataInjectionPoint(bean, ij, AnnotatedTypes.getDeclaringAnnotatedType(ij.getAnnotated()).getBaseType()); } if (bean instanceof ProducerMethod<?, ?>) { ProducerMethod<?, ?> producerMethod = Reflections.cast(bean); checkBeanMetadataInjectionPoint(bean, ij, producerMethod.getAnnotated().getBaseType()); } } }
public void validateMetadataInjectionPoint(InjectionPoint ij, Bean<?> bean, MessageCallback<DefinitionException> messageCallback) { // metadata injection points if (ij.getType().equals(InjectionPoint.class) && bean == null) { throw messageCallback.construct(ij, Formats.formatAsStackTraceElement(ij)); } if (ij.getType().equals(InjectionPoint.class) && !Dependent.class.equals(bean.getScope())) { throw ValidatorLogger.LOG.injectionIntoNonDependentBean(ij, Formats.formatAsStackTraceElement(ij)); } Class<?> rawType = Reflections.getRawType(ij.getType()); if (Bean.class.equals(rawType) || Interceptor.class.equals(rawType) || Decorator.class.equals(rawType)) { if (bean == null) { throw messageCallback.construct(ij, Formats.formatAsStackTraceElement(ij)); } if (bean instanceof AbstractClassBean<?>) { checkBeanMetadataInjectionPoint(bean, ij, AnnotatedTypes.getDeclaringAnnotatedType(ij.getAnnotated()).getBaseType()); } if (bean instanceof ProducerMethod<?, ?>) { ProducerMethod<?, ?> producerMethod = Reflections.cast(bean); checkBeanMetadataInjectionPoint(bean, ij, producerMethod.getAnnotated().getBaseType()); } } }
public void validateMetadataInjectionPoint(InjectionPoint ij, Bean<?> bean, MessageCallback<DefinitionException> messageCallback) { // metadata injection points if (ij.getType().equals(InjectionPoint.class) && bean == null) { throw messageCallback.construct(ij, Formats.formatAsStackTraceElement(ij)); } if (ij.getType().equals(InjectionPoint.class) && !Dependent.class.equals(bean.getScope())) { throw ValidatorLogger.LOG.injectionIntoNonDependentBean(ij, Formats.formatAsStackTraceElement(ij)); } Class<?> rawType = Reflections.getRawType(ij.getType()); if (Bean.class.equals(rawType) || Interceptor.class.equals(rawType) || Decorator.class.equals(rawType)) { if (bean == null) { throw messageCallback.construct(ij, Formats.formatAsStackTraceElement(ij)); } if (bean instanceof AbstractClassBean<?>) { checkBeanMetadataInjectionPoint(bean, ij, AnnotatedTypes.getDeclaringAnnotatedType(ij.getAnnotated()).getBaseType()); } if (bean instanceof ProducerMethod<?, ?>) { ProducerMethod<?, ?> producerMethod = Reflections.cast(bean); checkBeanMetadataInjectionPoint(bean, ij, producerMethod.getAnnotated().getBaseType()); } } }