001package org.biopax.paxtools.controller; 002 003import org.biopax.paxtools.model.BioPAXElement; 004 005import java.lang.reflect.Method; 006import java.util.Set; 007 008/** 009 010 */ 011public interface PropertyEditor<D extends BioPAXElement, R> extends PropertyAccessor<D,R> 012{ 013 @Override String toString(); 014 015 /** 016 * @return the add method. 017 */ 018 Method getAddMethod(); 019 020 /** 021 * @return the get method 022 */ 023 Method getGetMethod(); 024 025 /** 026 * @return the proterty name as a string 027 */ 028 String getProperty(); 029 030 /** 031 * @return the remove method 032 */ 033 Method getRemoveMethod(); 034 035 /** 036 * @return the set method 037 */ 038 Method getSetMethod(); 039 040 /** 041 * Sets a maximum cardinality for a domain. 042 * @param domain domain on which restriction will be set 043 * @param max cardinality 044 * @see #isMultipleCardinality() 045 */ 046 void addMaxCardinalityRestriction(Class<? extends D> domain, int max); 047 048 /** 049 * Return the maximum cardinality that is defined for the property to which editor is belong. 050 * @param restrictedDomain domain to be checked for the cardinality 051 * @return an integer indicating the maximum cardinality 052 */ 053 Integer getMaxCardinality(Class<? extends D> restrictedDomain); 054 055 /** 056 * Gets the unknown <em>value</em>. In an object property or enumeration 057 * context a <em>value</em> is regarded to be unknown if it is null (unset); 058 * in a primitive property context it depends (can be e.g., 059 * {@link org.biopax.paxtools.model.BioPAXElement#UNKNOWN_FLOAT}) 060 * @return null or what it means that the property value is unknown 061 */ 062 R getUnknown(); 063 064 /** 065 * Removes the <em>value</em> from the <em>bean</em> using the default removeMethod, 066 * if such method is defined (i.e., it's a multiple cardinality property), 067 * otherwise sets <em>unknown</em> value using {@link #setValueToBean(Object, org.biopax.paxtools.model.BioPAXElement)} 068 * (but only if ) 069 * 070 * @param value to be removed from the bean 071 * @param bean bean from which the value is going to be removed 072 */ 073 void removeValueFromBean(R value, D bean); 074 075 /** 076 * Removes the <em>values</em> from the <em>bean</em> 077 * using the {@link #removeValueFromBean(Object, org.biopax.paxtools.model.BioPAXElement)} 078 * for each value in the set. 079 * 080 * @param values to be removed from the bean 081 * @param bean bean from which the value is going to be removed 082 */ 083 void removeValueFromBean(Set<R> values, D bean); 084 085 /** 086 * Sets the <em>value</em> to the <em>bean</em> using the default setMethod if 087 * <em>value</em> is not null. 088 * @param value to be set to the <em>bean</em> 089 * @param bean to which the <em>value</em> is to be set 090 */ 091 void setValueToBean(R value, D bean); 092 093 void setValueToBean(Set<R> values, D bean); 094 095 /** 096 * Returns the primary set method of the editor. It is the setMethod for a property of 097 * single cardinality, and the addMethod method for a property of multiple cardinality. 098 * @return the method to be primarily used for setting a value to an object. 099 */ 100 Method getPrimarySetMethod(); 101}