Package org.opt4j.config
Class Property
- java.lang.Object
-
- org.opt4j.config.Property
-
public class Property extends Object
ThePropertycontains information about a single property of aPropertyModule.
-
-
Field Summary
Fields Modifier and Type Field Description protected Map<Class<? extends Annotation>,Annotation>annotationsprotected Methodgetterprotected Stringinfoprotected com.google.inject.Modulemoduleprotected Stringnameprotected intorderprotected Collection<Requirement>requirementsprotected Methodsetterprotected Class<?>type
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddRequirement(Requirement requirement)Adds aRequirement.<A extends Annotation>
AgetAnnotation(Class<? extends A> clazz)Returns the annotation of the specified class or null if not existent.Collection<Annotation>getAnnotations()Returns the annotations of this property.MethodgetGetter()Returns the getter method.StringgetInfo()Returns the info.StringgetName()Returns the name.intgetOrder()Returns the order.Collection<Requirement>getRequirements()Returns the requirements.MethodgetSetter()Returns the setter method.Class<?>getType()Returns the type.ObjectgetValue()Returns the value of the property.booleanisActive()Returnstrueif the property is active.booleanisNumber()Returnstrueif the property represents a number.voidsetInfo(String info)Sets the info.voidsetOrder(int order)Sets the order.voidsetValue(Object value)Sets the value of the property.voidsetValue(String value)Sets the value of the property.protected voidsetValueObject(Object value)Sets the value of the property.
-
-
-
Field Detail
-
module
protected final com.google.inject.Module module
-
name
protected final String name
-
type
protected final Class<?> type
-
getter
protected final Method getter
-
setter
protected final Method setter
-
info
protected String info
-
order
protected int order
-
requirements
protected final Collection<Requirement> requirements
-
annotations
protected final Map<Class<? extends Annotation>,Annotation> annotations
-
-
Constructor Detail
-
Property
public Property(com.google.inject.Module module, String name, Class<?> type, Method getter, Method setter, Iterable<Annotation> annotations)Constructs aProperty.- Parameters:
module- the modulename- the nametype- the typegetter- the getter methodsetter- the setter methodannotations- the annotations
-
-
Method Detail
-
getInfo
public String getInfo()
Returns the info.- Returns:
- the info
- See Also:
setInfo(java.lang.String)
-
setInfo
public void setInfo(String info)
Sets the info.- Parameters:
info- the info to set- See Also:
getInfo()
-
getOrder
public int getOrder()
Returns the order.- Returns:
- the order
- See Also:
setOrder(int)
-
setOrder
public void setOrder(int order)
Sets the order.- Parameters:
order- the order to set- See Also:
getOrder()
-
getName
public String getName()
Returns the name.- Returns:
- the name
-
getType
public Class<?> getType()
Returns the type.- Returns:
- the type
-
getGetter
public Method getGetter()
Returns the getter method.- Returns:
- the getter
-
getSetter
public Method getSetter()
Returns the setter method.- Returns:
- the setter
-
addRequirement
public void addRequirement(Requirement requirement)
Adds aRequirement.- Parameters:
requirement- the requirement to add
-
isActive
public boolean isActive()
Returnstrueif the property is active.- Returns:
trueif the property is active
-
getRequirements
public Collection<Requirement> getRequirements()
Returns the requirements.- Returns:
- the requirements
-
getValue
public Object getValue()
Returns the value of the property.- Returns:
- the value of the property
- See Also:
setValue(java.lang.Object)
-
setValue
public void setValue(Object value) throws InvocationTargetException
Sets the value of the property.- Parameters:
value- the value to set- Throws:
InvocationTargetException- thrown if the value cannot be assigned- See Also:
getValue()
-
setValue
public void setValue(String value) throws InvocationTargetException
Sets the value of the property. The property has first to be converted to a the corresponding type.- Parameters:
value- the value to set- Throws:
InvocationTargetException- thrown if the value cannot be assigned
-
isNumber
public boolean isNumber()
Returnstrueif the property represents a number.- Returns:
trueif the property represents a number
-
setValueObject
protected void setValueObject(Object value) throws InvocationTargetException
Sets the value of the property.- Parameters:
value- the value to set- Throws:
InvocationTargetException- thrown if the value cannot be assigned
-
getAnnotations
public Collection<Annotation> getAnnotations()
Returns the annotations of this property.- Returns:
- the annotations
-
getAnnotation
public <A extends Annotation> A getAnnotation(Class<? extends A> clazz)
Returns the annotation of the specified class or null if not existent.- Type Parameters:
A- the annotation type- Parameters:
clazz- the specific annotation class- Returns:
- the annotation
-
-