import eu.etaxonomy.cdm.api.facade.DerivedUnitFacade;
import eu.etaxonomy.cdm.model.common.CdmBase;
import eu.etaxonomy.taxeditor.model.AbstractUtility;
+import eu.etaxonomy.taxeditor.model.FeatureNodeContainer;
import eu.etaxonomy.taxeditor.store.internal.TaxeditorStorePlugin;
/**
/**
* If the object given is already a {@link CdmBase} then it is returned.<br>
- * If it is a facade then it is asked for its "responsible" CdmBase entity.<br>
+ * If it is a kind of "container" for CDM objects then it is asked for its "responsible" CdmBase entity.<br>
* Otherwise an exception is thrown.
* @param object the object to test for CdmBase
* @return a CdmBase object
- * @throws IllegalArgumentException if the tested object is neither a CdmBase nor a facade
+ * @throws IllegalArgumentException if the tested object is neither a CdmBase nor a CDM "container"
*/
public static CdmBase getCdmEntity(Object object){
// TODO temporary solution for ticket #4091????
- if(object instanceof DerivedUnitFacade){
+ if (object == null){
+ return null; //not sure if an object should ever be null at this point, but this needs to be handled in calling methods
+ }else if(object instanceof DerivedUnitFacade){
return ((DerivedUnitFacade)object).baseUnit();
}
+ else if(object instanceof FeatureNodeContainer){
+ return ((FeatureNodeContainer) object).getFeatureNode();
+ }
else if(object instanceof CdmBase){
return (CdmBase) object;
}
- throw new IllegalArgumentException("Object " + object.toString() + " is neither a CdmBase nor an EntityFacade");
+ throw new IllegalArgumentException("Object " + object.toString() + " is neither a CdmBase nor a CDM \"container\"");
}
/**