Search in sources :

Example 1 with AnnotatedCallable

use of jakarta.enterprise.inject.spi.AnnotatedCallable in project hibernate-validator by hibernate.

the class ValidationExtension method determineConstrainedCallables.

private <T> Set<AnnotatedCallable<? super T>> determineConstrainedCallables(AnnotatedType<T> type) {
    Set<AnnotatedCallable<? super T>> callables = new HashSet<>();
    BeanDescriptor beanDescriptor = validator.getConstraintsForClass(type.getJavaClass());
    determineConstrainedConstructors(type, beanDescriptor, callables);
    determineConstrainedMethods(type, beanDescriptor, callables);
    return callables;
}
Also used : BeanDescriptor(jakarta.validation.metadata.BeanDescriptor) AnnotatedCallable(jakarta.enterprise.inject.spi.AnnotatedCallable) HashSet(java.util.HashSet)

Example 2 with AnnotatedCallable

use of jakarta.enterprise.inject.spi.AnnotatedCallable in project core by weld.

the class JsonObjectsTest method getFooAnnotatedMethod.

private static AnnotatedMethod<Foo> getFooAnnotatedMethod(String name) {
    final Method method = findDeclaredFooMethod(name);
    return new AnnotatedMethod<Foo>() {

        @Override
        public List<AnnotatedParameter<Foo>> getParameters() {
            Type[] paramTypes = method.getGenericParameterTypes();
            if (paramTypes.length == 0) {
                return Collections.emptyList();
            }
            List<AnnotatedParameter<Foo>> params = new ArrayList<>();
            for (int i = 0; i < paramTypes.length; i++) {
                final Type baseType = paramTypes[i];
                final Annotation[] annotations = method.getParameterAnnotations()[i];
                params.add(new AnnotatedParameter<Foo>() {

                    @Override
                    public Type getBaseType() {
                        return baseType;
                    }

                    @Override
                    public Set<Type> getTypeClosure() {
                        throw new UnsupportedOperationException();
                    }

                    @Override
                    public <T extends Annotation> T getAnnotation(Class<T> annotationType) {
                        throw new UnsupportedOperationException();
                    }

                    @Override
                    public Set<Annotation> getAnnotations() {
                        return new HashSet<>(Arrays.asList(annotations));
                    }

                    @Override
                    public boolean isAnnotationPresent(Class<? extends Annotation> annotationType) {
                        throw new UnsupportedOperationException();
                    }

                    @Override
                    public int getPosition() {
                        throw new UnsupportedOperationException();
                    }

                    @Override
                    public AnnotatedCallable<Foo> getDeclaringCallable() {
                        throw new UnsupportedOperationException();
                    }
                });
            }
            return params;
        }

        @Override
        public boolean isStatic() {
            throw new UnsupportedOperationException();
        }

        @Override
        public AnnotatedType<Foo> getDeclaringType() {
            return new AnnotatedType<Foo>() {

                @Override
                public Type getBaseType() {
                    throw new UnsupportedOperationException();
                }

                @Override
                public Set<Type> getTypeClosure() {
                    throw new UnsupportedOperationException();
                }

                @Override
                public <T extends Annotation> T getAnnotation(Class<T> annotationType) {
                    throw new UnsupportedOperationException();
                }

                @Override
                public Set<Annotation> getAnnotations() {
                    throw new UnsupportedOperationException();
                }

                @Override
                public boolean isAnnotationPresent(Class<? extends Annotation> annotationType) {
                    throw new UnsupportedOperationException();
                }

                @Override
                public Class<Foo> getJavaClass() {
                    return Foo.class;
                }

                @Override
                public Set<AnnotatedConstructor<Foo>> getConstructors() {
                    throw new UnsupportedOperationException();
                }

                @Override
                public Set<AnnotatedMethod<? super Foo>> getMethods() {
                    throw new UnsupportedOperationException();
                }

                @Override
                public Set<AnnotatedField<? super Foo>> getFields() {
                    throw new UnsupportedOperationException();
                }
            };
        }

        @Override
        public Type getBaseType() {
            throw new UnsupportedOperationException();
        }

        @Override
        public Set<Type> getTypeClosure() {
            throw new UnsupportedOperationException();
        }

        @Override
        public <T extends Annotation> T getAnnotation(Class<T> annotationType) {
            throw new UnsupportedOperationException();
        }

        @Override
        public Set<Annotation> getAnnotations() {
            return new HashSet<>(Arrays.asList(method.getAnnotations()));
        }

        @Override
        public boolean isAnnotationPresent(Class<? extends Annotation> annotationType) {
            throw new UnsupportedOperationException();
        }

        @Override
        public Method getJavaMember() {
            return method;
        }
    };
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) AnnotatedMethod(jakarta.enterprise.inject.spi.AnnotatedMethod) AnnotatedParameter(jakarta.enterprise.inject.spi.AnnotatedParameter) ArrayList(java.util.ArrayList) AnnotatedCallable(jakarta.enterprise.inject.spi.AnnotatedCallable) AnnotatedConstructor(jakarta.enterprise.inject.spi.AnnotatedConstructor) HashSet(java.util.HashSet) AnnotatedMethod(jakarta.enterprise.inject.spi.AnnotatedMethod) Method(java.lang.reflect.Method) Annotation(java.lang.annotation.Annotation) ElementType(java.lang.annotation.ElementType) Type(java.lang.reflect.Type) AnnotatedType(jakarta.enterprise.inject.spi.AnnotatedType) AnnotatedType(jakarta.enterprise.inject.spi.AnnotatedType) AnnotatedField(jakarta.enterprise.inject.spi.AnnotatedField)

Aggregations

AnnotatedCallable (jakarta.enterprise.inject.spi.AnnotatedCallable)2 HashSet (java.util.HashSet)2 AnnotatedConstructor (jakarta.enterprise.inject.spi.AnnotatedConstructor)1 AnnotatedField (jakarta.enterprise.inject.spi.AnnotatedField)1 AnnotatedMethod (jakarta.enterprise.inject.spi.AnnotatedMethod)1 AnnotatedParameter (jakarta.enterprise.inject.spi.AnnotatedParameter)1 AnnotatedType (jakarta.enterprise.inject.spi.AnnotatedType)1 BeanDescriptor (jakarta.validation.metadata.BeanDescriptor)1 Annotation (java.lang.annotation.Annotation)1 ElementType (java.lang.annotation.ElementType)1 Method (java.lang.reflect.Method)1 Type (java.lang.reflect.Type)1 ArrayList (java.util.ArrayList)1 Set (java.util.Set)1