Search in sources :

Example 1 with AnnotatedCallable

use of javax.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(javax.enterprise.inject.spi.AnnotatedMethod) AnnotatedParameter(javax.enterprise.inject.spi.AnnotatedParameter) ArrayList(java.util.ArrayList) AnnotatedCallable(javax.enterprise.inject.spi.AnnotatedCallable) AnnotatedConstructor(javax.enterprise.inject.spi.AnnotatedConstructor) HashSet(java.util.HashSet) Method(java.lang.reflect.Method) AnnotatedMethod(javax.enterprise.inject.spi.AnnotatedMethod) Annotation(java.lang.annotation.Annotation) AnnotatedType(javax.enterprise.inject.spi.AnnotatedType) Type(java.lang.reflect.Type) AnnotatedType(javax.enterprise.inject.spi.AnnotatedType) AnnotatedField(javax.enterprise.inject.spi.AnnotatedField)

Aggregations

Annotation (java.lang.annotation.Annotation)1 Method (java.lang.reflect.Method)1 Type (java.lang.reflect.Type)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 Set (java.util.Set)1 AnnotatedCallable (javax.enterprise.inject.spi.AnnotatedCallable)1 AnnotatedConstructor (javax.enterprise.inject.spi.AnnotatedConstructor)1 AnnotatedField (javax.enterprise.inject.spi.AnnotatedField)1 AnnotatedMethod (javax.enterprise.inject.spi.AnnotatedMethod)1 AnnotatedParameter (javax.enterprise.inject.spi.AnnotatedParameter)1 AnnotatedType (javax.enterprise.inject.spi.AnnotatedType)1