Module proto4j.swing
Package org.proto4j.swing.core.desc
Class GenericDesc<A extends java.lang.annotation.Annotation>
java.lang.Object
org.proto4j.swing.core.desc.GenericDesc<A>
- Type Parameters:
A- the annotation type
- Direct Known Subclasses:
BoundsDesc,LayoutDesc,MarginDesc,ModelDesc,OptionDesc,PositionDesc,WindowDesc
public abstract class GenericDesc<A extends java.lang.annotation.Annotation>
extends java.lang.Object
The base class for all option related descriptions.
This class is used to be the base for all attribute descriptions and their implementations. It is bound to an annotation type in order to make it easier to filter them in a list (concurrency).
-
Field Summary
Fields Modifier and Type Field Description static intINVALID_INTA simple constant specifying whether the option is valid.static java.lang.StringUNDEFINEDA simple property descriptor indicating that a property wasn't found. -
Constructor Summary
Constructors Modifier Constructor Description protectedGenericDesc(java.lang.Class<A> cls)Creates a newGenericDescfrom the given annotation class. -
Method Summary
Modifier and Type Method Description java.lang.Class<A>annotationType()abstract voidapplyTo(java.awt.Component component)Applies the stored options on the given component.java.lang.Objectget(java.lang.String key)Returns the value to which the specified key is mapped, or null if this description contains no mapping for the key.java.util.PropertiesgetDefinedOptions()<R> RgetOption(java.lang.String key, java.lang.Class<R> cls)Returns the value to which the specified key is mapped, or null if this description contains no mapping for the key and casts it to the given format.booleanhasOption(java.lang.String key)Tests if the specified object is a key in this description.java.util.Set<java.lang.Object>keys()Returns a Set view of the keys contained in thisGenericDesc.voidput(java.lang.String key, java.lang.Object value)If the specified key is not already associated with a value (or is mapped to null) associates it with the given value.voidread(A value)Tries to insert all attributes provided by the givenAnnotationobject.voidread(GenericDesc<A> desc)Tries to insert all attributes provided by the givenGenericDescobject.
-
Field Details
-
UNDEFINED
public static final java.lang.String UNDEFINEDA simple property descriptor indicating that a property wasn't found.- Since:
- 1.1.0
- See Also:
- Constant Field Values
-
INVALID_INT
public static final int INVALID_INTA simple constant specifying whether the option is valid.- Since:
- 1.1.0
- See Also:
- Constant Field Values
-
-
Constructor Details
-
GenericDesc
Creates a newGenericDescfrom the given annotation class.- Parameters:
cls- the annotation class- Throws:
java.lang.NullPointerException- if the given annotation class isnull
-
-
Method Details
-
applyTo
public abstract void applyTo(java.awt.Component component)Applies the stored options on the given component.- Parameters:
component- theComponentreference
-
annotationType
- Returns:
- The annotation type this description is bound to.
-
get
public java.lang.Object get(java.lang.String key)Returns the value to which the specified key is mapped, or null if this description contains no mapping for the key.- Parameters:
key- the option's name- Returns:
- the value to which the specified key is mapped, or null if this description contain no mapping for the key
-
put
public void put(java.lang.String key, java.lang.Object value)If the specified key is not already associated with a value (or is mapped to null) associates it with the given value.- Parameters:
key- the option's namevalue- the option's value
-
getOption
public <R> R getOption(java.lang.String key, java.lang.Class<R> cls) throws java.lang.NullPointerException, java.lang.ClassCastExceptionReturns the value to which the specified key is mapped, or null if this description contains no mapping for the key and casts it to the given format.- Type Parameters:
R- the return type- Parameters:
key- the option's namecls- the type's class- Returns:
- the value to which the specified key is mapped, or null if this description contain no mapping for the key
- Throws:
java.lang.NullPointerException- if any of the provided arguments isnulljava.lang.ClassCastException- if an error is thrown during the object casting
-
hasOption
public boolean hasOption(java.lang.String key)Tests if the specified object is a key in this description.- Parameters:
key- the option's name- Returns:
- true if and only if the specified object is a key in this description object; false otherwise.
-
read
Tries to insert all attributes provided by the givenAnnotationobject.- Parameters:
value- the annotation instance
-
read
Tries to insert all attributes provided by the givenGenericDescobject.- Parameters:
desc- the parent description- Throws:
java.lang.NullPointerException
-
keys
public java.util.Set<java.lang.Object> keys()Returns a Set view of the keys contained in thisGenericDesc.- Returns:
- a Set view of the keys contained in this
GenericDesc.
-
getDefinedOptions
public java.util.Properties getDefinedOptions()- Returns:
- the defined option namespace for this description
-