Package org.biopax.paxtools.controller
Class AbstractPropertyEditor<D extends BioPAXElement,R>
java.lang.Object
org.biopax.paxtools.controller.PropertyAccessorAdapter<D,R>
org.biopax.paxtools.controller.SimplePropertyAccessor<D,R>
org.biopax.paxtools.controller.AbstractPropertyEditor<D,R>
- All Implemented Interfaces:
PropertyAccessor<D,,R> PropertyEditor<D,R>
- Direct Known Subclasses:
EnumeratedPropertyEditor,ObjectPropertyEditor,PrimitivePropertyEditor,StringPropertyEditor
public abstract class AbstractPropertyEditor<D extends BioPAXElement,R>
extends SimplePropertyAccessor<D,R>
implements PropertyEditor<D,R>
This is the base class for all property editors. Each property controller is responsible for
manipulating a certain property for a given class of objects (domain).
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected MethodThis variable stores the method to invoke for adding the given value to the property managed by this commander.static ThreadLocal<Boolean>protected static final org.slf4j.Loggerprotected final StringLocal OWL name of the propertyprotected MethodThis variable stores the method for removing the value of the property on a given bean.protected MethodThis variable stores the method to invoke for setting a property to the to the given value.Fields inherited from class org.biopax.paxtools.controller.SimplePropertyAccessor
getMethodFields inherited from class org.biopax.paxtools.controller.PropertyAccessorAdapter
domain, multipleCardinality, range -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddMaxCardinalityRestriction(Class<? extends D> domain, int max) Sets a maximum cardinality for a domain.protected voidcheckRestrictions(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>
PropertyEditor<D,R> createPropertyEditor(Class<D> domain, String property) This method creates a property reflecting on the domain and property.protected static ClassdetectRange(Method getMethod) Given the multiple cardinality feature, the range of the get method is returned.getMaxCardinality(Class<? extends D> restrictedDomain) Return the maximum cardinality that is defined for the property to which editor is belong.Returns the primary set method of the editor.Gets the unknown value.protected voidinvokeMethod(Method method, D bean, R value) Calls the method onto bean with the value as its parameter.protected booleanisInstanceOfAtLeastOne(Set<Class<? extends BioPAXElement>> classes, Object value) Checks if value is an instance of one of the classes given in a set.protected RparseValueFromString(String value) voidremoveValueFromBean(Set<R> values, D bean) Removes the values from the bean using thePropertyEditor.removeValueFromBean(Object, org.biopax.paxtools.model.BioPAXElement)for each value in the set.voidremoveValueFromBean(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 usingPropertyEditor.setValueToBean(Object, org.biopax.paxtools.model.BioPAXElement)(but only if )voidsetValueToBean(Set<R> values, D bean) voidsetValueToBean(R value, D bean) Sets the value to the bean using the default setMethod if value is not null.toString()Methods inherited from class org.biopax.paxtools.controller.SimplePropertyAccessor
getValueFromBean, isMultipleCardinality, isUnknownMethods inherited from class org.biopax.paxtools.controller.PropertyAccessorAdapter
getDomain, getRange, getValueFromBeans, isMultipleCardinalityMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.biopax.paxtools.controller.PropertyAccessor
getDomain, getRange, getValueFromBean, getValueFromBeans, isMultipleCardinality, isUnknown
-
Field Details
-
log
protected static final org.slf4j.Logger log -
setMethod
This variable stores the method to invoke for setting a property to the to the given value. Ifmultiple cardinality, the returned method is expected to have aSetas its only parameter. -
addMethod
This variable stores the method to invoke for adding the given value to the property managed by this commander. In the case of multiple cardinality, the method is expected to have aPropertyAccessorAdapter.rangeas its only parameter, otherwise expected to be null. -
removeMethod
This variable stores the method for removing the value of the property on a given bean. In the case of multiple cardinality, this method is expected to have aPropertyAccessorAdapter.rangeas its only parameter, otherwise expected to be null -
property
Local OWL name of the property -
checkRestrictions
-
-
Constructor Details
-
AbstractPropertyEditor
public AbstractPropertyEditor(String property, Method getMethod, Class<D> domain, Class<R> range, boolean multipleCardinality) Constructor.- Parameters:
property- biopax property namegetMethod- getterdomain- class the property belongs torange- property values type/classmultipleCardinality- whether more than one value is allowed
-
-
Method Details
-
toString
- Specified by:
toStringin interfacePropertyEditor<D extends BioPAXElement,R> - Overrides:
toStringin classSimplePropertyAccessor<D extends BioPAXElement,R>
-
createPropertyEditor
public static <D extends BioPAXElement,R> PropertyEditor<D,R> createPropertyEditor(Class<D> domain, String property) This method creates a property reflecting on the domain and property. Proper subclass is chosen based on the range of the property.- Type Parameters:
D- domainR- range- Parameters:
domain- paxtools level2 interface that maps to the corresponding owl level2.property- to be managed by the constructed controller.- Returns:
- a property controller to manipulate the beans for the given property.
-
detectRange
Given the multiple cardinality feature, the range of the get method is returned.- Parameters:
getMethod- default method- Returns:
- the range as a class
-
getAddMethod
- Specified by:
getAddMethodin interfacePropertyEditor<D extends BioPAXElement,R> - Returns:
- the add method.
-
getGetMethod
- Specified by:
getGetMethodin interfacePropertyEditor<D extends BioPAXElement,R> - Returns:
- the get method
-
getProperty
- Specified by:
getPropertyin interfacePropertyEditor<D extends BioPAXElement,R> - Returns:
- the proterty name as a string
-
getRemoveMethod
- Specified by:
getRemoveMethodin interfacePropertyEditor<D extends BioPAXElement,R> - Returns:
- the remove method
-
getSetMethod
- Specified by:
getSetMethodin interfacePropertyEditor<D extends BioPAXElement,R> - Returns:
- the set method
-
addMaxCardinalityRestriction
Description copied from interface:PropertyEditorSets a maximum cardinality for a domain.- Specified by:
addMaxCardinalityRestrictionin interfacePropertyEditor<D extends BioPAXElement,R> - Parameters:
domain- domain on which restriction will be setmax- cardinality- See Also:
-
getMaxCardinality
Description copied from interface:PropertyEditorReturn the maximum cardinality that is defined for the property to which editor is belong.- Specified by:
getMaxCardinalityin interfacePropertyEditor<D extends BioPAXElement,R> - Parameters:
restrictedDomain- domain to be checked for the cardinality- Returns:
- an integer indicating the maximum cardinality
-
isInstanceOfAtLeastOne
Checks if value is an instance of one of the classes given in a set. This method becomes useful, when the restrictions have to be checked for a set of objects. e.g. check if the value is in the range of the editor.- Parameters:
classes- a set of classes to be checkedvalue- value whose class will be checked- Returns:
- true if value belongs to one of the classes in the set
-
getUnknown
Description copied from interface:PropertyEditorGets the unknown value. In an object property or enumeration context a value is regarded to be unknown if it is null (unset); in a primitive property context it depends (can be e.g.,BioPAXElement.UNKNOWN_FLOAT)- Specified by:
getUnknownin interfacePropertyEditor<D extends BioPAXElement,R> - Returns:
- null or what it means that the property value is unknown
-
removeValueFromBean
Description copied from interface:PropertyEditorRemoves 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 usingPropertyEditor.setValueToBean(Object, org.biopax.paxtools.model.BioPAXElement)(but only if )- Specified by:
removeValueFromBeanin interfacePropertyEditor<D extends BioPAXElement,R> - Parameters:
value- to be removed from the beanbean- bean from which the value is going to be removed
-
removeValueFromBean
Description copied from interface:PropertyEditorRemoves the values from the bean using thePropertyEditor.removeValueFromBean(Object, org.biopax.paxtools.model.BioPAXElement)for each value in the set.- Specified by:
removeValueFromBeanin interfacePropertyEditor<D extends BioPAXElement,R> - Parameters:
values- to be removed from the beanbean- bean from which the value is going to be removed
-
invokeMethod
Calls the method onto bean with the value as its parameter. In this context method can be one of these three: set, add, or remove.- Parameters:
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 method
-
parseValueFromString
-
setValueToBean
Description copied from interface:PropertyEditorSets the value to the bean using the default setMethod if value is not null.- Specified by:
setValueToBeanin interfacePropertyEditor<D extends BioPAXElement,R> - Parameters:
value- to be set to the beanbean- to which the value is to be set
-
setValueToBean
- Specified by:
setValueToBeanin interfacePropertyEditor<D extends BioPAXElement,R>
-
checkRestrictions
Checks if the bean and the value are consistent with the cardinality rules of the model. This method is important for validations.- Parameters:
value- Value that is related to the objectbean- Object that is related to the value
-
getPrimarySetMethod
Description copied from interface:PropertyEditorReturns the primary set method of the editor. It is the setMethod for a property of single cardinality, and the addMethod method for a property of multiple cardinality.- Specified by:
getPrimarySetMethodin interfacePropertyEditor<D extends BioPAXElement,R> - Returns:
- the method to be primarily used for setting a value to an object.
-