public abstract class AbstractPropertyEditor<D extends BioPAXElement,R> extends SimplePropertyAccessor<D,R> implements PropertyEditor<D,R>
Modifier and Type | Field and Description |
---|---|
protected Method |
addMethod
This variable stores the method to invoke for adding the given value to the property managed by
this commander.
|
static ThreadLocal<Boolean> |
checkRestrictions |
protected static org.apache.commons.logging.Log |
log |
protected String |
property
Local OWL name of the property
|
protected Method |
removeMethod
This variable stores the method for removing the value of the property on a given bean.
|
protected Method |
setMethod
This variable stores the method to invoke for setting a property to the to the given value.
|
getMethod
domain, multipleCardinality, range
Constructor and Description |
---|
AbstractPropertyEditor(String property,
Method getMethod,
Class<D> domain,
Class<R> range,
boolean multipleCardinality)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
addMaxCardinalityRestriction(Class<? extends D> domain,
int max)
Sets a maximum cardinality for a domain.
|
protected void |
checkRestrictions(R value,
D bean)
Checks if the bean and the value are consistent with the cardinality rules of
the model.
|
static <D extends BioPAXElement,R> |
createPropertyEditor(Class<D> domain,
String property)
This method creates a property reflecting on the domain and property.
|
protected static Class |
detectRange(Method getMethod)
Given the multiple cardinality feature, the range of the get method is returned.
|
Method |
getAddMethod() |
Method |
getGetMethod() |
Integer |
getMaxCardinality(Class<? extends D> restrictedDomain)
Return the maximum cardinality that is defined for the property to which editor is belong.
|
Method |
getPrimarySetMethod()
Returns the primary set method of the editor.
|
String |
getProperty() |
Method |
getRemoveMethod() |
Method |
getSetMethod() |
R |
getUnknown()
Gets the unknown value.
|
protected void |
invokeMethod(Method method,
D bean,
R value)
Calls the method onto bean with the value as its parameter.
|
protected boolean |
isInstanceOfAtLeastOne(Set<Class<? extends BioPAXElement>> classes,
Object value)
Checks if value is an instance of one of the classes given in a set.
|
protected R |
parseValueFromString(String value) |
void |
removeValueFromBean(R value,
D bean)
Removes the value from the bean using the default removeMethod,
if such method is defined (i.e., it's a multiple cardinality property),
otherwise sets unknown value using
PropertyEditor.setValueToBean(Object, org.biopax.paxtools.model.BioPAXElement)
(but only if ) |
void |
removeValueFromBean(Set<R> values,
D bean)
Removes the values from the bean
using the
PropertyEditor.removeValueFromBean(Object, org.biopax.paxtools.model.BioPAXElement)
for each value in the set. |
void |
setValueToBean(R value,
D bean)
Sets the value to the bean using the default setMethod if
value is not null.
|
void |
setValueToBean(Set<R> values,
D bean) |
String |
toString() |
getValueFromBean, isMultipleCardinality, isUnknown
getDomain, getRange, getValueFromBeans, isMultipleCardinality
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getDomain, getRange, getValueFromBean, getValueFromBeans, isMultipleCardinality, isUnknown
protected static final org.apache.commons.logging.Log log
protected Method setMethod
multiple cardinality
, the returned method is expected to have a
Set
as its only parameter.protected Method addMethod
PropertyAccessorAdapter.range
as its only parameter, otherwise expected to be null.protected Method removeMethod
PropertyAccessorAdapter.range
as its only
parameter, otherwise expected to be nullpublic static ThreadLocal<Boolean> checkRestrictions
public AbstractPropertyEditor(String property, Method getMethod, Class<D> domain, Class<R> range, boolean multipleCardinality)
property
- biopax property namegetMethod
- getterdomain
- class the property belongs torange
- property values type/classmultipleCardinality
- whether more than one value is allowedpublic String toString()
toString
in interface PropertyEditor<D extends BioPAXElement,R>
toString
in class SimplePropertyAccessor<D extends BioPAXElement,R>
public static <D extends BioPAXElement,R> PropertyEditor<D,R> createPropertyEditor(Class<D> domain, String property)
D
- domainR
- rangedomain
- paxtools level2 interface that maps to the corresponding owl level2.property
- to be managed by the constructed controller.protected static Class detectRange(Method getMethod)
getMethod
- default methodpublic Method getAddMethod()
getAddMethod
in interface PropertyEditor<D extends BioPAXElement,R>
public Method getGetMethod()
getGetMethod
in interface PropertyEditor<D extends BioPAXElement,R>
public String getProperty()
getProperty
in interface PropertyEditor<D extends BioPAXElement,R>
public Method getRemoveMethod()
getRemoveMethod
in interface PropertyEditor<D extends BioPAXElement,R>
public Method getSetMethod()
getSetMethod
in interface PropertyEditor<D extends BioPAXElement,R>
public void addMaxCardinalityRestriction(Class<? extends D> domain, int max)
PropertyEditor
addMaxCardinalityRestriction
in interface PropertyEditor<D extends BioPAXElement,R>
domain
- domain on which restriction will be setmax
- cardinalityPropertyAccessor.isMultipleCardinality()
public Integer getMaxCardinality(Class<? extends D> restrictedDomain)
PropertyEditor
getMaxCardinality
in interface PropertyEditor<D extends BioPAXElement,R>
restrictedDomain
- domain to be checked for the cardinalityprotected boolean isInstanceOfAtLeastOne(Set<Class<? extends BioPAXElement>> classes, Object value)
classes
- a set of classes to be checkedvalue
- value whose class will be checkedpublic R getUnknown()
PropertyEditor
BioPAXElement.UNKNOWN_FLOAT
)getUnknown
in interface PropertyEditor<D extends BioPAXElement,R>
public void removeValueFromBean(R value, D bean)
PropertyEditor
PropertyEditor.setValueToBean(Object, org.biopax.paxtools.model.BioPAXElement)
(but only if )removeValueFromBean
in interface PropertyEditor<D extends BioPAXElement,R>
value
- to be removed from the beanbean
- bean from which the value is going to be removedpublic void removeValueFromBean(Set<R> values, D bean)
PropertyEditor
PropertyEditor.removeValueFromBean(Object, org.biopax.paxtools.model.BioPAXElement)
for each value in the set.removeValueFromBean
in interface PropertyEditor<D extends BioPAXElement,R>
values
- to be removed from the beanbean
- bean from which the value is going to be removedprotected void invokeMethod(Method method, D bean, R value)
method
- method that is going to be calledbean
- bean onto which the method is going to be appliedvalue
- the value which is going to be used by methodprotected R parseValueFromString(String value)
public void setValueToBean(R value, D bean)
PropertyEditor
setValueToBean
in interface PropertyEditor<D extends BioPAXElement,R>
value
- to be set to the beanbean
- to which the value is to be setpublic void setValueToBean(Set<R> values, D bean)
setValueToBean
in interface PropertyEditor<D extends BioPAXElement,R>
protected void checkRestrictions(R value, D bean)
value
- Value that is related to the objectbean
- Object that is related to the valuepublic Method getPrimarySetMethod()
PropertyEditor
getPrimarySetMethod
in interface PropertyEditor<D extends BioPAXElement,R>
Copyright © 2015 BioPAX. All rights reserved.