001package org.biopax.paxtools.controller; 002 003import org.biopax.paxtools.model.BioPAXElement; 004 005import java.lang.reflect.Method; 006 007/** 008 * Provides an ENUM class compatible editor by extending the {@link PropertyEditor}. 009 * 010 * @see PropertyEditor 011 */ 012public class EnumeratedPropertyEditor<D extends BioPAXElement, R extends Enum> 013 extends AbstractPropertyEditor<D, R> implements DataPropertyEditor<D,R> 014{ 015// --------------------------- CONSTRUCTORS --------------------------- 016 017 public EnumeratedPropertyEditor(String property, Method getMethod, 018 Class<D> domain, 019 Class<R> range, 020 boolean multipleCardinality) 021 { 022 super(property, 023 getMethod, 024 domain, 025 range, 026 multipleCardinality); 027 } 028 029// -------------------------- OTHER METHODS -------------------------- 030 031 @Override 032 protected R parseValueFromString(String value) 033 { 034 035 036 value = value.replaceAll("-", "_"); 037 value = value.replaceAll("^\\s+",""); 038 value = value.replaceAll("\\s+$",""); 039 return (R)Enum.valueOf(this.getRange(), value); 040 } 041} 042