io.ciera.tool.sql.architecture.invocable.impl.GenericInvocableImpl Maven / Gradle / Ivy
package io.ciera.tool.sql.architecture.invocable.impl;
import io.ciera.runtime.instanceloading.AttributeChangedDelta;
import io.ciera.runtime.instanceloading.InstanceCreatedDelta;
import io.ciera.runtime.summit.application.IRunContext;
import io.ciera.runtime.summit.classes.IInstanceIdentifier;
import io.ciera.runtime.summit.classes.InstanceIdentifier;
import io.ciera.runtime.summit.classes.ModelInstance;
import io.ciera.runtime.summit.exceptions.EmptyInstanceException;
import io.ciera.runtime.summit.exceptions.InstancePopulationException;
import io.ciera.runtime.summit.exceptions.XtumlException;
import io.ciera.runtime.summit.types.IWhere;
import io.ciera.runtime.summit.types.IXtumlType;
import io.ciera.runtime.summit.types.StringUtil;
import io.ciera.runtime.summit.types.UniqueId;
import io.ciera.tool.Sql;
import io.ciera.tool.sql.architecture.invocable.GenericInvocable;
import io.ciera.tool.sql.architecture.invocable.InvocableObject;
import io.ciera.tool.sql.architecture.invocable.impl.InvocableObjectImpl;
public class GenericInvocableImpl extends ModelInstance implements GenericInvocable {
public static final String KEY_LETTERS = "GenericInvocable";
public static final GenericInvocable EMPTY_GENERICINVOCABLE = new EmptyGenericInvocable();
private Sql context;
// constructors
private GenericInvocableImpl( Sql context ) {
this.context = context;
ref_parent_name = "";
ref_parent_package = "";
ref_name = "";
R427_is_a_InvocableObject_inst = InvocableObjectImpl.EMPTY_INVOCABLEOBJECT;
}
private GenericInvocableImpl( Sql context, UniqueId instanceId, String ref_parent_name, String ref_parent_package, String ref_name ) {
super(instanceId);
this.context = context;
this.ref_parent_name = ref_parent_name;
this.ref_parent_package = ref_parent_package;
this.ref_name = ref_name;
R427_is_a_InvocableObject_inst = InvocableObjectImpl.EMPTY_INVOCABLEOBJECT;
}
public static GenericInvocable create( Sql context ) throws XtumlException {
GenericInvocable newGenericInvocable = new GenericInvocableImpl( context );
if ( context.addInstance( newGenericInvocable ) ) {
newGenericInvocable.getRunContext().addChange(new InstanceCreatedDelta(newGenericInvocable, KEY_LETTERS));
return newGenericInvocable;
}
else throw new InstancePopulationException( "Instance already exists within this population." );
}
public static GenericInvocable create( Sql context, String ref_parent_name, String ref_parent_package, String ref_name ) throws XtumlException {
return create(context, UniqueId.random(), ref_parent_name, ref_parent_package, ref_name);
}
public static GenericInvocable create( Sql context, UniqueId instanceId, String ref_parent_name, String ref_parent_package, String ref_name ) throws XtumlException {
GenericInvocable newGenericInvocable = new GenericInvocableImpl( context, instanceId, ref_parent_name, ref_parent_package, ref_name );
if ( context.addInstance( newGenericInvocable ) ) {
return newGenericInvocable;
}
else throw new InstancePopulationException( "Instance already exists within this population." );
}
// attributes
private String ref_parent_name;
@Override
public void setParent_name(String ref_parent_name) throws XtumlException {
checkLiving();
if (StringUtil.inequality(ref_parent_name, this.ref_parent_name)) {
final String oldValue = this.ref_parent_name;
this.ref_parent_name = ref_parent_name;
getRunContext().addChange(new AttributeChangedDelta(this, KEY_LETTERS, "ref_parent_name", oldValue, this.ref_parent_name));
}
}
@Override
public String getParent_name() throws XtumlException {
checkLiving();
return ref_parent_name;
}
private String ref_parent_package;
@Override
public String getParent_package() throws XtumlException {
checkLiving();
return ref_parent_package;
}
@Override
public void setParent_package(String ref_parent_package) throws XtumlException {
checkLiving();
if (StringUtil.inequality(ref_parent_package, this.ref_parent_package)) {
final String oldValue = this.ref_parent_package;
this.ref_parent_package = ref_parent_package;
getRunContext().addChange(new AttributeChangedDelta(this, KEY_LETTERS, "ref_parent_package", oldValue, this.ref_parent_package));
}
}
private String ref_name;
@Override
public String getName() throws XtumlException {
checkLiving();
return ref_name;
}
@Override
public void setName(String ref_name) throws XtumlException {
checkLiving();
if (StringUtil.inequality(ref_name, this.ref_name)) {
final String oldValue = this.ref_name;
this.ref_name = ref_name;
getRunContext().addChange(new AttributeChangedDelta(this, KEY_LETTERS, "ref_name", oldValue, this.ref_name));
}
}
// instance identifiers
@Override
public IInstanceIdentifier getId1() {
try {
return new InstanceIdentifier(getParent_name(), getParent_package(), getName());
}
catch ( XtumlException e ) {
getRunContext().getLog().error(e);
System.exit(1);
return null;
}
}
// operations
// static operations
// events
// selections
private InvocableObject R427_is_a_InvocableObject_inst;
@Override
public void setR427_is_a_InvocableObject( InvocableObject inst ) {
R427_is_a_InvocableObject_inst = inst;
}
@Override
public InvocableObject R427_is_a_InvocableObject() throws XtumlException {
return R427_is_a_InvocableObject_inst;
}
@Override
public IRunContext getRunContext() {
return context().getRunContext();
}
@Override
public Sql context() {
return context;
}
@Override
public String getKeyLetters() {
return KEY_LETTERS;
}
@Override
public GenericInvocable self() {
return this;
}
@Override
public GenericInvocable oneWhere(IWhere condition) throws XtumlException {
if (null == condition) throw new XtumlException("Null condition passed to selection.");
if (condition.evaluate(this)) return this;
else return EMPTY_GENERICINVOCABLE;
}
}
class EmptyGenericInvocable extends ModelInstance implements GenericInvocable {
// attributes
public void setParent_name( String ref_parent_name ) throws XtumlException {
throw new EmptyInstanceException( "Cannot set attribute of empty instance." );
}
public String getParent_name() throws XtumlException {
throw new EmptyInstanceException( "Cannot get attribute of empty instance." );
}
public String getParent_package() throws XtumlException {
throw new EmptyInstanceException( "Cannot get attribute of empty instance." );
}
public void setParent_package( String ref_parent_package ) throws XtumlException {
throw new EmptyInstanceException( "Cannot set attribute of empty instance." );
}
public String getName() throws XtumlException {
throw new EmptyInstanceException( "Cannot get attribute of empty instance." );
}
public void setName( String ref_name ) throws XtumlException {
throw new EmptyInstanceException( "Cannot set attribute of empty instance." );
}
// operations
// selections
@Override
public InvocableObject R427_is_a_InvocableObject() {
return InvocableObjectImpl.EMPTY_INVOCABLEOBJECT;
}
@Override
public String getKeyLetters() {
return GenericInvocableImpl.KEY_LETTERS;
}
@Override
public GenericInvocable self() {
return this;
}
@Override
public boolean isEmpty() {
return true;
}
@Override
public GenericInvocable oneWhere(IWhere condition) throws XtumlException {
if (null == condition) throw new XtumlException("Null condition passed to selection.");
return GenericInvocableImpl.EMPTY_GENERICINVOCABLE;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy