Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
U
uaaltools
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
universAAL
uaaltools
Commits
0331959a
Commit
0331959a
authored
13 years ago
by
Erlend Stav
Browse files
Options
Downloads
Patches
Plain Diff
Updated setter and getter methods for multiple cardinality based on discussion with Carsten
parent
c33f6ef2
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
transformations/org.universaal.tools.transformationcommand/transformations/ontUML2JavaV2.m2t
+34
-45
34 additions, 45 deletions
...s.transformationcommand/transformations/ontUML2JavaV2.m2t
with
34 additions
and
45 deletions
transformations/org.universaal.tools.transformationcommand/transformations/ontUML2JavaV2.m2t
+
34
−
45
View file @
0331959a
...
...
@@ -829,7 +829,8 @@ public class ' ontologyName 'Factory extends ResourceFactoryImpl {
}
if ((att.upper > 1) or (att.upper == -1)) {
self.genArrayGetterAndSetter(methodName, propLongName, theTypeName)
var includeAddMethod:Boolean = att.lower < 2
self.genArrayGetterAndSetter(methodName, propLongName, theTypeName, includeAddMethod)
}
else if (theTypeName == "Boolean") {
self.genBooleanGetterAndSetter(methodName, propLongName)
...
...
@@ -844,64 +845,52 @@ public class ' ontologyName 'Factory extends ResourceFactoryImpl {
self.genObjectGetterAndSetter(methodName, propLongName, theTypeName)
}
}
/*
self.getAssociations()->forEach (ass : uml.Association | ass.endType.first().name.trim().equals(self.name.trim()) ) {
var methodName:String = ass.memberEnd.last().name.trim().firstToUpper()
var propLongName:String = "PROP_" + ass.toUpperFormat()
var theTypeName:String = ass.endType.last().name
self.genObjectGetterAndSetter(methodName, propLongName, theTypeName)
}
*/
}
uml.Class::genArrayGetterAndSetter(methodName:String, propertyLongName:String, typeName:String) {
/* The following code was made under the assumption that we need to handle a special case of a single
* contained object differently than if the list contain many objects. Hopefully the simplified approach
* above will be sufficient, though.
*/
uml.Class::genArrayGetterAndSetter(methodName:String, propertyLongName:String, typeName:String, includeAdd:boolean) {
'
public 'typeName'[] get'methodName'() {
Object propList =
props.get
('propertyLongName');
if (propList instanceof List)
{
Object propList =
getProperty
('propertyLongName');
if (propList instanceof List)
return ('typeName'[]) ((List) propList).toArray(new 'typeName'[0]);
} else {
List returnList = new ArrayList();
else if (propList != null)
return new 'typeName'[] {('typeName')propList}; // Handle special case of a single item not contained in a list
return new 'typeName'[0];
}
'
if (includeAdd) {
'
public void add'methodName'('typeName' newValue) {
Object propList = getProperty('propertyLongName');
List newList;
if (propList instanceof List)
newList = (List)propList;
else {
newList = new ArrayList();
if (propList != null)
returnList.add(('typeName') propList);
return ('typeName'[]) returnList.toArray(new 'typeName'[0]);
newList.add(propList); // Handle special case of a single previous item not contained in a list
}
newList.add(newValue);
setProperty('propertyLongName', newList);
}
public void add'methodName'('typeName' sens) {
Object propList = props.get('propertyLongName');
if (propList instanceof List) {
List list = (List) propList;
list.add(sens);
props.put('propertyLongName', list);
} else if (propList == null) {
props.put('propertyLongName', sens);
} else {
List list = new ArrayList();
list.add(('typeName') propList);
list.add(sens);
props.put('propertyLongName', list);
}
'
} else {
'
// No add'methodName'() method was generated because the lower cardinality of this
// property is >= 2, and the generic add method implementation do not support this constraint
'
}
'
public void set'methodName'('typeName'[]
sens
) {
List propList = new ArrayList(
sens
.length);
for (int i = 0; i <
sens
.length; i++) {
propList.add(
sens
[i]);
public void set'methodName'('typeName'[]
propertyValue
) {
List propList = new ArrayList(
propertyValue
.length);
for (int i = 0; i <
propertyValue
.length; i++) {
propList.add(
propertyValue
[i]);
}
props.put
('propertyLongName', propList);
setProperty
('propertyLongName', propList);
}
'
/**/
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment