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
GenericDesc
throughgetDesc(FieldReference, Annotation)
- Add the description to the
ComponentDesc
stored 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 theGenericDesc
object from the given reference and annotation value.void
onElement(FieldReference<?> reference, AnnotationContext<?> context)
Handles the incomingFieldReference
with itsComponentDesc
and the references field.
-
Constructor Details
-
AbstractSwingHandler
public AbstractSwingHandler()
-
-
Method Details
-
onElement
Handles the incomingFieldReference
with itsComponentDesc
and the references field.INFO: This method makes use of the thread-safe class
FieldReference
so that no external synchronization has to be done.- Specified by:
onElement
in interfaceSwingHandler
- Parameters:
reference
- the field's referencecontext
- the loaded annotation wrapped into anAnnotationContext
-
getDesc
Tries to create theGenericDesc
object from the given reference and annotation value.- Parameters:
reference
- theFieldReference
objectvalue
- the annotation value- Returns:
- a qualified
GenericDesc
that can read an annotation of type<A>
-