
net.stickycode.metadata.MetadataResolverRegistry Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of sticky-metadata-api Show documentation
Show all versions of sticky-metadata-api Show documentation
Contract for querying metadata about types, methods and fields
package net.stickycode.metadata;
import java.lang.reflect.AnnotatedElement;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import net.stickycode.stereotype.StickyFramework;
/**
*
*
* Inject
* MetadataResolverRegisty usingMetadata;
*
* ...
*
* Field field = findField();
* if (withMetadata.is(field).metaAnnotatedWith(Configured.class)
* doSomethingWithAnnotatedField(field);
*
* ...
*
* Method method = fieldMethod();
* if (usingMetadata.is(method).metaAnnotatedWith(Scheduled.class)
* doSomethingWithAnnotatedMethod(method);
*
* ...
*
* Class> type = findType();
* if (usingMetadata.is(type).annotatedWith(StickRepository.class)
* doSomethingWithAnnoatedType(type);
*
* ...
*
* Class> type = findType();
* if (usingMetadata.does(type).haveAnyFieldsAnnotatedWith(Configured.class, ConfiguredStrategy.class)
* doSomethingWithTypeWithAnnotedElements();
*
* ...
*
* Class> type = findType();
* if (usingMetadata.does(type).haveAnyMethodsAnnotatedWith(Scheduled.class, Pulse.class)
* doSomethingWithTypeWithAnnotedElements();
*
*/
@StickyFramework
public interface MetadataResolverRegistry {
/**
* return a resolver for the given method that can resolve annotations on
*
* - the method itself
* - annotations on the method
*
*/
MetadataResolver is(Method method);
/**
* return a resolver for the given field that can resolve annotations on
*
* - the field itself
* - annotations on the field
*
*/
MetadataResolver is(Field field);
/**
* return a resolver for the given class that can resolve annotations on
*
* - the type itself
* - interfaces of the type
* - any of the supertypes
* - any of the interfaces of the super types
*
*/
MetadataResolver is(Class> annotatedClass);
/**
* return a resolver for the given class that can resolve annotations on
*
* - methods or fields of the type itself
* - methods or fileds of the interfaces of the type
* - methods or fields of any of the supertypes
* - methods or fields of any of the interfaces of the super types
*
*/
ElementMetadataResolver does(Class> type);
/**
* return a resolver for the given annotation element that can resolve annotations on
*
* - the element itself
* - any of the super elements
*
*/
MetadataResolver is(AnnotatedElement annotatedElement);
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy