Class AbstractPropertyEditor<D extends BioPAXElement,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 Details

    • log

      protected static final org.slf4j.Logger log
    • setMethod

      protected Method setMethod
      This variable stores the method to invoke for setting a property to the to the given value. If multiple cardinality, the returned method is expected to have a Set as its only parameter.
    • addMethod

      protected Method 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 a PropertyAccessorAdapter.range as its only parameter, otherwise expected to be null.
    • removeMethod

      protected Method 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 a PropertyAccessorAdapter.range as its only parameter, otherwise expected to be null
    • property

      protected final String property
      Local OWL name of the property
    • checkRestrictions

      public static ThreadLocal<Boolean> checkRestrictions
  • Constructor Details

    • AbstractPropertyEditor

      public AbstractPropertyEditor(String property, Method getMethod, Class<D> domain, Class<R> range, boolean multipleCardinality)
      Constructor.
      Parameters:
      property - biopax property name
      getMethod - getter
      domain - class the property belongs to
      range - property values type/class
      multipleCardinality - whether more than one value is allowed
  • Method Details

    • toString

      public String toString()
      Specified by:
      toString in interface PropertyEditor<D extends BioPAXElement,R>
      Overrides:
      toString in class SimplePropertyAccessor<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 - domain
      R - 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

      protected static Class detectRange(Method getMethod)
      Given the multiple cardinality feature, the range of the get method is returned.
      Parameters:
      getMethod - default method
      Returns:
      the range as a class
    • getAddMethod

      public Method getAddMethod()
      Specified by:
      getAddMethod in interface PropertyEditor<D extends BioPAXElement,R>
      Returns:
      the add method.
    • getGetMethod

      public Method getGetMethod()
      Specified by:
      getGetMethod in interface PropertyEditor<D extends BioPAXElement,R>
      Returns:
      the get method
    • getProperty

      public String getProperty()
      Specified by:
      getProperty in interface PropertyEditor<D extends BioPAXElement,R>
      Returns:
      the proterty name as a string
    • getRemoveMethod

      public Method getRemoveMethod()
      Specified by:
      getRemoveMethod in interface PropertyEditor<D extends BioPAXElement,R>
      Returns:
      the remove method
    • getSetMethod

      public Method getSetMethod()
      Specified by:
      getSetMethod in interface PropertyEditor<D extends BioPAXElement,R>
      Returns:
      the set method
    • addMaxCardinalityRestriction

      public void addMaxCardinalityRestriction(Class<? extends D> domain, int max)
      Description copied from interface: PropertyEditor
      Sets a maximum cardinality for a domain.
      Specified by:
      addMaxCardinalityRestriction in interface PropertyEditor<D extends BioPAXElement,R>
      Parameters:
      domain - domain on which restriction will be set
      max - cardinality
      See Also:
    • getMaxCardinality

      public Integer getMaxCardinality(Class<? extends D> restrictedDomain)
      Description copied from interface: PropertyEditor
      Return the maximum cardinality that is defined for the property to which editor is belong.
      Specified by:
      getMaxCardinality in interface PropertyEditor<D extends BioPAXElement,R>
      Parameters:
      restrictedDomain - domain to be checked for the cardinality
      Returns:
      an integer indicating the maximum cardinality
    • isInstanceOfAtLeastOne

      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. 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 checked
      value - value whose class will be checked
      Returns:
      true if value belongs to one of the classes in the set
    • getUnknown

      public R getUnknown()
      Description copied from interface: PropertyEditor
      Gets 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:
      getUnknown in interface PropertyEditor<D extends BioPAXElement,R>
      Returns:
      null or what it means that the property value is unknown
    • removeValueFromBean

      public void removeValueFromBean(R value, D bean)
      Description copied from interface: PropertyEditor
      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 )
      Specified by:
      removeValueFromBean in interface PropertyEditor<D extends BioPAXElement,R>
      Parameters:
      value - to be removed from the bean
      bean - bean from which the value is going to be removed
    • removeValueFromBean

      public void removeValueFromBean(Set<R> values, D bean)
      Description copied from interface: PropertyEditor
      Removes the values from the bean using the PropertyEditor.removeValueFromBean(Object, org.biopax.paxtools.model.BioPAXElement) for each value in the set.
      Specified by:
      removeValueFromBean in interface PropertyEditor<D extends BioPAXElement,R>
      Parameters:
      values - to be removed from the bean
      bean - bean from which the value is going to be removed
    • invokeMethod

      protected void invokeMethod(Method method, D bean, R value)
      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 called
      bean - bean onto which the method is going to be applied
      value - the value which is going to be used by method
    • parseValueFromString

      protected R parseValueFromString(String value)
    • setValueToBean

      public void setValueToBean(R value, D bean)
      Description copied from interface: PropertyEditor
      Sets the value to the bean using the default setMethod if value is not null.
      Specified by:
      setValueToBean in interface PropertyEditor<D extends BioPAXElement,R>
      Parameters:
      value - to be set to the bean
      bean - to which the value is to be set
    • setValueToBean

      public void setValueToBean(Set<R> values, D bean)
      Specified by:
      setValueToBean in interface PropertyEditor<D extends BioPAXElement,R>
    • checkRestrictions

      protected void checkRestrictions(R value, D bean)
      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 object
      bean - Object that is related to the value
    • getPrimarySetMethod

      public Method getPrimarySetMethod()
      Description copied from interface: PropertyEditor
      Returns 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:
      getPrimarySetMethod in interface PropertyEditor<D extends BioPAXElement,R>
      Returns:
      the method to be primarily used for setting a value to an object.