net.sf.nakeduml.domainmetamodel.DomainPackage Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of metamodel Show documentation
Show all versions of metamodel Show documentation
A uml code generator and execution engine
The newest version!
package net.sf.nakeduml.domainmetamodel;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import net.sf.nakeduml.util.CompositionNode;
import util.Stdlib;
abstract public class DomainPackage extends DomainElement implements CompositionNode {
private Set ownedClassifier = new HashSet();
private Set childPackage = new HashSet();
/** Default constructor for
*/
public DomainPackage() {
}
public void addAllToChildPackage(Set childPackage) {
for ( NodeDomainPackage o : childPackage ) {
addToChildPackage(o);
}
}
public void addAllToOwnedClassifier(Set ownedClassifier) {
for ( DomainClassifier o : ownedClassifier ) {
addToOwnedClassifier(o);
}
}
public void addToChildPackage(NodeDomainPackage childPackage) {
childPackage.setParentPackage(this);
}
public void addToOwnedClassifier(DomainClassifier ownedClassifier) {
ownedClassifier.setDomainPackage(this);
}
/** Call this method when you want to attach this object to the containment tree. Useful with transitive persistence
*/
public void addToOwningObject() {
}
public void clearChildPackage() {
removeAllFromChildPackage(getChildPackage());
}
public void clearOwnedClassifier() {
removeAllFromOwnedClassifier(getOwnedClassifier());
}
public void copyState(DomainPackage from, DomainPackage to) {
to.setName(from.getName());
to.setHumanName(from.getHumanName());
for ( DomainClassifier child : getOwnedClassifier() ) {
to.addToOwnedClassifier(child.makeCopy());
}
for ( NodeDomainPackage child : getChildPackage() ) {
to.addToChildPackage(child.makeCopy());
}
}
public NodeDomainPackage createChildPackage() {
NodeDomainPackage newInstance= new NodeDomainPackage();
newInstance.init(this);
return newInstance;
}
public void createComponents() {
super.createComponents();
}
public DomainClassifier createOwnedClassifier() {
DomainClassifier newInstance= new DomainClassifier();
newInstance.init(this);
return newInstance;
}
public Set getChildPackage() {
return childPackage;
}
public Set getEntity() {
Set entity = (Set)Stdlib.collectionAsSet(collect2());
return entity;
}
public Set getOwnedClassifier() {
return ownedClassifier;
}
public Set getOwnedElement() {
Set ownedElementSubsetting = new HashSet();
ownedElementSubsetting.addAll(super.getOwnedElement());
ownedElementSubsetting.addAll(getOwnedClassifier());
ownedElementSubsetting.addAll(getChildPackage());
return ownedElementSubsetting;
}
public CompositionNode getOwningObject() {
return null;
}
public void init(CompositionNode owner) {
super.init(owner);
createComponents();
}
abstract public DomainPackage makeCopy();
public void markDeleted() {
super.markDeleted();
for ( DomainClassifier child : new ArrayList(getOwnedClassifier()) ) {
child.markDeleted();
}
for ( NodeDomainPackage child : new ArrayList(getChildPackage()) ) {
child.markDeleted();
}
}
public void removeAllFromChildPackage(Set childPackage) {
for ( NodeDomainPackage o : childPackage ) {
removeFromChildPackage(o);
}
}
public void removeAllFromOwnedClassifier(Set ownedClassifier) {
for ( DomainClassifier o : ownedClassifier ) {
removeFromOwnedClassifier(o);
}
}
public void removeFromChildPackage(NodeDomainPackage childPackage) {
childPackage.setParentPackage(null);
}
public void removeFromOwnedClassifier(DomainClassifier ownedClassifier) {
ownedClassifier.setDomainPackage(null);
}
public void removeFromOwningObject() {
this.markDeleted();
}
public void setChildPackage(Set childPackage) {
for ( NodeDomainPackage o : new HashSet(this.childPackage) ) {
o.setParentPackage(null);
}
for ( NodeDomainPackage o : childPackage ) {
o.setParentPackage((DomainPackage)this);
}
}
public void setOwnedClassifier(Set ownedClassifier) {
for ( DomainClassifier o : new HashSet(this.ownedClassifier) ) {
o.setDomainPackage(null);
}
for ( DomainClassifier o : ownedClassifier ) {
o.setDomainPackage((DomainPackage)this);
}
}
public void shallowCopyState(DomainPackage from, DomainPackage to) {
to.setName(from.getName());
to.setHumanName(from.getHumanName());
}
public String toString() {
StringBuilder sb = new StringBuilder();
if ( getOwner()==null ) {
sb.append("owner=null;");
} else {
sb.append("owner="+getOwner().getClass().getSimpleName()+"[");
sb.append(getOwner().getName());
sb.append("];");
}
sb.append("name=");
sb.append(getName());
sb.append(";");
sb.append("humanName=");
sb.append(getHumanName());
sb.append(";");
sb.append("qualifiedName=");
sb.append(getQualifiedName());
sb.append(";");
return sb.toString();
}
public String toXmlString() {
StringBuilder sb = new StringBuilder();
if ( getName()==null ) {
sb.append(" ");
} else {
sb.append("");
sb.append(getName());
sb.append(" ");
sb.append("\n");
}
if ( getHumanName()==null ) {
sb.append(" ");
} else {
sb.append("");
sb.append(getHumanName());
sb.append(" ");
sb.append("\n");
}
for ( DomainClassifier ownedClassifier : getOwnedClassifier() ) {
sb.append("");
sb.append(ownedClassifier.toXmlString());
sb.append(" ");
sb.append("\n");
}
for ( NodeDomainPackage childPackage : getChildPackage() ) {
sb.append("");
sb.append(childPackage.toXmlString());
sb.append(" ");
sb.append("\n");
}
return sb.toString();
}
/** Implements ->collect( c : DomainClassifier | c.oclAsType(DomainEntity) )
*/
private List collect2() {
List result = new ArrayList();
for ( DomainClassifier c : select1() ) {
DomainEntity bodyExpResult = ((DomainEntity) c);
if ( bodyExpResult != null ) result.add( bodyExpResult );
}
return result;
}
/** Implements ->select( c : DomainClassifier | c.oclIsKindOf(DomainEntity) )
*/
private Set select1() {
Set result = new HashSet();
for ( DomainClassifier c : this.getOwnedClassifier() ) {
if ( (false /* types of oclIsKindOf do not conform */) ) {
result.add( c );
}
}
return result;
}
}