Class ComponentDesc

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
    protected ComponentDesc​(java.lang.reflect.AnnotatedElement field, java.lang.Object parent)
    Creates a new ComponentDesc from the given annotated element and the parent instance.
  • Method Summary

    Modifier and Type Method Description
    abstract <A extends java.lang.annotation.Annotation>
    void
    addIfAbsent​(GenericDesc<A> desc)
    Inserts the given generic description with the linked annotation type if not already mapped.
    static ComponentDesc createDesc​(java.lang.reflect.AnnotatedElement field, java.lang.Object root)
    Returns the default instance for component descriptions.
    abstract <A extends java.lang.annotation.Annotation>
    boolean
    describable​(java.lang.Class<A> cls)
    Checks if this ComponentDesc contains an OptionDesc linked to the given Annotation class.
    java.lang.Class<?> getComponentType()  
    abstract <A extends java.lang.annotation.Annotation>
    GenericDesc<A>
    getDesc​(java.lang.Class<A> cls)
    Retrieves the current GenericDesc for the given annotation type of null if none was specified yet.
    java.lang.reflect.AnnotatedElement getField()  
    java.lang.String getFieldName()  
    java.lang.Object getInstance()  
    void setInstance​(java.lang.Object value)
    Applies a new value to the referenced component.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • ComponentDesc

      protected ComponentDesc​(java.lang.reflect.AnnotatedElement field, java.lang.Object parent)
      Creates a new ComponentDesc from the given annotated element and the parent instance.
      Parameters:
      field - the annotated element
      parent - the GUI's instance
  • Method Details

    • createDesc

      public static ComponentDesc createDesc​(java.lang.reflect.AnnotatedElement field, java.lang.Object root) throws java.lang.NullPointerException
      Returns the default instance for component descriptions. The used class is: OrderedArrayListComponentDesc. This implementation of the ComponentDesc provides a concurrent approach for retrieving the stored values.
      Parameters:
      field - the source
      root - the GUI's instance
      Returns:
      a new ComponentDesc object
      Throws:
      java.lang.NullPointerException - if one of the given arguments was null
    • describable

      public abstract <A extends java.lang.annotation.Annotation> boolean describable​(java.lang.Class<A> cls) throws java.lang.NullPointerException
      Checks if this ComponentDesc contains an OptionDesc linked to the given Annotation class.
      Type Parameters:
      A - the bound annotation type
      Parameters:
      cls - the annotation class
      Returns:
      true if this ComponentDesc can describe an OptionDesc to the given annotation type
      Throws:
      java.lang.NullPointerException - if the given annotation class is null
    • addIfAbsent

      public abstract <A extends java.lang.annotation.Annotation> void addIfAbsent​(GenericDesc<A> desc) throws java.lang.NullPointerException
      Inserts 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 is null
    • getDesc

      public abstract <A extends java.lang.annotation.Annotation> GenericDesc<A> getDesc​(java.lang.Class<A> cls) throws java.lang.NullPointerException
      Retrieves the current GenericDesc for the given annotation type of null if none was specified yet.
      Type Parameters:
      A - the annotation type
      Parameters:
      cls - the annotation class
      Returns:
      the current GenericDesc for the given annotation type of null if none was specified yet.
      Throws:
      java.lang.NullPointerException - if the given class was null
    • 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