All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.sf.andromedaioc.model.beans.AbstractDataStructureModel Maven / Gradle / Ivy

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;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy