Module proto4j.swing
Package org.proto4j.swing.core.handler
Class AbstractSwingHandler<A extends java.lang.annotation.Annotation>
java.lang.Object
org.proto4j.swing.core.handler.AbstractSwingHandler<A>
- Type Parameters:
A- the annotation type
- All Implemented Interfaces:
SwingHandler
- Direct Known Subclasses:
BasicOptionHandler,BoundsHandler,LayoutHandler,MarginHandler,ModelHandler,PositionHandler,WindowHandler
public abstract class AbstractSwingHandler<A extends java.lang.annotation.Annotation> extends java.lang.Object implements SwingHandler
This class provides a generic implementation of a
SwingHandler
class. The basic execution flow is the following:
- Check if the annotation is present (Exception on failure)
- Retrieve the
GenericDescthroughgetDesc(FieldReference, Annotation) - Add the description to the
ComponentDescstored in theFieldReference - Read the contents of the given annotation with
GenericDesc.read(Annotation) - Call
GenericDesc.applyTo(Component)with the linked component from theFieldReference
- Since:
- 1.0
- See Also:
GenericDesc
-
Field Summary
-
Constructor Summary
Constructors Constructor Description AbstractSwingHandler() -
Method Summary
Modifier and Type Method Description protected abstract GenericDesc<A>getDesc(FieldReference<?> reference, A value)Tries to create theGenericDescobject from the given reference and annotation value.voidonElement(FieldReference<?> reference, AnnotationContext<?> context)Handles the incomingFieldReferencewith itsComponentDescand the references field.
-
Constructor Details
-
AbstractSwingHandler
public AbstractSwingHandler()
-
-
Method Details
-
onElement
Handles the incomingFieldReferencewith itsComponentDescand the references field.INFO: This method makes use of the thread-safe class
FieldReferenceso that no external synchronization has to be done.- Specified by:
onElementin interfaceSwingHandler- Parameters:
reference- the field's referencecontext- the loaded annotation wrapped into anAnnotationContext
-
getDesc
Tries to create theGenericDescobject from the given reference and annotation value.- Parameters:
reference- theFieldReferenceobjectvalue- the annotation value- Returns:
- a qualified
GenericDescthat can read an annotation of type<A>
-