org.jboss.weld.annotated.enhanced.EnhancedAnnotatedType Maven / Gradle / Ivy
/*
* JBoss, Home of Professional Open Source
* Copyright 2008, Red Hat, Inc., and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jboss.weld.annotated.enhanced;
import java.lang.annotation.Annotation;
import java.lang.reflect.Method;
import java.util.Collection;
import javax.enterprise.inject.spi.AnnotatedType;
import org.jboss.weld.annotated.slim.SlimAnnotatedType;
/**
* Represents a Class
*
* @author Pete Muir
*/
public interface EnhancedAnnotatedType extends EnhancedAnnotated>, AnnotatedType {
/**
* Gets all fields on the type
*
* @return A set of abstracted fields
*/
Collection> getEnhancedFields();
/**
* Gets all methods on the type including those declared on a superclass of {@link #getJavaClass()}. Overridden methods are not returned.
*
* @return A set of abstracted methods
*/
Collection> getEnhancedMethods();
/**
* Gets all methods on the type
*
* @return A set of abstracted methods
*/
Collection> getDeclaredEnhancedMethods();
/**
* Get a field by name
*
* @param the expected type of the field
* @param fieldName the field name
* @return the field
*/
EnhancedAnnotatedField getDeclaredEnhancedField(String fieldName);
/**
* Gets all fields which are annotated with the given annotation type on this
* class and all super classes
*
* @param annotationType The annotation to match
* @return A set of abstracted fields with the given annotation. Returns an
* empty set if there are no matches
*/
Collection> getEnhancedFields(Class annotationType);
/**
* Gets all fields declared on this class only.
*
* @return A set of abstracted fields. Returns an
* empty set if there are no matches
*/
Collection> getDeclaredEnhancedFields();
/**
* Gets all fields which are annotated with the given annotation type on this
* class only.
*
* @param annotationType The annotation to match
* @return A set of abstracted fields with the given annotation. Returns an
* empty set if there are no matches
*/
Collection> getDeclaredEnhancedFields(Class annotationType);
/**
* Gets all constructors
*/
Collection> getEnhancedConstructors();
/**
* Gets all constructors which are annotated with annotationType
*
* @param annotationType The annotation type to match
* @return A set of abstracted fields with the given annotation. Returns an
* empty set if there are no matches
*/
Collection> getEnhancedConstructors(Class annotationType);
/**
* Gets the no-args constructor
*
* @return The no-args constructor, or null if not defined
*/
EnhancedAnnotatedConstructor getNoArgsEnhancedConstructor();
/**
* Get the constructor which matches the argument list provided
*
* @param parameterTypes the parameters of the constructor
* @return the matching constructor, or null if not defined
*/
EnhancedAnnotatedConstructor getDeclaredEnhancedConstructor(ConstructorSignature signature);
/**
* Gets all methods annotated with annotationType including those declared on a superclass of {@link #getJavaClass()}. Overridden methods are not returned.
*
* @param annotationType The annotation to match
* @return A set of abstracted methods with the given annotation. Returns an
* empty set if there are no matches
*/
Collection> getEnhancedMethods(Class annotationType);
/**
* Gets all methods annotated with annotationType
*
* @param annotationType The annotation to match
* @return A set of abstracted methods with the given annotation. Returns an
* empty set if there are no matches
*/
Collection> getDeclaredEnhancedMethods(Class annotationType);
/**
* Find the annotated method for a given methodDescriptor
*
* @param methodDescriptor
* @return
*/
// TODO replace with MethodSignature variant
@Deprecated
EnhancedAnnotatedMethod getEnhancedMethod(Method method);
/**
* Get a method by name
*
* @param the expected return type
* @param signature the name of the method
* @return the method, or null if it doesn't exist
*/
EnhancedAnnotatedMethod getDeclaredEnhancedMethod(MethodSignature signature);
/**
* Get a method by name
*
* @param the expected return type
* @param signature the name of the method
* @return the method, or null if it doesn't exist
*/
EnhancedAnnotatedMethod getEnhancedMethod(MethodSignature signature);
// TODO Replace with MethodSignature variant
@Deprecated
EnhancedAnnotatedMethod getDeclaredEnhancedMethod(Method method);
/**
* Gets declared with parameters annotated with annotationType
*
* @param annotationType The annotation to match
* @return A set of abstracted methods with the given annotation. Returns an
* empty set if there are no matches
*/
Collection> getDeclaredEnhancedMethodsWithAnnotatedParameters(Class annotationType);
/**
* Gets all methods with parameters annotated with annotationType including those declared on a superclass of {@link #getJavaClass()}. Overridden methods are not returned.
*
* @param annotationType The annotation to match
* @return A set of abstracted methods with the given annotation. Returns an
* empty set if there are no matches
*/
Collection> getEnhancedMethodsWithAnnotatedParameters(Class annotationType);
/**
* Gets the superclass.
*
* @return The abstracted superclass, null if there is no superclass
*/
EnhancedAnnotatedType getEnhancedSuperclass();
boolean isParameterizedType();
boolean isAbstract();
boolean isEnum();
boolean isMemberClass();
boolean isLocalClass();
boolean isAnonymousClass();
boolean isSerializable();
boolean isDiscovered();
S cast(Object object);
EnhancedAnnotatedType asEnhancedSubclass(EnhancedAnnotatedType clazz);
/**
* Check if this is equivalent to a java class
*
* @param clazz The Java class
* @return true if equivalent
*/
boolean isEquivalent(Class clazz);
String getSimpleName();
/**
* Gets all annotations which are declared on this annotated item with the
* given meta annotation type
*
* @param The meta annotation to match
* @return A set of matching meta-annotations. Returns an empty set if there
* are no matches.
*/
Collection getDeclaredMetaAnnotations(Class metaAnnotationType);
/**
* Returns a lightweight implementation of {@link AnnotatedType} with minimal memory footprint.
* @return the slim version of this {@link AnnotatedType}
*/
SlimAnnotatedType slim();
}