templates.Features.xpt Maven / Gradle / Ivy
?IMPORT core?
?IMPORT dom?
?EXTENSION extensions::EntityExtension?
?EXTENSION extensions::Names?
?EXTENSION extensions::JavaUtil?
?DEFINE serialVersionUID FOR ComplexType-?
private static final long serialVersionUID = ?serialVersionUID()?;
?ENDDEFINE?
?DEFINE operationSignature(boolean isImplementation) FOR DelegateOperation-?
?EXPAND Documentation::documentationIndented FOR this-?
?EXPAND operationAnnotation(isImplementation) FOR this-?
?IF isImplementation?public ?ENDIF??getType()? ?((Operation)operation).name?(?EXPAND parameterDeclaration(isImplementation) FOREACH ((Operation)operation).parameters SEPARATOR ","?)?""-?
?ENDDEFINE?
?DEFINE operationSignature(boolean isImplementation) FOR Operation-?
?EXPAND Documentation::documentationIndented FOR this-?
?EXPAND operationAnnotation(isImplementation) FOR this-?
?IF isImplementation?public ?ENDIF??getType()? ?name?(?EXPAND parameterDeclaration(isImplementation) FOREACH parameters SEPARATOR ","?)?""-?
?ENDDEFINE?
?DEFINE operationAnnotation(boolean isImplementation) FOR DelegateOperation??ENDDEFINE?
?DEFINE operationAnnotation(boolean isImplementation) FOR dom::Operation??ENDDEFINE?
?DEFINE parameterDeclaration(boolean isImplementation) FOR dom::Parameter??EXPAND parameterAnnotation(isImplementation) FOR this??getType()? ?name.toFirstLower()??ENDDEFINE?
?DEFINE parameterAnnotation(boolean isImplementation) FOR dom::Parameter??ENDDEFINE?
?DEFINE methodParameterJavaDoc FOR QueryParameter??EXPAND methodParameterJavaDoc FOR attribute??ENDDEFINE?
?DEFINE methodParameterJavaDoc FOR PresentableFeature-?
* @param ?getResolvedName()?
?ENDDEFINE?
?DEFINE methodParameterJavaDoc FOR dom::Parameter-?
* @param ?name?
?ENDDEFINE?
?DEFINE attributes FOR DataBaseConstraint-?
?EXPAND attribute FOREACH attributes-?
?ENDDEFINE?
?DEFINE attributes FOR Entity-?
?EXPAND attribute FOREACH attributes.select(e|!e.derived)-?
?ENDDEFINE?
?DEFINE attributes FOR DataView-?
?EXPAND attribute FOREACH attributes.select(e|!e.derived)-?
?ENDDEFINE?
?DEFINE attributes FOR ComplexType-?
?EXPAND attribute FOREACH attributes-?
?ENDDEFINE?
?DEFINE attribute FOR Attribute-?
?EXPAND Documentation::documentationIndented FOR this-?
?IF !many-?
protected ?getImplementationType()? ?name-??IF ValueObject.isInstance(type.dataType)-? = new ?getImplementationType()-?()?ENDIF-?;
?ELSE-?
protected ?Entity.isInstance(eContainer) ? registerImport("java.util.Set"):registerImport("java.util.List")? ?name?;
?ENDIF-?
?ENDDEFINE?
?DEFINE methodParameter FOR QueryParameter-?
?attribute.getType()? ?attribute.name-?
?ENDDEFINE?
?DEFINE methodParameter FOR Attribute-?
?getImplementationType()? ?getResolvedName()-?
?ENDDEFINE?
?DEFINE methodParameter FOR dom::Parameter-?
?getType()? ?name-?
?ENDDEFINE?
?DEFINE properties FOR DataView-?
?FOREACH attributes AS attribute-?
?IF !attribute.derived-?
public ?IF attribute.many?List?ELSE??attribute.getImplementationType()??ENDIF-? ?attribute.getAccessorMethodName()?() {
return this.?attribute.name?;
}
public void ?attribute.getMutatorMethodName()?(?IF attribute.many-??registerImport("java.util.List")??ELSE??attribute.getImplementationType()??ENDIF? ?attribute.name?) {
this.?attribute.name?=?attribute.name?;
}
?IF attribute.many-?
public void ?attribute.getAddMethodName()?(?attribute.getImplementationType()? ?attribute.name?) {
if (?attribute.name? == null) {
throw new IllegalArgumentException("parameter '?attribute.name?' must not be null");
}
if (?attribute.getAccessorMethodName()?() == null) {
this.?attribute.name? = new ?registerImport("java.util.ArrayList")?();
}
this.?attribute.name?.add(?attribute.name?);
}
?ENDIF-?
?ELSE-?
public abstract ?IF attribute.many?List?ELSE??attribute.getImplementationType()??ENDIF-? ?attribute.getAccessorMethodName()?();
?IF !attribute.readOnly-?
public abstract void ?attribute.getMutatorMethodName()?(?IF attribute.many-??registerImport("java.util.List")??ELSE??attribute.getImplementationType()??ENDIF? ?attribute.name?);
?ENDIF-?
?ENDIF-?
?ENDFOREACH?
?ENDDEFINE?
?DEFINE properties FOR Entity-?
?EXPAND properties FOREACH attributes.select(e|!e.derived)-?
?ENDDEFINE?
?DEFINE properties FOR ComplexType-?
?EXPAND properties FOREACH attributes-?
?ENDDEFINE?
?DEFINE properties FOR DataBaseConstraint-?
?EXPAND properties FOREACH attributes-?
?ENDDEFINE?
?DEFINE properties FOR Attribute?
?IF !reference-?
?IF !many-?
public ?getImplementationType()? ?getAccessorMethodName()?() {
return this.?name?;
}
?ELSE-?
public List ?getAccessorMethodName()?() {
return this.?name?;
}
?ENDIF-?
?IF !readOnly-?
?IF !many-?
public void ?getMutatorMethodName()?(?getImplementationType()? ?name?) {
this.?name? = ?name?;
}
?ELSE-?
public void ?getMutatorMethodName()?(List ?name?) {
this.?name? = ?name?;
}
?ENDIF-?
?ENDIF-?
?ELSE-?
?IF !many-?
public ?getImplementationType()? ?getAccessorMethodName()?() {
return this.?name?;
}
public void ?getMutatorMethodName()?(?getImplementationType()? ?name?) {
if (this.?name? != ?name?) {
?IF oppositeReference !=null && oppositeReference.many-?
if (this.?name? != null) {
this.?name?.?oppositeReference.getRemoveMethodName()?(this);
}
?ENDIF-?
this.?name? = ?name.toFirstLower()?;
?IF oppositeReference!=null-?
if (?name.toFirstLower()? != null) {
?IF !oppositeReference.many-?
?name.toFirstLower()?.?oppositeReference.getMutatorMethodName()?(this);
?ELSE-?
?name.toFirstLower()?.?oppositeReference.getAddMethodName()?(this);
?ENDIF-?
}
?ENDIF-?
}
}
?ELSE-?
public Set ?getAccessorMethodName()?() {
if (this.?name? == null) {
this.?name? = new ?registerImport("java.util.HashSet")?();
}
return ?registerImport("java.util.Collections")?.unmodifiableSet(this.?name?);
}
public boolean ?getHasMethodName()?() {
return ?name? != null && !?name?.isEmpty();
}
public void ?getAddMethodName()?(?getImplementationType()? ?name?) {
if (?name.toFirstLower()? == null) {
throw new IllegalArgumentException("parameter '?name?' must not be null");
}
if (!?getAccessorMethodName()?().contains(?name?)) {
this.?name?.add(?name?);
?IF oppositeReference!=null-?
?name?.?IF !oppositeReference.many??oppositeReference.getMutatorMethodName()??ELSE??oppositeReference.getAddMethodName()??ENDIF?(this);
?ENDIF-?
}
}
public void ?getRemoveMethodName()?(?getImplementationType()? ?name?) {
if (?name? == null) {
throw new IllegalArgumentException("parameter '?name?' must not be null");
}
if (?getAccessorMethodName()?().contains(?name?)) {
this.?name?.remove(?name?);
?IF oppositeReference!=null-?
?name?.?IF !oppositeReference.many??oppositeReference.getMutatorMethodName()?(null)?ELSE??oppositeReference.getRemoveMethodName()?(this)?ENDIF?;
?ENDIF-?
}
}
public void ?getRemoveAllMethodName()?() {
if (this.?name? != null) {
?IF isInverseSide() && !composition-?
for (?getImplementationType()? ?getImplementationType().toFirstLower()? : new HashSet(this.?name?)) {
?getRemoveMethodName()?(?getImplementationType().toFirstLower()?);
}
?ELSE-?
this.?name?.clear();
?ENDIF-?
}
}
?ENDIF-?
?ENDIF-?
?ENDDEFINE?
?DEFINE accessor FOR Attribute-?
?EXPAND Documentation::documentationIndented FOR this-?
?IF many-?
?registerImport("java.util.Set")? ?getAccessorMethodName()?();
?ELSE-?
?getImplementationType()? ?getAccessorMethodName()?();
?ENDIF-?
?ENDDEFINE?
?DEFINE mutator FOR Attribute-?
?IF many-?
boolean ?getHasMethodName()?();
void ?getAddMethodName()?(?getImplementationType()? ?name?);
void ?getRemoveMethodName()?(?getImplementationType()? ?name?);
void ?getRemoveAllMethodName()?();
?ELSEIF !readOnly-?
void ?getMutatorMethodName()?(?getImplementationType()? ?name?);
?ENDIF-?
?ENDDEFINE?
?DEFINE toString FOR ComplexType?
@Override
public String toString() {
StringBuilder toStringBuilder = new StringBuilder("?name? [");
?IF (Entity.isInstance(this) && ((Entity)this).superType!=null) || (DataView.isInstance(this) && ((DataView)this).superType!=null)-?
toStringBuilder.append(super.toString())?IF !attributes.isEmpty?.append(",")?ENDIF?;
?ENDIF-?
?FOREACH attributes.reject(e|ComplexType.isInstance(e.type.dataType)) AS attribute ITERATOR iterator-?
toStringBuilder.append("?attribute.name?=").append(?attribute.getAccessorMethodName()?())?IF !iterator.lastIteration?.append(",")?ENDIF?;
?ENDFOREACH-?
return toStringBuilder.append("]").toString();
}
?ENDDEFINE?