java.lang.Object
org.proto4j.swing.core.desc.ComponentDesc
public abstract class ComponentDesc
extends java.lang.Object
This class provides basic features of
Component descriptions,
to minimize the effort required to implement inheritors.
This class is used within the generation of the GUI. It represents the annotated component together with its declared properties.
- Since:
- 1.0
-
Constructor Summary
Constructors Modifier Constructor Description protectedComponentDesc(java.lang.reflect.AnnotatedElement field, java.lang.Object parent)Creates a newComponentDescfrom the given annotated element and the parent instance. -
Method Summary
Modifier and Type Method Description abstract <A extends java.lang.annotation.Annotation>
voidaddIfAbsent(GenericDesc<A> desc)Inserts the given generic description with the linked annotation type if not already mapped.static ComponentDesccreateDesc(java.lang.reflect.AnnotatedElement field, java.lang.Object root)Returns the default instance for component descriptions.abstract <A extends java.lang.annotation.Annotation>
booleandescribable(java.lang.Class<A> cls)java.lang.Class<?>getComponentType()abstract <A extends java.lang.annotation.Annotation>
GenericDesc<A>getDesc(java.lang.Class<A> cls)Retrieves the currentGenericDescfor the given annotation type ofnullif none was specified yet.java.lang.reflect.AnnotatedElementgetField()java.lang.StringgetFieldName()java.lang.ObjectgetInstance()voidsetInstance(java.lang.Object value)Applies a new value to the referenced component.
-
Constructor Details
-
ComponentDesc
protected ComponentDesc(java.lang.reflect.AnnotatedElement field, java.lang.Object parent)Creates a newComponentDescfrom the given annotated element and the parent instance.- Parameters:
field- the annotated elementparent- the GUI's instance
-
-
Method Details
-
createDesc
public static ComponentDesc createDesc(java.lang.reflect.AnnotatedElement field, java.lang.Object root) throws java.lang.NullPointerExceptionReturns the default instance for component descriptions. The used class is:OrderedArrayListComponentDesc. This implementation of theComponentDescprovides a concurrent approach for retrieving the stored values.- Parameters:
field- the sourceroot- the GUI's instance- Returns:
- a new
ComponentDescobject - Throws:
java.lang.NullPointerException- if one of the given arguments wasnull
-
describable
public abstract <A extends java.lang.annotation.Annotation> boolean describable(java.lang.Class<A> cls) throws java.lang.NullPointerException- Type Parameters:
A- the bound annotation type- Parameters:
cls- the annotation class- Returns:
trueif thisComponentDesccan describe anOptionDescto the given annotation type- Throws:
java.lang.NullPointerException- if the given annotation class isnull
-
addIfAbsent
public abstract <A extends java.lang.annotation.Annotation> void addIfAbsent(GenericDesc<A> desc) throws java.lang.NullPointerExceptionInserts the given generic description with the linked annotation type if not already mapped.- Type Parameters:
A- the linked annotation type- Parameters:
desc- the option description- Throws:
java.lang.NullPointerException- if the option description isnull
-
getDesc
public abstract <A extends java.lang.annotation.Annotation> GenericDesc<A> getDesc(java.lang.Class<A> cls) throws java.lang.NullPointerExceptionRetrieves the currentGenericDescfor the given annotation type ofnullif none was specified yet.- Type Parameters:
A- the annotation type- Parameters:
cls- the annotation class- Returns:
- the current
GenericDescfor the given annotation type ofnullif none was specified yet. - Throws:
java.lang.NullPointerException- if the given class wasnull
-
getField
public java.lang.reflect.AnnotatedElement getField()- Returns:
- the referenced
AnnotatedElement.
-
getFieldName
public java.lang.String getFieldName()- Returns:
- The referenced annotated element's name
-
getComponentType
public java.lang.Class<?> getComponentType()- Returns:
- The type of the stored
Component.
-
getInstance
public java.lang.Object getInstance()- Returns:
- the component instance for this description
-
setInstance
public void setInstance(java.lang.Object value)Applies a new value to the referenced component.- Parameters:
value- the new component value
-