T - the type of objects produced by the builderpublic class ObjectBuilderFactory<T> extends Object implements AnnotationProcessor
This factory creates builder for a particular type of object. All implementations of this type must be annotated with a specified annotation to be detected over the classpath.
| Modifier and Type | Class and Description |
|---|---|
class |
ObjectBuilderFactory.KnownType
Data object that provides a detected service and the type name that identifies its builder.
|
| Constructor and Description |
|---|
ObjectBuilderFactory(Class<? extends Annotation> annotationToScan,
Class<? extends T>... classes)
Builds a new instance.
|
ObjectBuilderFactory(Class<? extends Annotation> annotationToScan,
String packageToScan)
Builds a new instance.
|
| Modifier and Type | Method and Description |
|---|---|
ObjectBuilder<T> |
create(String type)
Creates a builder for the given type.
|
void |
handle(Class<?> annotatedType)
Handles a type annotated with the required annotation.
|
ObjectBuilderFactory<T> |
inspector(ObjectBuilderInspector i)
Adds an inspector.
|
List<ObjectBuilderFactory.KnownType> |
knownTypes()
Returns all the supported types.
|
Class<? extends Annotation> |
requiredAnnotation()
The annotation that must be detected on type to be handled.
|
public ObjectBuilderFactory(Class<? extends Annotation> annotationToScan, String packageToScan)
Builds a new instance.
annotationToScan - the annotation to discoverpackageToScan - the package to scanpublic ObjectBuilderFactory(Class<? extends Annotation> annotationToScan, Class<? extends T>... classes)
Builds a new instance.
annotationToScan - the annotation to discoverclasses - a list of classes to directly scan instead of discovering types by scanning classpathpublic ObjectBuilderFactory<T> inspector(ObjectBuilderInspector i)
Adds an inspector.
i - the inspectorpublic List<ObjectBuilderFactory.KnownType> knownTypes()
Returns all the supported types.
public Class<? extends Annotation> requiredAnnotation()
The annotation that must be detected on type to be handled.
requiredAnnotation in interface AnnotationProcessorpublic final void handle(Class<?> annotatedType)
Handles a type annotated with the required annotation.
handle in interface AnnotationProcessorannotatedType - the annotated typepublic ObjectBuilder<T> create(String type)
Creates a builder for the given type. The type is the simple name of the class produced by the builder.
All supported type are detected during classpath scanning. If a type could not be registered, the
cause is logged and when retrieved with this method, null will be returned.
Throws an IllegalArgumentException if the there is a bad usage of annotation or if the type is unknown
type - the type created by the builderCopyright © 2012-2015. All Rights Reserved.