net.sf.andromedaioc.model.beans.AbstractDataStructureModel Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of andromeda-ioc Show documentation
Show all versions of andromeda-ioc Show documentation
Inversion of Control Framework for Android
The newest version!
package net.sf.andromedaioc.model.beans;
import net.sf.andromedaioc.model.builder.xml.XmlContextElement;
import java.lang.reflect.Modifier;
public abstract class AbstractDataStructureModel extends BeanModel {
private final XmlContextElement xmlContextElement;
protected AbstractDataStructureModel(XmlContextElement xmlContextElement) {
this.xmlContextElement = xmlContextElement;
}
public void setBeanClass(Class> beanClass) {
if(beanClass == null) {
return;
}
if(!xmlContextElement.getBaseType().isAssignableFrom(beanClass)) {
throw new IllegalArgumentException(String.format("Provided class %s is not instance of %s class", beanClass, xmlContextElement.getBaseType()));
}
if(beanClass.isInterface() || Modifier.isAbstract(beanClass.getModifiers())) {
throw new IllegalArgumentException(String.format("Provided class %s is interface or abstract", beanClass));
}
super.setBeanClass(beanClass);
}
public void setAbstractBean(boolean abstractBean) {
if(abstractBean) {
throw new UnsupportedOperationException(String.format("Inheritance is not supported for data structures %s", xmlContextElement.getName()));
}
}
public boolean isAbstractBean() {
return false;
}
public void setParent(ReferenceKey parent) {
if(parent != null) {
throw new UnsupportedOperationException(String.format("Inheritance is not supported for data structures %s", xmlContextElement.getName()));
}
}
public ReferenceKey getParent() {
return null;
}
}