Author: tfmorris
Date: 2007-08-06 10:50:41-0700
New Revision: 13255
Modified:
trunk/src/model-mdr/build.xml
trunk/src/model-mdr/src/org/argouml/model/mdr/ActivityGraphsHelperMDRImpl.java
trunk/src/model-mdr/src/org/argouml/model/mdr/CollaborationsFactoryMDRImpl.java
trunk/src/model-mdr/src/org/argouml/model/mdr/CollaborationsHelperMDRImpl.java
trunk/src/model-mdr/src/org/argouml/model/mdr/CommonBehaviorHelperMDRImpl.java
trunk/src/model-mdr/src/org/argouml/model/mdr/CoreFactoryMDRImpl.java
trunk/src/model-mdr/src/org/argouml/model/mdr/CoreHelperMDRImpl.java
trunk/src/model-mdr/src/org/argouml/model/mdr/DataTypesFactoryMDRImpl.java
trunk/src/model-mdr/src/org/argouml/model/mdr/ExtensionMechanismsHelperMDRImpl.java
trunk/src/model-mdr/src/org/argouml/model/mdr/StateMachinesHelperMDRImpl.java
trunk/src/model-mdr/src/org/argouml/model/mdr/UseCasesHelperMDRImpl.java
Log:
Enable Java 5 generics in MDR
Modified: trunk/src/model-mdr/build.xml
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/model-mdr/build.xml?view=diff&rev=13255&p1=trunk/src/model-mdr/build.xml&p2=trunk/src/model-mdr/build.xml&r1=13254&r2=13255
==============================================================================
--- trunk/src/model-mdr/build.xml (original)
+++ trunk/src/model-mdr/build.xml 2007-08-06 10:50:41-0700
@@ -194,6 +194,19 @@
-->
</mdr>
+ <!-- Macro to enable Java 5 generics in MDR generated sources -->
+ <macrodef name="uncommentMdrGenerics">
+ <attribute name="javadir" default="/unspecified/path"/>
+ <sequential>
+ <replace dir="@{javadir}">
+ <replacefilter token="/*<" value="<" />
+ <replacefilter token=">*/" value=">" />
+ </replace>
+ </sequential>
+ </macrodef>
+
+ <uncommentMdrGenerics javadir="${build.javas}"/>
+
</target>
<!-- =================================================================== -->
Modified: trunk/src/model-mdr/src/org/argouml/model/mdr/ActivityGraphsHelperMDRImpl.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/model-mdr/src/org/argouml/model/mdr/ActivityGraphsHelperMDRImpl.java?view=diff&rev=13255&p1=trunk/src/model-mdr/src/org/argouml/model/mdr/ActivityGraphsHelperMDRImpl.java&p2=trunk/src/model-mdr/src/org/argouml/model/mdr/ActivityGraphsHelperMDRImpl.java&r1=13254&r2=13255
==============================================================================
--- trunk/src/model-mdr/src/org/argouml/model/mdr/ActivityGraphsHelperMDRImpl.java (original)
+++ trunk/src/model-mdr/src/org/argouml/model/mdr/ActivityGraphsHelperMDRImpl.java 2007-08-06 10:50:41-0700
@@ -40,6 +40,7 @@
import org.omg.uml.foundation.core.Classifier;
import org.omg.uml.foundation.core.ModelElement;
import org.omg.uml.foundation.core.Namespace;
+import org.omg.uml.foundation.core.Parameter;
import org.omg.uml.modelmanagement.UmlPackage;
/**
@@ -136,7 +137,8 @@
public void addInState(Object classifierInState, Object state) {
if (classifierInState instanceof ClassifierInState
&& state instanceof State) {
- ((ClassifierInState) classifierInState).getInState().add(state);
+ ((ClassifierInState) classifierInState).getInState().add(
+ (State) state);
} else {
throw new IllegalArgumentException(
"classifierInState: " + classifierInState
@@ -168,7 +170,7 @@
public void addContent(Object partition, Object modelElement) {
Partition p = (Partition) partition;
- p.getContents().add(modelElement);
+ p.getContents().add((ModelElement) modelElement);
}
public void removeContent(Object partition, Object modelElement) {
@@ -181,7 +183,8 @@
}
public void addParameter(Object objectFlowState, Object parameter) {
- ((ObjectFlowState) objectFlowState).getParameter().add(parameter);
+ ((ObjectFlowState) objectFlowState).getParameter().add(
+ (Parameter) parameter);
}
public void removeParameter(Object objectFlowState, Object parameter) {
Modified: trunk/src/model-mdr/src/org/argouml/model/mdr/CollaborationsFactoryMDRImpl.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/model-mdr/src/org/argouml/model/mdr/CollaborationsFactoryMDRImpl.java?view=diff&rev=13255&p1=trunk/src/model-mdr/src/org/argouml/model/mdr/CollaborationsFactoryMDRImpl.java&p2=trunk/src/model-mdr/src/org/argouml/model/mdr/CollaborationsFactoryMDRImpl.java&r1=13254&r2=13255
==============================================================================
--- trunk/src/model-mdr/src/org/argouml/model/mdr/CollaborationsFactoryMDRImpl.java (original)
+++ trunk/src/model-mdr/src/org/argouml/model/mdr/CollaborationsFactoryMDRImpl.java 2007-08-06 10:50:41-0700
@@ -221,10 +221,8 @@
+ " Collaboration or Operation");
}
- /*
- * @see org.argouml.model.CollaborationsFactory#buildInteraction(java.lang.Object)
- */
- public Object buildInteraction(Object handle) {
+
+ public Interaction buildInteraction(Object handle) {
Collaboration collab = (Collaboration) handle;
Interaction inter = (Interaction) createInteraction();
inter.setContext(collab);
@@ -232,10 +230,8 @@
return inter;
}
- /*
- * @see org.argouml.model.CollaborationsFactory#buildAssociationEndRole(java.lang.Object)
- */
- public Object buildAssociationEndRole(Object atype) {
+
+ public AssociationEndRole buildAssociationEndRole(Object atype) {
ClassifierRole type = (ClassifierRole) atype;
AssociationEndRole end =
(AssociationEndRole) createAssociationEndRole();
@@ -244,11 +240,8 @@
}
- /*
- * @see org.argouml.model.CollaborationsFactory#buildAssociationRole(java.lang.Object,
- * java.lang.Object)
- */
- public Object buildAssociationRole(Object from, Object to) {
+
+ public AssociationRole buildAssociationRole(Object from, Object to) {
return buildAssociationRole((ClassifierRole) from, (ClassifierRole) to);
}
@@ -272,12 +265,8 @@
return role;
}
- /*
- * @see org.argouml.model.CollaborationsFactory#buildAssociationRole(java.lang.Object,
- * java.lang.Object, java.lang.Object, java.lang.Object,
- * java.lang.Boolean)
- */
- public Object buildAssociationRole(Object from, Object agg1, Object to,
+
+ public AssociationRole buildAssociationRole(Object from, Object agg1, Object to,
Object agg2, Boolean unidirectional) {
AggregationKind ak1 = checkAggregationKind(agg1);
@@ -368,12 +357,12 @@
message.setCommunicationConnection(role);
if (role.getConnection().size() == 2) {
- message.setSender((ClassifierRole) ((AssociationEnd) role.
- getConnection().get(0)).getParticipant());
- message.setReceiver((ClassifierRole) ((AssociationEnd) role.
- getConnection().get(1)).getParticipant());
+ message.setSender((ClassifierRole) role.getConnection().get(0)
+ .getParticipant());
+ message.setReceiver((ClassifierRole) role.getConnection().get(1)
+ .getParticipant());
- Collection messages =
+ Collection<Message> messages =
Model.getFacade().getReceivedMessages(message.getSender());
Message lastMsg = lastMessage(messages, message);
@@ -405,11 +394,9 @@
* A Message.
* @return The last message in the collection, or null.
*/
- private Message lastMessage(Collection c, Message m) {
+ private Message lastMessage(Collection<Message> c, Message m) {
Message last = null;
- Iterator it = c.iterator();
- while (it.hasNext()) {
- Message msg = (Message) it.next();
+ for (Message msg : c) {
if (msg != null && msg != m) {
last = msg;
}
@@ -426,20 +413,17 @@
*/
private Message findEnd(Message m) {
while (true) {
- Collection c = Model.getFacade().getSuccessors(m);
- Iterator it = c.iterator();
+ Collection<Message> c = Model.getFacade().getSuccessors(m);
+ Iterator<Message> it = c.iterator();
if (!it.hasNext()) {
return m;
}
- m = (Message) it.next();
+ m = it.next();
}
}
- /*
- * @see org.argouml.model.CollaborationsFactory#buildMessage(java.lang.Object,
- * java.lang.Object)
- */
- public Object buildMessage(Object acollab, Object arole) {
+
+ public Message buildMessage(Object acollab, Object arole) {
if (!(arole instanceof AssociationRole)) {
throw new IllegalArgumentException(
"An association role must be supplied - got " + arole);
@@ -459,22 +443,19 @@
}
}
- private Object buildMessageCollab(Collaboration collab,
+ private Message buildMessageCollab(Collaboration collab,
AssociationRole role) {
Interaction inter = null;
if (collab.getInteraction().size() == 0) {
- inter = (Interaction) buildInteraction(collab);
+ inter = buildInteraction(collab);
} else {
inter = (Interaction) (collab.getInteraction().toArray())[0];
}
return buildMessageInteraction(inter, role);
}
- /*
- * @see org.argouml.model.CollaborationsFactory#buildActivator(java.lang.Object,
- * java.lang.Object)
- */
- public Object buildActivator(Object owner, Object interaction) {
+
+ public Message buildActivator(Object owner, Object interaction) {
Message theOwner = (Message) owner;
Interaction theInteraction;
if (interaction == null) {
Modified: trunk/src/model-mdr/src/org/argouml/model/mdr/CollaborationsHelperMDRImpl.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/model-mdr/src/org/argouml/model/mdr/CollaborationsHelperMDRImpl.java?view=diff&rev=13255&p1=trunk/src/model-mdr/src/org/argouml/model/mdr/CollaborationsHelperMDRImpl.java&p2=trunk/src/model-mdr/src/org/argouml/model/mdr/CollaborationsHelperMDRImpl.java&r1=13254&r2=13255
==============================================================================
--- trunk/src/model-mdr/src/org/argouml/model/mdr/CollaborationsHelperMDRImpl.java (original)
+++ trunk/src/model-mdr/src/org/argouml/model/mdr/CollaborationsHelperMDRImpl.java 2007-08-06 10:50:41-0700
@@ -73,7 +73,7 @@
private MDRModelImplementation modelImpl;
/**
- * Don't allow instantiation.
+ * Constructor.
*
* @param implementation
* To get other helpers and factories.
@@ -83,21 +83,19 @@
}
- public Collection getAllClassifierRoles(Object ns) {
+ public Collection<ClassifierRole> getAllClassifierRoles(Object ns) {
if (!(ns instanceof Namespace)) {
throw new IllegalArgumentException();
}
try {
- List<Object> list = new ArrayList<Object>();
- Iterator it = ((Namespace) ns).getOwnedElement().iterator();
- while (it.hasNext()) {
- Object o = it.next();
+ List<ClassifierRole> list = new ArrayList<ClassifierRole>();
+ for (Object o : ((Namespace) ns).getOwnedElement()) {
if (o instanceof Namespace) {
list.addAll(getAllClassifierRoles(o));
}
if (o instanceof ClassifierRole) {
- list.add(o);
+ list.add((ClassifierRole) o);
}
}
return list;
@@ -132,16 +130,16 @@
}
- public Collection getClassifierRoles(Object role) {
+ public Collection<Classifier> getClassifierRoles(Object role) {
if (role == null) {
- return new ArrayList();
+ return Collections.EMPTY_SET;
}
if (!(role instanceof ClassifierRole)) {
throw new IllegalArgumentException();
}
- List roles = new ArrayList();
+ List<Classifier> roles = new ArrayList<Classifier>();
try {
Collection associationEnds =
Model.getFacade().getAssociationEnds(role);
@@ -200,7 +198,7 @@
}
- public Collection getAllPossibleActivators(Object ames) {
+ public Collection<Message> getAllPossibleActivators(Object ames) {
Message mes = (Message) ames;
if (mes == null || mes.getInteraction() == null) {
return Collections.unmodifiableCollection(Collections.EMPTY_LIST);
@@ -208,16 +206,14 @@
try {
Interaction inter = mes.getInteraction();
- Collection predecessors = mes.getPredecessor();
- Collection allMessages = inter.getMessage();
- Iterator it = allMessages.iterator();
- List list = new ArrayList();
- while (it.hasNext()) {
- Object o = it.next();
- if (!predecessors.contains(o) && mes != o
- && !hasAsActivator(o, mes)
- && !((Message) o).getPredecessor().contains(mes)) {
- list.add(o);
+ Collection<Message> predecessors = mes.getPredecessor();
+ Collection<Message> allMessages = inter.getMessage();
+ List<Message> list = new ArrayList<Message>();
+ for (Message m : allMessages) {
+ if (!predecessors.contains(m) && mes != m
+ && !hasAsActivator(m, mes)
+ && !m.getPredecessor().contains(mes)) {
+ list.add(m);
}
}
return list;
@@ -289,29 +285,29 @@
+ "the original activator");
}
}
- List listToChange = new ArrayList();
- Collection predecessors = mes.getPredecessor();
+ List<Message> listToChange = new ArrayList<Message>();
+ Collection<Message> predecessors = mes.getPredecessor();
listToChange.addAll(predecessors);
listToChange.add(mes);
Interaction inter = mes.getInteraction();
- Collection allMessages = inter.getMessage();
- Iterator it = allMessages.iterator();
+ Collection<Message> allMessages = inter.getMessage();
+ Iterator<Message> it = allMessages.iterator();
while (it.hasNext()) {
- Message mes2 = (Message) it.next();
+ Message mes2 = it.next();
if (mes2.getPredecessor().contains(mes)) {
listToChange.add(mes2);
}
}
it = listToChange.iterator();
while (it.hasNext()) {
- Message mes2 = (Message) it.next();
+ Message mes2 = it.next();
mes2.setActivator(activator);
}
}
- public Collection getAllPossiblePredecessors(Object amessage) {
+ public Collection<Message> getAllPossiblePredecessors(Object amessage) {
Message message = (Message) amessage;
if (message == null) {
throw new IllegalArgumentException(
@@ -321,10 +317,8 @@
try {
Interaction inter = message.getInteraction();
- Iterator it = inter.getMessage().iterator();
- List list = new ArrayList();
- while (it.hasNext()) {
- Message mes = (Message) it.next();
+ List<Message> list = new ArrayList<Message>();
+ for (Message mes : inter.getMessage()) {
if (mes.getActivator() == message.getActivator()
&& message != mes
&& !mes.getPredecessor().contains(message)
@@ -338,10 +332,7 @@
}
}
- /*
- * @see org.argouml.model.CollaborationsHelper#addBase(java.lang.Object,
- * java.lang.Object)
- */
+
public void addBase(Object arole, Object abase) {
ClassifierRole role = (ClassifierRole) arole;
Classifier base = (Classifier) abase;
@@ -379,14 +370,18 @@
while (it.hasNext()) {
ModelElement elem = (ModelElement) it.next();
if (!role.getAvailableContents().contains(elem)) {
- role.getAvailableContents().add(it.next());
+ // TODO: I'm not sure what this is supposed to be doing,
+ // but it looks suspicious - tfm - 20070806
+ role.getAvailableContents().add((ModelElement) it.next());
}
}
it = base.getFeature().iterator();
while (it.hasNext()) {
Feature feature = (Feature) it.next();
if (!role.getAvailableFeature().contains(feature)) {
- role.getAvailableFeature().add(it.next());
+ // TODO: I'm not sure what this is supposed to be doing,
+ // but it looks suspicious - tfm - 20070806
+ role.getAvailableFeature().add((Feature) it.next());
}
}
}
@@ -402,11 +397,11 @@
}
- public Collection allAvailableFeatures(Object arole) {
+ public Collection<Feature> allAvailableFeatures(Object arole) {
if (arole instanceof ClassifierRole) {
try {
- List returnList = new ArrayList();
+ List<Feature> returnList = new ArrayList<Feature>();
ClassifierRole role = (ClassifierRole) arole;
Iterator it =
Model.getFacade().getGeneralizations(arole).iterator();
@@ -416,9 +411,8 @@
returnList.addAll(allAvailableFeatures(genElem));
}
}
- it = role.getBase().iterator();
- while (it.hasNext()) {
- returnList.addAll(((Classifier) it.next()).getFeature());
+ for (Classifier classifier : role.getBase()) {
+ returnList.addAll(classifier.getFeature());
}
return returnList;
} catch (InvalidObjectException e) {
@@ -557,7 +551,7 @@
*/
private Collection getAllPossibleBases(ClassifierRole role) {
if (role == null || modelImpl.getFacade().getNamespace(role) == null) {
- return new ArrayList();
+ return Collections.EMPTY_SET;
}
Collaboration coll = (Collaboration) role.getNamespace();
Namespace ns = coll.getNamespace();
@@ -615,19 +609,17 @@
* @param obj the given namespace
* @return a collection of classifiers
*/
- private Collection getAllImportedClassifiers(Object obj) {
+ private Collection<Classifier> getAllImportedClassifiers(Object obj) {
Collection c = modelImpl.getModelManagementHelper()
.getAllImportedElements(obj);
return filterClassifiers(c);
}
- private Collection filterClassifiers(Collection in) {
- Collection out = new ArrayList();
- Iterator i = in.iterator();
- while (i.hasNext()) {
- Object o = i.next();
- if (modelImpl.getFacade().isAClassifier(o))
- out.add(o);
+ private Collection<Classifier> filterClassifiers(Collection in) {
+ Collection<Classifier> out = new ArrayList<Classifier>();
+ for (Object o : in) {
+ if (o instanceof Classifier)
+ out.add((Classifier) o);
}
return out;
}
@@ -651,8 +643,8 @@
.getSource(role);
ClassifierRole receiver = (ClassifierRole) modelImpl
.getCoreHelper().getDestination(role);
- Collection senderBases = sender.getBase();
- Collection receiverBases = receiver.getBase();
+ Collection<Classifier> senderBases = sender.getBase();
+ Collection<Classifier> receiverBases = receiver.getBase();
AssociationEndRole senderRole = (AssociationEndRole) modelImpl.
getCoreHelper().getAssociationEnd(sender, role);
@@ -660,10 +652,7 @@
getCoreHelper().getAssociationEnd(receiver, role);
if (base != null) {
- Collection baseConnections = base.getConnection();
- Iterator it = baseConnections.iterator();
- while (it.hasNext()) {
- AssociationEnd end = (AssociationEnd) it.next();
+ for (AssociationEnd end : base.getConnection()) {
if (senderBases.contains(end.getParticipant())) {
senderRole.setBase(end);
} else if (receiverBases.contains(end.getParticipant())) {
@@ -780,8 +769,8 @@
public void addConstrainingElement(Object handle, Object constraint) {
if (handle instanceof Collaboration
&& constraint instanceof ModelElement) {
- ((Collaboration) handle).getConstrainingElement().add(constraint);
-
+ ((Collaboration) handle).getConstrainingElement().add(
+ (ModelElement) constraint);
return;
}
@@ -793,8 +782,8 @@
public void addInstance(Object classifierRole, Object instance) {
if (classifierRole instanceof ClassifierRole
&& instance instanceof Instance) {
- ((ClassifierRole) classifierRole).getConformingInstance()
- .add(instance);
+ ((ClassifierRole) classifierRole).getConformingInstance().add(
+ (Instance) instance);
}
throw new IllegalArgumentException("classifierRole: " + classifierRole
+ " or instance: " + instance);
@@ -803,13 +792,11 @@
public void addMessage(Object handle, Object elem) {
if (handle instanceof Interaction && elem instanceof Message) {
- ((Interaction) handle).getMessage().add(elem);
-
+ ((Interaction) handle).getMessage().add((Message) elem);
return;
}
if (handle instanceof AssociationRole && elem instanceof Message) {
- ((AssociationRole) handle).getMessage().add(elem);
-
+ ((AssociationRole) handle).getMessage().add((Message) elem);
return;
}
throw new IllegalArgumentException("handle: " + handle + " or elem: "
@@ -833,7 +820,7 @@
public void addPredecessor(Object handle, Object predecessor) {
if (handle != null && handle instanceof Message && predecessor != null
&& predecessor instanceof Message) {
- ((Message) handle).getPredecessor().add(predecessor);
+ ((Message) handle).getPredecessor().add((Message) predecessor);
return;
}
throw new IllegalArgumentException("handle: " + handle
Modified: trunk/src/model-mdr/src/org/argouml/model/mdr/CommonBehaviorHelperMDRImpl.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/model-mdr/src/org/argouml/model/mdr/CommonBehaviorHelperMDRImpl.java?view=diff&rev=13255&p1=trunk/src/model-mdr/src/org/argouml/model/mdr/CommonBehaviorHelperMDRImpl.java&p2=trunk/src/model-mdr/src/org/argouml/model/mdr/CommonBehaviorHelperMDRImpl.java&r1=13254&r2=13255
==============================================================================
--- trunk/src/model-mdr/src/org/argouml/model/mdr/CommonBehaviorHelperMDRImpl.java (original)
+++ trunk/src/model-mdr/src/org/argouml/model/mdr/CommonBehaviorHelperMDRImpl.java 2007-08-06 10:50:41-0700
@@ -87,9 +87,7 @@
this.modelImpl = implementation;
}
- /*
- * @see org.argouml.model.CommonBehaviorHelper#getSource(java.lang.Object)
- */
+
public Object getSource(Object link) {
try {
if (link instanceof Link) {
@@ -101,9 +99,7 @@
throw new IllegalArgumentException("Argument is not a link");
}
- /*
- * @see org.argouml.model.CommonBehaviorHelper#getDestination(java.lang.Object)
- */
+
public Object getDestination(Object link) {
try {
if (link instanceof Link) {
@@ -115,10 +111,7 @@
throw new IllegalArgumentException("Argument is not a link");
}
- /*
- * @see org.argouml.model.CommonBehaviorHelper#removeActualArgument(java.lang.Object,
- * java.lang.Object)
- */
+
public void removeActualArgument(Object handle, Object argument) {
try {
if (handle instanceof Action && argument instanceof Argument) {
@@ -132,9 +125,7 @@
+ " or " + argument);
}
- /*
- * @see org.argouml.model.CommonBehaviorHelper#setActualArguments(java.lang.Object, java.util.List)
- */
+
public void setActualArguments(Object action, List arguments) {
try {
if (action instanceof Action) {
@@ -149,10 +140,7 @@
+ " or " + arguments);
}
- /*
- * @see org.argouml.model.CommonBehaviorHelper#removeClassifier(java.lang.Object,
- * java.lang.Object)
- */
+
public void removeClassifier(Object handle, Object classifier) {
try {
if (handle instanceof Instance
@@ -167,10 +155,7 @@
+ " or " + classifier);
}
- /*
- * @see org.argouml.model.CommonBehaviorHelper#removeContext(java.lang.Object,
- * java.lang.Object)
- */
+
public void removeContext(Object handle, Object context) {
try {
if (handle instanceof Signal
@@ -187,10 +172,7 @@
+ " or " + context);
}
- /*
- * @see org.argouml.model.CommonBehaviorHelper#removeReception(java.lang.Object,
- * java.lang.Object)
- */
+
public void removeReception(Object handle, Object reception) {
try {
if (handle instanceof Signal && reception instanceof Reception) {
@@ -206,43 +188,34 @@
+ " or " + reception);
}
- /*
- * @see org.argouml.model.CommonBehaviorHelper#addActualArgument(java.lang.Object,
- * java.lang.Object)
- */
+
public void addActualArgument(Object handle, Object argument) {
if (handle instanceof Action && argument instanceof Argument) {
- ((Action) handle).getActualArgument().add(argument);
+ ((Action) handle).getActualArgument().add((Argument) argument);
return;
}
throw new IllegalArgumentException("Unrecognized object " + handle
+ " or " + argument);
}
- /*
- * @see org.argouml.model.CommonBehaviorHelper#addActualArgument(
- * java.lang.Object, int, java.lang.Object)
- */
- public void addActualArgument(Object handle, int position,
- Object argument) {
- if (!(handle instanceof Action)
- || !(argument instanceof Argument)) {
+
+ public void addActualArgument(Object handle, int position, Object argument) {
+ if (handle instanceof Action && argument instanceof Argument) {
+ try {
+ ((Action) handle).getActualArgument().add(position,
+ (Argument) argument);
+ } catch (InvalidObjectException e) {
+ throw new InvalidElementException(e);
+ }
+ } else {
throw new IllegalArgumentException();
}
- try {
- ((Action) handle).getActualArgument().add(position, argument);
- } catch (InvalidObjectException e) {
- throw new InvalidElementException(e);
- }
}
- /*
- * @see org.argouml.model.CommonBehaviorHelper#addClassifier(java.lang.Object,
- * java.lang.Object)
- */
+
public void addClassifier(Object handle, Object classifier) {
if (handle instanceof Instance && classifier instanceof Classifier) {
- ((Instance) handle).getClassifier().add(classifier);
+ ((Instance) handle).getClassifier().add((Classifier) classifier);
return;
}
throw new IllegalArgumentException("Unrecognized object " + handle
@@ -283,10 +256,7 @@
}
}
- /*
- * @see org.argouml.model.CommonBehaviorHelper#addStimulus(java.lang.Object,
- * java.lang.Object)
- */
+
public void addStimulus(Object handle, Object stimulus) {
if (handle != null && stimulus != null
&& stimulus instanceof Stimulus) {
@@ -303,10 +273,7 @@
+ " or stimulus: " + stimulus);
}
- /*
- * @see org.argouml.model.CommonBehaviorHelper#setAsynchronous(java.lang.Object,
- * boolean)
- */
+
public void setAsynchronous(Object handle, boolean value) {
if (handle instanceof Action) {
((Action) handle).setAsynchronous(value);
@@ -315,10 +282,7 @@
throw new IllegalArgumentException("handle: " + handle);
}
- /*
- * @see org.argouml.model.CommonBehaviorHelper#setOperation(java.lang.Object,
- * java.lang.Object)
- */
+
public void setOperation(Object handle, Object operation) {
if (handle instanceof CallAction
&& (operation == null || operation instanceof Operation)) {
@@ -334,35 +298,17 @@
+ " or operation: " + operation);
}
- /*
- * @see org.argouml.model.CommonBehaviorHelper#setClassifiers(java.lang.Object,
- * java.util.Vector)
- */
- public void setClassifiers(Object handle, Vector v) {
+
+ public void setClassifiers(Object handle, Vector classifiers) {
if (handle instanceof Instance) {
- Collection actualClassifiers = Model.getFacade().getClassifiers(
- handle);
- if (!actualClassifiers.isEmpty()) {
- Vector classifiers = new Vector();
- classifiers.addAll(actualClassifiers);
- Iterator toRemove = classifiers.iterator();
- while (toRemove.hasNext())
- removeClassifier(handle, toRemove.next());
- }
- if (!v.isEmpty()) {
- Iterator toAdd = v.iterator();
- while (toAdd.hasNext())
- addClassifier(handle, toAdd.next());
- }
+ ((Instance) handle).getClassifier().retainAll(classifiers);
+ ((Instance) handle).getClassifier().addAll(classifiers);
return;
}
throw new IllegalArgumentException("handle: " + handle);
}
- /*
- * @see org.argouml.model.CommonBehaviorHelper#setCommunicationLink(java.lang.Object,
- * java.lang.Object)
- */
+
public void setCommunicationLink(Object handle, Object c) {
if (handle instanceof Stimulus && c instanceof Link) {
((Stimulus) handle).setCommunicationLink((Link) c);
@@ -371,10 +317,7 @@
throw new IllegalArgumentException("handle: " + handle + " or c: " + c);
}
- /*
- * @see org.argouml.model.CommonBehaviorHelper#setComponentInstance(java.lang.Object,
- * java.lang.Object)
- */
+
public void setComponentInstance(Object handle, Object c) {
if (handle instanceof Instance
&& (c == null || c instanceof ComponentInstance)) {
@@ -384,10 +327,7 @@
throw new IllegalArgumentException("handle: " + handle + " or c: " + c);
}
- /*
- * @see org.argouml.model.CommonBehaviorHelper#setContexts(java.lang.Object,
- * java.util.Collection)
- */
+
public void setContexts(Object handle, Collection c) {
if (handle instanceof Signal) {
Collection actualContexts = Model.getFacade().getContexts(handle);
@@ -408,10 +348,7 @@
throw new IllegalArgumentException("handle: " + handle);
}
- /*
- * @see org.argouml.model.CommonBehaviorHelper#setDispatchAction(java.lang.Object,
- * java.lang.Object)
- */
+
public void setDispatchAction(Object handle, Object value) {
if (handle instanceof Stimulus
&& (value == null || value instanceof Action)) {
@@ -422,10 +359,7 @@
+ value);
}
- /*
- * @see org.argouml.model.CommonBehaviorHelper#setInstance(java.lang.Object,
- * java.lang.Object)
- */
+
public void setInstance(Object handle, Object inst) {
if (inst == null || inst instanceof Instance) {
if (handle instanceof LinkEnd) {
@@ -480,10 +414,7 @@
+ " or receiver: " + receiver);
}
- /*
- * @see org.argouml.model.CommonBehaviorHelper#setReception(java.lang.Object,
- * java.util.Collection)
- */
+
public void setReception(Object handle, Collection c) {
if (handle instanceof Signal) {
Collection actualReceptions =
@@ -505,10 +436,7 @@
throw new IllegalArgumentException("handle: " + handle);
}
- /*
- * @see org.argouml.model.CommonBehaviorHelper#setRecurrence(java.lang.Object,
- * java.lang.Object)
- */
+
public void setRecurrence(Object handle, Object expr) {
if (handle instanceof Action && expr instanceof IterationExpression) {
((Action) handle).setRecurrence((IterationExpression) expr);
@@ -518,10 +446,7 @@
+ expr);
}
- /*
- * @see org.argouml.model.CommonBehaviorHelper#setScript(java.lang.Object,
- * java.lang.Object)
- */
+
public void setScript(Object handle, Object expr) {
if (handle instanceof Action
&& (expr == null || expr instanceof ActionExpression)) {
@@ -532,10 +457,7 @@
+ expr);
}
- /*
- * @see org.argouml.model.CommonBehaviorHelper#setSender(java.lang.Object,
- * java.lang.Object)
- */
+
public void setSender(Object handle, Object sender) {
if (handle instanceof Message
&& (sender instanceof ClassifierRole || sender == null)) {
@@ -550,10 +472,7 @@
+ sender);
}
- /*
- * @see org.argouml.model.CommonBehaviorHelper#setSignal(java.lang.Object,
- * java.lang.Object)
- */
+
public void setSignal(Object handle, Object signal) {
if (signal == null || signal instanceof Signal) {
if (handle instanceof SendAction) {
@@ -573,10 +492,7 @@
+ signal);
}
- /*
- * @see org.argouml.model.CommonBehaviorHelper#setSpecification(java.lang.Object,
- * java.lang.String)
- */
+
public void setSpecification(Object handle, String specification) {
if (handle instanceof Reception) {
((Reception) handle).setSpecification(specification);
@@ -585,10 +501,7 @@
throw new IllegalArgumentException("handle: " + handle);
}
- /*
- * @see org.argouml.model.CommonBehaviorHelper#setTarget(java.lang.Object,
- * java.lang.Object)
- */
+
public void setTarget(Object handle, Object element) {
if (handle instanceof Action
&& element instanceof ObjectSetExpression) {
@@ -603,10 +516,7 @@
+ " or element: " + element);
}
- /*
- * @see org.argouml.model.CommonBehaviorHelper#setTransition(java.lang.Object,
- * java.lang.Object)
- */
+
public void setTransition(Object handle, Object trans) {
if (trans instanceof Transition) {
if (handle instanceof Guard) {
@@ -622,10 +532,7 @@
+ trans);
}
- /*
- * @see org.argouml.model.CommonBehaviorHelper#setValue(java.lang.Object,
- * java.lang.Object)
- */
+
public void setValue(Object handle, Object value) {
if (handle instanceof Argument) {
((Argument) handle).setValue((Expression) value);
@@ -644,10 +551,8 @@
+ value);
}
- /*
- * @see CommonBehaviorHelper#getInstantiation(Object)
- */
- public Object getInstantiation(Object createaction) {
+
+ public Classifier getInstantiation(Object createaction) {
try {
if (createaction instanceof CreateAction) {
return ((CreateAction) createaction).getInstantiation();
@@ -658,9 +563,7 @@
throw new IllegalArgumentException("handle: " + createaction);
}
- /*
- * @see CommonBehaviorHelper#setInstantiation(Object, Object)
- */
+
public void setInstantiation(Object createaction, Object instantiation) {
if (createaction instanceof CreateAction) {
if (instantiation instanceof Classifier) {
@@ -677,9 +580,7 @@
}
- /*
- * @see org.argouml.model.CommonBehaviorHelper#getActionOwner(java.lang.Object)
- */
+
public Object getActionOwner(Object action) {
if (!(action instanceof Action)) {
throw new IllegalArgumentException();
@@ -714,7 +615,7 @@
throw new IllegalArgumentException();
}
try {
- ((ActionSequence) handle).getAction().add(action);
+ ((ActionSequence) handle).getAction().add((Action) action);
} catch (InvalidObjectException e) {
throw new InvalidElementException(e);
}
@@ -726,7 +627,8 @@
throw new IllegalArgumentException();
}
try {
- ((ActionSequence) handle).getAction().add(position, action);
+ ((ActionSequence) handle).getAction()
+ .add(position, (Action) action);
} catch (InvalidObjectException e) {
throw new InvalidElementException(e);
}
Modified: trunk/src/model-mdr/src/org/argouml/model/mdr/CoreFactoryMDRImpl.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/model-mdr/src/org/argouml/model/mdr/CoreFactoryMDRImpl.java?view=diff&rev=13255&p1=trunk/src/model-mdr/src/org/argouml/model/mdr/CoreFactoryMDRImpl.java&p2=trunk/src/model-mdr/src/org/argouml/model/mdr/CoreFactoryMDRImpl.java&r1=13254&r2=13255
==============================================================================
--- trunk/src/model-mdr/src/org/argouml/model/mdr/CoreFactoryMDRImpl.java (original)
+++ trunk/src/model-mdr/src/org/argouml/model/mdr/CoreFactoryMDRImpl.java 2007-08-06 10:50:41-0700
@@ -137,7 +137,7 @@
}
- public Object createAbstraction() {
+ public Abstraction createAbstraction() {
Abstraction myAbstraction = corePackage.getAbstraction()
.createAbstraction();
super.initialize(myAbstraction);
@@ -145,7 +145,7 @@
}
- public Object buildAbstraction(String name, Object supplier,
+ public Abstraction buildAbstraction(String name, Object supplier,
Object client) {
if (!(client instanceof Classifier)
|| !(supplier instanceof Classifier)) {
@@ -153,22 +153,22 @@
"The supplier and client of an abstraction"
+ "should be classifiers");
}
- Abstraction abstraction = (Abstraction) createAbstraction();
+ Abstraction abstraction = createAbstraction();
abstraction.setName(name);
- abstraction.getClient().add(client);
- abstraction.getSupplier().add(supplier);
+ abstraction.getClient().add((Classifier) client);
+ abstraction.getSupplier().add((Classifier) supplier);
return abstraction;
}
- public Object createArtifact() {
+ public Artifact createArtifact() {
Artifact artifact = corePackage.getArtifact().createArtifact();
super.initialize(artifact);
return artifact;
}
- public Object createAssociation() {
+ public UmlAssociation createAssociation() {
UmlAssociation assoc = corePackage.getUmlAssociation()
.createUmlAssociation();
super.initialize(assoc);
@@ -432,7 +432,7 @@
throw new IllegalArgumentException("one of "
+ "the classifiers does not " + "belong to a namespace");
}
- UmlAssociation assoc = (UmlAssociation) createAssociation();
+ UmlAssociation assoc = createAssociation();
assoc.setName("");
assoc.setNamespace((Namespace) modelImpl.getCoreHelper().
getFirstSharedNamespace(ns1, ns2));
@@ -466,7 +466,7 @@
throw new IllegalArgumentException("one of "
+ "the classifiers does not " + "belong to a namespace");
}
- UmlAssociation assoc = (UmlAssociation) createAssociation();
+ UmlAssociation assoc = createAssociation();
assoc.setName("");
assoc.setNamespace((Namespace) modelImpl.getCoreHelper().
getFirstSharedNamespace(ns1, ns2));
@@ -535,13 +535,7 @@
}
- /*
- * @see org.argouml.model.CoreFactory#buildAssociationEnd(java.lang.Object,
- * java.lang.String, java.lang.Object, java.lang.Object,
- * java.lang.Object, boolean, java.lang.Object, java.lang.Object,
- * java.lang.Object, java.lang.Object, java.lang.Object)
- */
- public Object buildAssociationEnd(Object assoc, String name, Object type,
+ public AssociationEnd buildAssociationEnd(Object assoc, String name, Object type,
Object multi, Object stereo, boolean navigable, Object order,
Object aggregation, Object scope, Object changeable,
Object visibility) {
@@ -582,11 +576,9 @@
+ "association is navigable away from "
+ "that end.");
}
- List ends = new ArrayList();
+ List<AssociationEnd> ends = new ArrayList<AssociationEnd>();
ends.addAll(((UmlAssociation) assoc).getConnection());
- Iterator it = ends.iterator();
- while (it.hasNext()) {
- AssociationEnd end = (AssociationEnd) it.next();
+ for (AssociationEnd end : ends) {
if (end.isNavigable()) {
throw new IllegalArgumentException("type is either "
+ "datatype or " + "interface and is "
@@ -612,7 +604,7 @@
}
if (stereo != null) {
end.getStereotype().clear();
- end.getStereotype().add(stereo);
+ end.getStereotype().add((Stereotype) stereo);
}
end.setNavigable(navigable);
if (order != null) {
@@ -652,8 +644,8 @@
*/
private int getMaxUpper(Multiplicity m) {
int max = 0;
- for (Iterator i = m.getRange().iterator(); i.hasNext();) {
- int value = ((MultiplicityRange) i.next()).getUpper();
+ for (MultiplicityRange mr : m.getRange()) {
+ int value = mr.getUpper();
if (value > max) {
max = value;
}
@@ -991,7 +983,7 @@
private Permission buildPermissionInternal(ModelElement client,
ModelElement supplier) {
- Permission permission = (Permission) createPermission();
+ Permission permission = createPermission();
permission.getSupplier().add(supplier);
permission.getClient().add(client);
if (client instanceof Namespace) {
@@ -1020,29 +1012,22 @@
}
- public Object buildGeneralization(Object child, Object parent,
+ public Generalization buildGeneralization(Object child, Object parent,
String name) {
if (child == null || parent == null
|| !(child instanceof GeneralizableElement)
|| !(parent instanceof GeneralizableElement)) {
throw new IllegalArgumentException();
}
- Object gen = buildGeneralization(child, parent);
+ Generalization gen = buildGeneralization(child, parent);
if (gen != null) {
- ((Generalization) gen).setName(name);
+ gen.setName(name);
}
return gen;
}
- /*
- * @see org.argouml.model.CoreFactory#buildGeneralization(java.lang.Object,
- * java.lang.Object)
- *
- * The well-formedness rules should move to
- * UmlFactoryMDRImpl.isConnectionWellFormed and buildGeneralization should
- * become private.
- */
- public Object buildGeneralization(Object child1, Object parent1) {
+
+ public Generalization buildGeneralization(Object child1, Object parent1) {
// TODO: This is a part implementation of well-formedness rule
// UML1.4.2 - 4.5.3.20 [3] Circular inheritance is not allowed.
// not self.allParents->includes(self)
@@ -1060,9 +1045,7 @@
// TODO: This is a part implementation of well-formedness rule
// UML1.4.2 - 4.5.3.20 [3] Circular inheritance is not allowed.
// not self.allParents->includes(self)
- Iterator it = parent.getGeneralization().iterator();
- while (it.hasNext()) {
- Generalization gen = (Generalization) it.next();
+ for (Generalization gen : parent.getGeneralization()) {
if (gen.getParent().equals(child)) {
throw new IllegalArgumentException("Generalization exists"
+ " in opposite direction");
@@ -1096,10 +1079,8 @@
return gen;
}
- /*
- * @see org.argouml.model.CoreFactory#buildMethod(java.lang.String)
- */
- public Object buildMethod(String name) {
+
+ public Method buildMethod(String name) {
Method method = (Method) createMethod();
if (method != null) {
method.setName(name);
@@ -1109,13 +1090,13 @@
@SuppressWarnings("deprecation")
- public Object buildOperation(Object classifier, Object model,
+ public Operation buildOperation(Object classifier, Object model,
Object returnType) {
return buildOperation(classifier, returnType);
}
- public Object buildOperation(Object classifier, Object returnType) {
+ public Operation buildOperation(Object classifier, Object returnType) {
if (!(classifier instanceof Classifier)) {
throw new IllegalArgumentException("Handle is not a classifier");
}
@@ -1131,8 +1112,7 @@
oper.setOwnerScope(ScopeKindEnum.SK_INSTANCE);
oper.setConcurrency(CallConcurrencyKindEnum.CCK_SEQUENTIAL);
- Parameter returnParameter = (Parameter) buildParameter(oper,
- returnType);
+ Parameter returnParameter = buildParameter(oper, returnType);
returnParameter.setKind(ParameterDirectionKindEnum.PDK_RETURN);
returnParameter.setName("return");
return oper;
@@ -1140,16 +1120,16 @@
@SuppressWarnings("deprecation")
- public Object buildOperation(Object cls, Object model, Object returnType,
+ public Operation buildOperation(Object cls, Object model, Object returnType,
String name) {
return buildOperation2(cls, returnType, name);
}
- public Object buildOperation2(Object cls, Object returnType, String name) {
- Object oper = buildOperation(cls, returnType);
+ public Operation buildOperation2(Object cls, Object returnType, String name) {
+ Operation oper = buildOperation(cls, returnType);
if (oper != null) {
- ((Operation) oper).setName(name);
+ oper.setName(name);
}
return oper;
}
@@ -1159,7 +1139,7 @@
*
* @return The newly created parameter.
*/
- private Object buildParameter(Classifier type) {
+ private Parameter buildParameter(Classifier type) {
Parameter param = corePackage.getParameter().createParameter();
param.setType(type);
return param;
@@ -1167,21 +1147,21 @@
@SuppressWarnings("deprecation")
- public Object buildParameter(Object o, Object model, Object type) {
+ public Parameter buildParameter(Object o, Object model, Object type) {
return buildParameter(o, type);
}
- public Object buildParameter(Object o, Object type) {
+ public Parameter buildParameter(Object o, Object type) {
if (o instanceof Event) {
Event event = (Event) o;
- Parameter res = (Parameter) buildParameter((Classifier) type);
+ Parameter res = buildParameter((Classifier) type);
res.setKind(ParameterDirectionKindEnum.PDK_IN);
event.getParameter().add(res);
return res;
} else if (o instanceof BehavioralFeature) {
BehavioralFeature oper = (BehavioralFeature) o;
- Parameter res = (Parameter) buildParameter((Classifier) type);
+ Parameter res = buildParameter((Classifier) type);
oper.getParameter().add(res);
res.setName("arg" + oper.getParameter().size());
return res;
@@ -1191,14 +1171,14 @@
}
- public Object buildRealization(Object clnt, Object spplr, Object model) {
+ public Abstraction buildRealization(Object clnt, Object spplr, Object model) {
ModelElement client = (ModelElement) clnt;
ModelElement supplier = (ModelElement) spplr;
if (client == null || supplier == null || client.getNamespace() == null
|| supplier.getNamespace() == null) {
throw new IllegalArgumentException("faulty arguments.");
}
- Abstraction realization = (Abstraction) createAbstraction();
+ Abstraction realization = createAbstraction();
Namespace nsc = client.getNamespace();
Namespace nss = supplier.getNamespace();
// TODO: Shouldn't this use this computed nsc value below? - tfm
@@ -1224,7 +1204,7 @@
}
- public Object buildUsage(Object client, Object supplier) {
+ public Usage buildUsage(Object client, Object supplier) {
if (client == null || supplier == null) {
throw new IllegalArgumentException("In buildUsage null arguments.");
}
@@ -1237,8 +1217,8 @@
// TODO: UML 1.4 spec requires both client and supplier to be
// in the same model - tfm
Usage usage = (Usage) createUsage();
- usage.getSupplier().add(supplier);
- usage.getClient().add(client);
+ usage.getSupplier().add((ModelElement) supplier);
+ usage.getClient().add((ModelElement) client);
if (((ModelElement) supplier).getNamespace() != null) {
usage.setNamespace(((ModelElement) supplier).getNamespace());
} else if (((ModelElement) client).getNamespace() != null) {
@@ -1249,11 +1229,8 @@
return usage;
}
- /*
- * @see org.argouml.model.CoreFactory#buildComment(java.lang.Object,
- * java.lang.Object)
- */
- public Object buildComment(Object element, Object model) {
+
+ public Comment buildComment(Object element, Object model) {
if (model == null) {
throw new IllegalArgumentException("A namespace must be supplied.");
}
@@ -1272,10 +1249,8 @@
return comment;
}
- /*
- * @see org.argouml.model.CoreFactory#buildConstraint(java.lang.Object)
- */
- public Object buildConstraint(Object constrElement) {
+
+ public Constraint buildConstraint(Object constrElement) {
ModelElement constrainedElement = (ModelElement) constrElement;
if (constrainedElement == null) {
throw new IllegalArgumentException("the constrained element is "
@@ -1287,11 +1262,8 @@
return con;
}
- /*
- * @see org.argouml.model.CoreFactory#buildConstraint(java.lang.String,
- * java.lang.Object)
- */
- public Object buildConstraint(String name, Object bexpr) {
+
+ public Constraint buildConstraint(String name, Object bexpr) {
if (bexpr == null || !(bexpr instanceof BooleanExpression)) {
throw new IllegalArgumentException("invalid boolean expression.");
}
@@ -1304,10 +1276,10 @@
}
- public Object buildBinding(Object client, Object supplier, List arguments) {
- Collection clientDeps = ((ModelElement) client).getClientDependency();
- for (Iterator it = clientDeps.iterator(); it.hasNext();) {
- Object dep = it.next();
+ public Binding buildBinding(Object client, Object supplier, List arguments) {
+ Collection<Dependency> clientDeps = ((ModelElement) client)
+ .getClientDependency();
+ for (Dependency dep : clientDeps) {
if (dep instanceof Binding) {
throw new IllegalArgumentException(
"client is already client of another Binding");
@@ -1317,16 +1289,15 @@
// Check arguments against parameters for type and number
// TODO: Perhaps move this to a critic instead? - tfm - 20070326
if (arguments != null) {
- Collection params =
+ Collection<TemplateParameter> params =
((ModelElement) supplier).getTemplateParameter();
if (params.size() != arguments.size()) {
throw new IllegalArgumentException(
"number of arguments doesn't match number of params");
}
- Iterator ita = arguments.iterator();
- for (Iterator itp = params.iterator(); itp.hasNext();) {
- TemplateParameter param = (TemplateParameter) itp.next();
- TemplateArgument ta = (TemplateArgument) ita.next();
+ Iterator<TemplateArgument> ita = arguments.iterator();
+ for (TemplateParameter param : params) {
+ TemplateArgument ta = ita.next();
// TODO: Before allowing this, we should really check that
// TemplateParameter.defaultElement is defined
if (ta == null || ta.getModelElement() == null) {
@@ -1341,8 +1312,8 @@
}
Binding binding = (Binding) createBinding();
- binding.getClient().add(client);
- binding.getSupplier().add(supplier);
+ binding.getClient().add((ModelElement) client);
+ binding.getSupplier().add((ModelElement) supplier);
if (arguments != null) {
binding.getArgument().addAll(arguments);
}
@@ -1680,11 +1651,9 @@
}
// Delete dependencies where this is the only client
- Collection deps = org.argouml.model.Model.getFacade()
+ Collection<Dependency> deps = org.argouml.model.Model.getFacade()
.getClientDependencies(elem);
- Iterator it = deps.iterator();
- while (it.hasNext()) {
- Dependency dep = (Dependency) it.next();
+ for (Dependency dep : deps) {
if (dep.getClient().size() < 2
&& dep.getClient().contains(elem)) {
modelImpl.getUmlFactory().delete(dep);
@@ -1694,9 +1663,7 @@
// Delete dependencies where this is the only supplier
deps = org.argouml.model.Model.getFacade()
.getSupplierDependencies(elem);
- it = deps.iterator();
- while (it.hasNext()) {
- Dependency dep = (Dependency) it.next();
+ for (Dependency dep : deps) {
if (dep.getSupplier().size() < 2
&& dep.getSupplier().contains(elem)) {
modelImpl.getUmlFactory().delete(dep);
@@ -1730,14 +1697,13 @@
throw new IllegalArgumentException("elem: " + elem);
}
- List ownedElements = new ArrayList();
+ List<ModelElement> ownedElements = new ArrayList<ModelElement>();
// TODO: This is a composite association, so these will get deleted
// automatically. The only thing we need to do is check for any
// additional elements that need to be deleted as a result.
ownedElements.addAll(((Namespace) elem).getOwnedElement());
- Iterator it = ownedElements.iterator();
- while (it.hasNext()) {
- modelImpl.getUmlFactory().delete(it.next());
+ for (ModelElement element : ownedElements) {
+ modelImpl.getUmlFactory().delete(element);
}
}
Modified: trunk/src/model-mdr/src/org/argouml/model/mdr/CoreHelperMDRImpl.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/model-mdr/src/org/argouml/model/mdr/CoreHelperMDRImpl.java?view=diff&rev=13255&p1=trunk/src/model-mdr/src/org/argouml/model/mdr/CoreHelperMDRImpl.java&p2=trunk/src/model-mdr/src/org/argouml/model/mdr/CoreHelperMDRImpl.java&r1=13254&r2=13255
==============================================================================
--- trunk/src/model-mdr/src/org/argouml/model/mdr/CoreHelperMDRImpl.java (original)
+++ trunk/src/model-mdr/src/org/argouml/model/mdr/CoreHelperMDRImpl.java 2007-08-06 10:50:41-0700
@@ -225,16 +225,14 @@
return result;
}
- public Collection getSupertypes(Object ogeneralizableelement) {
- Collection result = new HashSet();
- try {
- if (ogeneralizableelement instanceof GeneralizableElement) {
- Iterator genIterator =
- modelImpl.getFacade().getGeneralizations(
- ogeneralizableelement).iterator();
- while (genIterator.hasNext()) {
- Generalization next = (Generalization) genIterator.next();
- result.add(next.getParent());
+ public Collection<GeneralizableElement> getSupertypes(Object genElement) {
+ Collection<GeneralizableElement> result =
+ new HashSet<GeneralizableElement>();
+ try {
+ if (genElement instanceof GeneralizableElement) {
+ for (Generalization gen : ((GeneralizableElement) genElement)
+ .getGeneralization()) {
+ result.add(gen.getParent());
}
}
} catch (InvalidObjectException e) {
@@ -244,7 +242,7 @@
}
- public Collection getAssociateEnds(Object classifier) {
+ public Collection<AssociationEnd> getAssociateEnds(Object classifier) {
if (!(classifier instanceof Classifier)) {
throw new IllegalArgumentException();
}
@@ -252,21 +250,17 @@
}
- public Collection getAssociateEndsInh(Object classifier1) {
+ public Collection<AssociationEnd> getAssociateEndsInh(Object classifier1) {
if (!(classifier1 instanceof Classifier)) {
throw new IllegalArgumentException();
}
Classifier classifier = (Classifier) classifier1;
-
- Collection result = new ArrayList();
+ Collection<AssociationEnd> result = new ArrayList<AssociationEnd>();
try {
result.addAll(getAssociateEnds(classifier));
- Collection generalizations =
- Model.getFacade().getGeneralizations(classifier);
- Iterator genIter = generalizations.iterator();
- while (genIter.hasNext()) {
- Object parent = Model.getFacade().getParent(genIter.next());
+ for (Generalization gen : classifier.getGeneralization()) {
+ Object parent = gen.getParent();
result.addAll(getAssociateEndsInh(parent));
}
} catch (InvalidObjectException e) {
@@ -275,10 +269,7 @@
return result;
}
- /*
- * @see org.argouml.model.CoreHelper#removeFeature( java.lang.Object,
- * java.lang.Object)
- */
+
public void removeFeature(Object cls, Object feature) {
try {
if (cls instanceof Classifier && feature instanceof Feature) {
@@ -292,10 +283,7 @@
+ " or feature: " + feature);
}
- /*
- * @see org.argouml.model.CoreHelper#removeLiteral(java.lang.Object,
- * java.lang.Object)
- */
+
public void removeLiteral(Object enu, Object literal) {
try {
if (enu instanceof Enumeration
@@ -310,17 +298,13 @@
+ " or literal: " + literal);
}
- /*
- * @see org.argouml.model.CoreHelper#setOperations( java.lang.Object,
- * java.util.List)
- */
+
public void setOperations(Object classifier, List operations) {
if (classifier instanceof Classifier) {
Classifier mclassifier = (Classifier) classifier;
- List result = new ArrayList(mclassifier.getFeature());
- Iterator features = mclassifier.getFeature().iterator();
- while (features.hasNext()) {
- Feature feature = (Feature) features.next();
+ List<Feature> result =
+ new ArrayList<Feature>(mclassifier.getFeature());
+ for (Feature feature : mclassifier.getFeature()) {
if (feature instanceof Operation) {
result.remove(feature);
}
@@ -340,10 +324,9 @@
public void setAttributes(Object classifier, List attributes) {
if (classifier instanceof Classifier) {
Classifier mclassifier = (Classifier) classifier;
- List result = new ArrayList(mclassifier.getFeature());
- Iterator features = mclassifier.getFeature().iterator();
- while (features.hasNext()) {
- Feature feature = (Feature) features.next();
+ List<Feature> result =
+ new ArrayList<Feature>(mclassifier.getFeature());
+ for (Feature feature : mclassifier.getFeature()) {
if (feature instanceof Attribute) {
result.remove(feature);
}
@@ -357,7 +340,7 @@
}
- public Collection getAttributesInh(Object classifier) {
+ public Collection<Attribute> getAttributesInh(Object classifier) {
if (!(classifier instanceof Classifier)) {
throw new IllegalArgumentException();
@@ -367,13 +350,9 @@
try {
result.addAll(modelImpl.getFacade().getStructuralFeatures(
classifier));
-
- Collection generalizations =
- Model.getFacade().getGeneralizations(classifier);
- Iterator genIter = generalizations.iterator();
- while (genIter.hasNext()) {
- Object parent = Model.getFacade().getParent(genIter.next());
- result.addAll(getAttributesInh(parent));
+ for (Generalization gen : ((Classifier) classifier)
+ .getGeneralization()) {
+ result.addAll(getAttributesInh(gen.getParent()));
}
} catch (InvalidObjectException e) {
throw new InvalidElementException(e);
@@ -382,21 +361,17 @@
}
- public Collection getOperationsInh(Object classifier) {
+ public Collection<Operation> getOperationsInh(Object classifier) {
if (!(classifier instanceof Classifier)) {
throw new IllegalArgumentException();
}
- Collection result = new ArrayList();
+ Collection<Operation> result = new ArrayList<Operation>();
try {
result.addAll(modelImpl.getFacade().getOperations(classifier));
-
- Collection generalizations =
- Model.getFacade().getGeneralizations(classifier);
- Iterator genIter = generalizations.iterator();
- while (genIter.hasNext()) {
- Object parent = Model.getFacade().getParent(genIter.next());
- result.addAll(getOperationsInh(parent));
+ for (Generalization gen : ((Classifier) classifier)
+ .getGeneralization()) {
+ result.addAll(getOperationsInh(gen.getParent()));
}
} catch (InvalidObjectException e) {
throw new InvalidElementException(e);
@@ -405,9 +380,7 @@
}
- /*
- * @see org.argouml.model.CoreHelper#getParent(java.lang.Object)
- */
+
public Collection<GeneralizableElement> getParents(
Object generalizableElement) {
if (!(generalizableElement instanceof GeneralizableElement)) {
@@ -422,15 +395,12 @@
return result;
}
- public List getReturnParameters(Object operation) {
- List returnParams = new ArrayList();
+ public List<Parameter> getReturnParameters(Object operation) {
+ List<Parameter> returnParams = new ArrayList<Parameter>();
try {
- Iterator params =
- ((Operation) operation).getParameter().iterator();
- while (params.hasNext()) {
- Parameter parameter = (Parameter) params.next();
- if (ParameterDirectionKindEnum.PDK_RETURN.equals(parameter.
- getKind())) {
+ for (Parameter parameter : ((Operation) operation).getParameter()) {
+ if (ParameterDirectionKindEnum.PDK_RETURN.equals(parameter
+ .getKind())) {
returnParams.add(parameter);
}
}
@@ -461,18 +431,18 @@
}
- public Collection getSubtypes(Object cls) {
+ public Collection<GeneralizableElement> getSubtypes(Object cls) {
if (!(cls instanceof Classifier)) {
throw new IllegalArgumentException();
}
- Collection result = new ArrayList();
+ Collection<GeneralizableElement> result =
+ new ArrayList<GeneralizableElement>();
try {
- Collection gens = Model.getFacade().getSpecializations(cls);
- Iterator genIterator = gens.iterator();
- while (genIterator.hasNext()) {
- Generalization next = (Generalization) genIterator.next();
- result.add(next.getChild());
+ Collection<Generalization> gens = Model.getFacade()
+ .getSpecializations(cls);
+ for (Generalization gen : gens) {
+ result.add(gen.getChild());
}
} catch (InvalidObjectException e) {
throw new InvalidElementException(e);
@@ -481,12 +451,12 @@
}
- public Collection getAllBehavioralFeatures(Object element) {
+ public Collection<BehavioralFeature> getAllBehavioralFeatures(Object element) {
if (!(element instanceof ModelElement)) {
throw new IllegalArgumentException();
}
List contents = new ArrayList();
- List list = new ArrayList();
+ List<BehavioralFeature> result = new ArrayList<BehavioralFeature>();
try {
contents.addAll(Model.getFacade()
.getTaggedValuesCollection(element));
@@ -497,35 +467,31 @@
if (o instanceof Classifier) {
Classifier clazz = (Classifier) o;
if (!(clazz instanceof DataType)) {
- Iterator it1 = clazz.getFeature().iterator();
- while (it1.hasNext()) {
- Object o1 = it1.next();
+ for (Object o1 : clazz.getFeature()) {
if (o1 instanceof BehavioralFeature) {
- list.add(o1);
+ result.add((BehavioralFeature) o1);
}
}
}
} else {
- list.addAll(getAllBehavioralFeatures(it.next()));
+ // TODO: 2nd next() for single hasNext()
+ result.addAll(getAllBehavioralFeatures(it.next()));
}
}
} catch (InvalidObjectException e) {
throw new InvalidElementException(e);
}
- return list;
+ return result;
}
- public List getBehavioralFeatures(Object clazz) {
+ public List<BehavioralFeature> getBehavioralFeatures(Object clazz) {
if (clazz instanceof Classifier) {
- List ret = new ArrayList();
+ List<BehavioralFeature> ret = new ArrayList<BehavioralFeature>();
try {
- Iterator it =
- modelImpl.getFacade().getFeatures(clazz).iterator();
- while (it.hasNext()) {
- Object o = it.next();
+ for (Object o : modelImpl.getFacade().getFeatures(clazz)) {
if (o instanceof BehavioralFeature) {
- ret.add(o);
+ ret.add((BehavioralFeature) o);
}
}
} catch (InvalidObjectException e) {
@@ -538,82 +504,71 @@
}
- public Collection getAllInterfaces(Object ns) {
+ public Collection<Interface> getAllInterfaces(Object ns) {
if (ns == null) {
- return new ArrayList();
+ return Collections.EMPTY_SET;
}
if (!(ns instanceof Namespace)) {
throw new IllegalArgumentException();
}
-
- Iterator it = ((Namespace) ns).getOwnedElement().iterator();
- List list = new ArrayList();
- while (it.hasNext()) {
- Object o = it.next();
+ List<Interface> result = new ArrayList<Interface>();
+ for (Object o : ((Namespace) ns).getOwnedElement()) {
if (o instanceof Namespace) {
- list.addAll(getAllInterfaces(o));
+ result.addAll(getAllInterfaces(o));
}
if (o instanceof Interface) {
- list.add(o);
+ result.add((Interface) o);
}
}
- return list;
+ return result;
}
- public Collection getAllClasses(Object ns) {
+ public Collection<UmlClass> getAllClasses(Object ns) {
if (ns == null) {
- return new ArrayList();
+ return Collections.EMPTY_SET;
}
if (!(ns instanceof Namespace)) {
throw new IllegalArgumentException();
}
- List list = new ArrayList();
+ List<UmlClass> result = new ArrayList<UmlClass>();
try {
- Iterator it = ((Namespace) ns).getOwnedElement().iterator();
- while (it.hasNext()) {
- Object o = it.next();
+ for (Object o : ((Namespace) ns).getOwnedElement()) {
if (o instanceof Namespace) {
- list.addAll(getAllClasses(o));
+ result.addAll(getAllClasses(o));
}
if (o instanceof UmlClass) {
- list.add(o);
+ result.add((UmlClass) o);
}
}
} catch (InvalidObjectException e) {
throw new InvalidElementException(e);
}
- return list;
+ return result;
}
- public Collection getRealizedInterfaces(Object cls) {
+ public Collection<Interface> getRealizedInterfaces(Object cls) {
Classifier classifier = (Classifier) cls;
if (classifier == null) {
return Collections.EMPTY_LIST;
}
- List list = new ArrayList();
+ List<Interface> result = new ArrayList<Interface>();
try {
- Iterator it = classifier.getClientDependency().iterator();
- while (it.hasNext()) {
- Object clientDependency = it.next();
+ for (Dependency clientDependency : classifier.getClientDependency()) {
if (clientDependency instanceof Abstraction) {
Abstraction abstraction = (Abstraction) clientDependency;
- Collection stereos = abstraction.getStereotype();
- for (Iterator s = stereos.iterator(); s.hasNext();) {
- Stereotype stereo = (Stereotype) s.next();
+ for (Stereotype stereo : abstraction.getStereotype()) {
if (stereo != null
&& CoreFactory.REALIZE_STEREOTYPE.equals(stereo
.getName())
// the following should always be true
&& stereo.getBaseClass()
.contains("Abstraction")) {
- Iterator it2 = abstraction.getSupplier().iterator();
- while (it2.hasNext()) {
- Object supplier = it2.next();
+ for (Object supplier : abstraction.getSupplier()) {
if (supplier instanceof Interface) {
- list.add(supplier);
+ result.add((Interface) supplier);
}
}
}
@@ -623,29 +578,28 @@
} catch (InvalidObjectException e) {
throw new InvalidElementException(e);
}
- return list;
+ return result;
}
- public Collection getExtendedClassifiers(Object clazz) {
+ public Collection<Classifier> getExtendedClassifiers(Object clazz) {
if (clazz == null) {
- return new ArrayList();
+ return Collections.EMPTY_SET;
}
- List list = new ArrayList();
+ List<Classifier> result = new ArrayList<Classifier>();
try {
- Iterator it =
- modelImpl.getFacade().getGeneralizations(clazz).iterator();
- while (it.hasNext()) {
- Generalization gen = (Generalization) it.next();
- GeneralizableElement parent = gen.getParent();
+ for (Object gen : modelImpl.getFacade().getGeneralizations(clazz)) {
+ GeneralizableElement parent = ((Generalization) gen).getParent();
if (parent != null) {
- list.add(parent);
+ // If we were handed a Classifier to start,
+ // this must be a Classifier
+ result.add((Classifier) parent);
}
}
} catch (InvalidObjectException e) {
throw new InvalidElementException(e);
}
- return list;
+ return result;
}
@@ -689,7 +643,7 @@
}
- public Collection getFlows(Object source, Object target) {
+ public Collection<Flow> getFlows(Object source, Object target) {
if (!(source instanceof ModelElement)) {
throw new IllegalArgumentException("source");
}
@@ -697,12 +651,10 @@
throw new IllegalArgumentException("target");
}
- List ret = new ArrayList();
+ List<Flow> ret = new ArrayList<Flow>();
try {
- Collection targetFlows = ((ModelElement) target).getTargetFlow();
- Iterator it = ((ModelElement) source).getSourceFlow().iterator();
- while (it.hasNext()) {
- Flow flow = (Flow) it.next();
+ Collection<Flow> targetFlows = ((ModelElement) target).getTargetFlow();
+ for (Flow flow : ((ModelElement) source).getSourceFlow()) {
if (targetFlows.contains(flow)) {
ret.add(flow);
}
@@ -716,7 +668,7 @@
public Collection getExtendingElements(Object clazz) {
if (clazz == null) {
- return new ArrayList();
+ return Collections.EMPTY_SET;
}
List list = new ArrayList();
try {
@@ -737,118 +689,107 @@
}
- public Collection getExtendingClassifiers(Object clazz) {
+ public Collection<Classifier> getExtendingClassifiers(Object clazz) {
if (clazz == null) {
- return new ArrayList();
+ return Collections.EMPTY_SET;
}
if (!(clazz instanceof Classifier)) {
throw new IllegalArgumentException();
}
- List list = new ArrayList();
+ List<Classifier> result = new ArrayList<Classifier>();
try {
- Collection specializations =
- Model.getFacade().getSpecializations(clazz);
- Iterator it = specializations.iterator();
- while (it.hasNext()) {
- Generalization gen = (Generalization) it.next();
- GeneralizableElement client = gen.getChild();
+ for (Object gen : Model.getFacade().getSpecializations(clazz)) {
+ GeneralizableElement client = ((Generalization) gen).getChild();
if (client instanceof Classifier) {
- list.add(client);
+ result.add((Classifier) client);
}
}
} catch (InvalidObjectException e) {
throw new InvalidElementException(e);
}
- return list;
+ return result;
}
- public Collection getAllComponents(Object ns) {
+ public Collection<Component> getAllComponents(Object ns) {
if (ns == null) {
- return new ArrayList();
+ return Collections.EMPTY_SET;
}
if (!(ns instanceof Namespace)) {
throw new IllegalArgumentException();
}
- List list = new ArrayList();
+ List<Component> result = new ArrayList<Component>();
try {
- Iterator it = ((Namespace) ns).getOwnedElement().iterator();
-
- while (it.hasNext()) {
- Object o = it.next();
+ for (Object o : ((Namespace) ns).getOwnedElement()) {
if (o instanceof Namespace) {
- list.addAll(getAllComponents(o));
+ result.addAll(getAllComponents(o));
}
if (o instanceof Component) {
- list.add(o);
+ result.add((Component) o);
}
}
} catch (InvalidObjectException e) {
throw new InvalidElementException(e);
}
- return list;
+ return result;
}
- public Collection getAllDataTypes(Object ns) {
+ public Collection<DataType> getAllDataTypes(Object ns) {
if (ns == null) {
- return new ArrayList();
+ return Collections.EMPTY_SET;
}
if (!(ns instanceof Namespace)) {
throw new IllegalArgumentException();
}
- List list = new ArrayList();
+ List<DataType> result = new ArrayList<DataType>();
try {
- Iterator it = ((Namespace) ns).getOwnedElement().iterator();
- while (it.hasNext()) {
- Object o = it.next();
+ for (Object o : ((Namespace) ns).getOwnedElement()) {
if (o instanceof Namespace) {
- list.addAll(getAllDataTypes(o));
+ result.addAll(getAllDataTypes(o));
}
if (o instanceof DataType) {
- list.add(o);
+ result.add((DataType) o);
}
}
} catch (InvalidObjectException e) {
throw new InvalidElementException(e);
}
- return list;
+ return result;
}
- public Collection getAllNodes(Object ns) {
+ public Collection<Node> getAllNodes(Object ns) {
if (ns == null) {
- return new ArrayList();
+ return Collections.EMPTY_SET;
}
if (!(ns instanceof Namespace)) {
throw new IllegalArgumentException();
}
- List list = new ArrayList();
+ List<Node> result = new ArrayList<Node>();
try {
- Iterator it = ((Namespace) ns).getOwnedElement().iterator();
- while (it.hasNext()) {
- Object o = it.next();
+ for (Object o : ((Namespace) ns).getOwnedElement()) {
if (o instanceof Namespace) {
- list.addAll(getAllNodes(o));
+ result.addAll(getAllNodes(o));
}
if (o instanceof Node) {
- list.add(o);
+ result.add((Node) o);
}
}
} catch (InvalidObjectException e) {
throw new InvalidElementException(e);
}
- return list;
+ return result;
}
public Collection getAssociatedClassifiers(Object aclassifier) {
Classifier classifier = (Classifier) aclassifier;
if (classifier == null) {
- return Collections.EMPTY_LIST;
+ return Collections.EMPTY_SET;
}
List list = new ArrayList();
try {
@@ -898,45 +839,40 @@
}
- public Collection getAllClassifiers(Object namespace) {
+ public Collection<Classifier> getAllClassifiers(Object namespace) {
if (namespace == null) {
throw new IllegalArgumentException();
}
- List list = new ArrayList();
+ List<Classifier> result = new ArrayList<Classifier>();
try {
- Namespace ns = (Namespace) namespace;
- Iterator it = ns.getOwnedElement().iterator();
- while (it.hasNext()) {
- Object o = it.next();
+ for (Object o : ((Namespace) namespace).getOwnedElement()) {
if (o instanceof Namespace) {
- list.addAll(getAllClassifiers(o));
+ result.addAll(getAllClassifiers(o));
}
if (o instanceof Classifier) {
- list.add(o);
+ result.add((Classifier) o);
}
}
} catch (InvalidObjectException e) {
throw new InvalidElementException(e);
}
- return list;
+ return result;
}
- public Collection getAssociations(Object oclassifier) {
- Collection col = new ArrayList();
+ public Collection<UmlAssociation> getAssociations(Object oclassifier) {
+ Collection<UmlAssociation> result = new ArrayList<UmlAssociation>();
try {
if (oclassifier instanceof Classifier) {
- Classifier classifier = (Classifier) oclassifier;
- Iterator it = Model.getFacade().getAssociationEnds(classifier)
- .iterator();
- while (it.hasNext()) {
- col.add(((AssociationEnd) it.next()).getAssociation());
+ for (Object end : Model.getFacade().getAssociationEnds(
+ oclassifier)) {
+ result.add(((AssociationEnd) end).getAssociation());
}
}
} catch (InvalidObjectException e) {
throw new InvalidElementException(e);
}
- return col;
+ return result;
}
@@ -966,7 +902,7 @@
@SuppressWarnings("deprecation")
public Collection getAllContents(Object clazz) {
if (clazz == null) {
- return new ArrayList();
+ return Collections.EMPTY_SET;
}
if (!(clazz instanceof Classifier)) {
throw new IllegalArgumentException();
@@ -975,26 +911,23 @@
}
- public Collection getAllAttributes(Object clazz) {
+ public Collection<Attribute> getAllAttributes(Object clazz) {
if (clazz == null) {
- return new ArrayList();
+ return Collections.EMPTY_SET;
}
if (!(clazz instanceof Classifier)) {
throw new IllegalArgumentException();
}
- List list = new ArrayList();
+ List<Attribute> list = new ArrayList<Attribute>();
try {
- Iterator it = ((Classifier) clazz).getFeature().iterator();
- while (it.hasNext()) {
- Feature element = (Feature) it.next();
- if (element instanceof Attribute) {
- list.add(element);
+ for (Feature feature : ((Classifier) clazz).getFeature()) {
+ if (feature instanceof Attribute) {
+ list.add((Attribute) feature);
}
}
- it = modelImpl.getFacade().getGeneralizations(clazz).iterator();
- while (it.hasNext()) {
- list.addAll(getAllAttributes(it.next()));
+ for (Object gen : modelImpl.getFacade().getGeneralizations(clazz)) {
+ list.addAll(getAllAttributes(gen));
}
} catch (InvalidObjectException e) {
throw new InvalidElementException(e);
@@ -1003,16 +936,14 @@
}
- public Collection getAllVisibleElements(Object ns) {
+ public Collection<ModelElement> getAllVisibleElements(Object ns) {
if (!(ns instanceof Namespace)) {
throw new IllegalArgumentException();
}
- List list = new ArrayList();
+ List<ModelElement> list = new ArrayList<ModelElement>();
try {
- Iterator it = ((Namespace) ns).getOwnedElement().iterator();
- while (it.hasNext()) {
- ModelElement element = (ModelElement) it.next();
+ for (ModelElement element : ((Namespace) ns).getOwnedElement()) {
if (element.getVisibility()
.equals(VisibilityKindEnum.VK_PUBLIC)) {
list.add(element);
@@ -1048,11 +979,11 @@
}
if (relationship instanceof UmlAssociation) {
UmlAssociation assoc = (UmlAssociation) relationship;
- List conns = assoc.getConnection();
+ List<AssociationEnd> conns = assoc.getConnection();
if (conns == null || conns.isEmpty()) {
return null;
}
- return ((AssociationEnd) conns.get(0)).getParticipant();
+ return conns.get(0).getParticipant();
}
if (relationship instanceof Generalization) {
Generalization gen = (Generalization) relationship;
@@ -1060,19 +991,19 @@
}
if (relationship instanceof Dependency) {
Dependency dep = (Dependency) relationship;
- Collection col = dep.getClient();
+ Collection<ModelElement> col = dep.getClient();
if (col.isEmpty()) {
return null;
}
- return (col.toArray())[0];
+ return col.iterator().next();
}
if (relationship instanceof Flow) {
Flow flow = (Flow) relationship;
- Collection col = flow.getSource();
+ Collection<ModelElement> col = flow.getSource();
if (col.isEmpty()) {
return null;
}
- return (col.toArray())[0];
+ return col.iterator().next();
}
if (relationship instanceof Extend) {
Extend extend = (Extend) relationship;
@@ -1124,11 +1055,11 @@
if (relationship instanceof UmlAssociation) {
UmlAssociation assoc = (UmlAssociation) relationship;
- List conns = assoc.getConnection();
+ List<AssociationEnd> conns = assoc.getConnection();
if (conns.size() <= 1) {
return null;
}
- return ((AssociationEnd) conns.get(1)).getParticipant();
+ return conns.get(1).getParticipant();
}
if (relationship instanceof Generalization) {
Generalization gen = (Generalization) relationship;
@@ -1136,7 +1067,7 @@
}
if (relationship instanceof Dependency) {
Dependency dep = (Dependency) relationship;
- Collection col = dep.getSupplier();
+ Collection<ModelElement> col = dep.getSupplier();
if (col.isEmpty()) {
return null;
}
@@ -1144,7 +1075,7 @@
}
if (relationship instanceof Flow) {
Flow flow = (Flow) relationship;
- Collection col = flow.getTarget();
+ Collection<ModelElement> col = flow.getTarget();
if (col.isEmpty()) {
return null;
}
@@ -1184,7 +1115,8 @@
List<Dependency> ret = new ArrayList<Dependency>();
try {
- Collection clientDependencies = client.getClientDependency();
+ Collection<Dependency> clientDependencies = client
+ .getClientDependency();
Iterator it =
Model.getFacade().getSupplierDependencies(supplier).iterator();
while (it.hasNext()) {
@@ -1205,7 +1137,7 @@
}
List<Permission> result = new ArrayList<Permission>();
try {
- for (Dependency dependency : (Collection<Dependency>) ((ModelElement) client)
+ for (Dependency dependency : ((ModelElement) client)
.getClientDependency()) {
if (dependency instanceof Permission
&& Model.getExtensionMechanismsHelper().hasStereotype(
@@ -1462,14 +1394,11 @@
* @return true if the given namespace may contain the collaboration
*/
private boolean isValidNamespace(Collaboration collab, Namespace ns) {
- Iterator it = collab.getOwnedElement().iterator();
- while (it.hasNext()) {
- ModelElement m = (ModelElement) it.next();
+ for (ModelElement m : collab.getOwnedElement()) {
if (m instanceof ClassifierRole) {
ClassifierRole role = (ClassifierRole) m;
- Iterator it2 = role.getBase().iterator();
- while (it2.hasNext()) {
- if (!ns.getOwnedElement().contains(it2.next())) {
+ for (Classifier base : role.getBase()) {
+ if (!ns.getOwnedElement().contains(base)) {
return false;
}
}
@@ -1515,8 +1444,7 @@
private boolean isValidNamespace(UmlAssociation assoc, Namespace ns) {
List<Namespace> namespaces = new ArrayList<Namespace>();
- for (AssociationEnd end
- : (List<AssociationEnd>) assoc.getConnection()) {
+ for (AssociationEnd end : assoc.getConnection()) {
namespaces.add(end.getParticipant().getNamespace());
}
if (namespaces.size() < 2) {
@@ -1537,12 +1465,11 @@
Namespace namespace) {
CorePackage corePackage = modelImpl.getUmlPackage().getCore();
- Collection generalizations =
+ Collection<Generalization> generalizations =
corePackage.getAChildGeneralization().
getGeneralization(generalizableElement);
- for (Iterator it = generalizations.iterator(); it.hasNext(); ) {
- Generalization generalization = (Generalization) it.next();
+ for (Generalization generalization : generalizations) {
/* TODO: Fix the following problem, as described in issue 3772:
* Both implementations for valid namespace check whether
* the parents are owned by the namespace. This is invalid.
@@ -1623,8 +1550,8 @@
* Return a list of namespaces enclosing this element.
* The list is ordered outer to inner. i.e. it starts at the root model.
*/
- private List getPath(ModelElement element) {
- LinkedList path = new LinkedList();
+ private List<ModelElement> getPath(ModelElement element) {
+ LinkedList<ModelElement> path = new LinkedList<ModelElement>();
path.add(element);
Namespace ns = element.getNamespace();
while (ns != null) {
@@ -2021,7 +1948,7 @@
public void addAnnotatedElement(Object comment, Object annotatedElement) {
if (comment instanceof Comment
&& annotatedElement instanceof ModelElement) {
- ((Comment) comment).getAnnotatedElement().add(annotatedElement);
+ ((Comment) comment).getAnnotatedElement().add((ModelElement) annotatedElement);
return;
}
throw new IllegalArgumentException("comment: " + comment
@@ -2031,7 +1958,7 @@
public void addClient(Object handle, Object element) {
if (handle instanceof Dependency && element instanceof ModelElement) {
- ((Dependency) handle).getClient().add(element);
+ ((Dependency) handle).getClient().add((ModelElement) element);
return;
}
throw new IllegalArgumentException("handle: " + handle
@@ -2042,7 +1969,7 @@
public void addClientDependency(Object handle, Object dependency) {
if (handle instanceof ModelElement
&& dependency instanceof Dependency) {
- ((ModelElement) handle).getClientDependency().add(dependency);
+ ((ModelElement) handle).getClientDependency().add((Dependency) dependency);
return;
}
throw new IllegalArgumentException("handle: " + handle
@@ -2052,7 +1979,7 @@
public void addComment(Object element, Object comment) {
if (element instanceof ModelElement && comment instanceof Comment) {
- ((ModelElement) element).getComment().add(comment);
+ ((ModelElement) element).getComment().add((Comment) comment);
return;
}
throw new IllegalArgumentException("element: " + element);
@@ -2062,11 +1989,11 @@
public void addConnection(Object handle, Object connection) {
if (handle instanceof UmlAssociation
&& connection instanceof AssociationEnd) {
- ((UmlAssociation) handle).getConnection().add(connection);
+ ((UmlAssociation) handle).getConnection().add((AssociationEnd) connection);
return;
}
if (handle instanceof Link && connection instanceof LinkEnd) {
- ((Link) handle).getConnection().add(connection);
+ ((Link) handle).getConnection().add((LinkEnd) connection);
return;
}
throw new IllegalArgumentException("handle: " + handle
@@ -2077,7 +2004,8 @@
public void addConnection(Object handle, int position, Object connection) {
if (handle instanceof UmlAssociation
&& connection instanceof AssociationEnd) {
- ((UmlAssociation) handle).getConnection().add(position, connection);
+ ((UmlAssociation) handle).getConnection().add(position,
+ (AssociationEnd) connection);
return;
}
/* Strange, but the Link.getConnection()
@@ -2085,7 +2013,7 @@
* This is a bug, compared to the UML standard (IMHO, mvw).
* Hence, the LinkEnd is added to the end instead... */
if (handle instanceof Link && connection instanceof LinkEnd) {
- ((Link) handle).getConnection().add(connection);
+ ((Link) handle).getConnection().add((LinkEnd) connection);
return;
}
throw new IllegalArgumentException("handle: " + handle
@@ -2095,7 +2023,7 @@
public void addConstraint(Object handle, Object mc) {
if (handle instanceof ModelElement && mc instanceof Constraint) {
- ((ModelElement) handle).getConstraint().add(mc);
+ ((ModelElement) handle).getConstraint().add((Constraint) mc);
return;
}
throw new IllegalArgumentException("handle: " + handle + " or mc: "
@@ -2105,7 +2033,7 @@
public void addDeploymentLocation(Object handle, Object node) {
if (handle instanceof Component && node instanceof Node) {
- ((Component) handle).getDeploymentLocation().add(node);
+ ((Component) handle).getDeploymentLocation().add((Node) node);
return;
}
throw new IllegalArgumentException("handle: " + handle + " or node: "
@@ -2164,7 +2092,7 @@
public void addFeature(Object handle, int index, Object f) {
if (handle instanceof Classifier && f instanceof Feature) {
- ((Classifier) handle).getFeature().add(index, f);
+ ((Classifier) handle).getFeature().add(index, (Feature) f);
return;
}
throw new IllegalArgumentException("handle: " + handle + " or f: " + f);
@@ -2174,7 +2102,8 @@
public void addLiteral(Object handle, int index, Object literal) {
if (handle instanceof Enumeration
&& literal instanceof EnumerationLiteral) {
- ((Enumeration) handle).getLiteral().add(index, literal);
+ ((Enumeration) handle).getLiteral().add(index,
+ (EnumerationLiteral) literal);
return;
}
throw new IllegalArgumentException("enumeration: " + handle
@@ -2184,7 +2113,7 @@
public void addFeature(Object handle, Object f) {
if (handle instanceof Classifier && f instanceof Feature) {
- ((Classifier) handle).getFeature().add(f);
+ ((Classifier) handle).getFeature().add((Feature) f);
return;
}
throw new IllegalArgumentException("handle: " + handle);
@@ -2228,12 +2157,13 @@
public void addParameter(Object handle, int index, Object parameter) {
if (parameter instanceof Parameter) {
if (handle instanceof Event) {
- ((Event) handle).getParameter().add(index, parameter);
+ ((Event) handle).getParameter().add(index,
+ (Parameter) parameter);
return;
}
if (handle instanceof BehavioralFeature) {
((BehavioralFeature) handle).getParameter().add(index,
- parameter);
+ (Parameter) parameter);
return;
}
}
@@ -2245,15 +2175,17 @@
public void addParameter(Object handle, Object parameter) {
if (parameter instanceof Parameter) {
if (handle instanceof ObjectFlowState) {
- ((ObjectFlowState) handle).getParameter().add(parameter);
+ ((ObjectFlowState) handle).getParameter().add(
+ (Parameter) parameter);
return;
}
if (handle instanceof Event) {
- ((Event) handle).getParameter().add(parameter);
+ ((Event) handle).getParameter().add((Parameter) parameter);
return;
}
if (handle instanceof BehavioralFeature) {
- ((BehavioralFeature) handle).getParameter().add(parameter);
+ ((BehavioralFeature) handle).getParameter().add(
+ (Parameter) parameter);
return;
}
if (handle instanceof Classifier) {
@@ -2271,7 +2203,7 @@
if (qualifier instanceof Attribute) {
if (handle instanceof AssociationEnd) {
((AssociationEnd) handle).getQualifier().add(index,
- qualifier);
+ (Attribute) qualifier);
return;
}
}
@@ -2302,7 +2234,7 @@
public void addSourceFlow(Object handle, Object flow) {
if (handle instanceof ModelElement && flow instanceof Flow) {
- ((ModelElement) handle).getSourceFlow().add(flow);
+ ((ModelElement) handle).getSourceFlow().add((Flow) flow);
return;
}
@@ -2313,7 +2245,7 @@
public void addSupplier(Object handle, Object element) {
if (handle instanceof Dependency && element instanceof ModelElement) {
- ((Dependency) handle).getSupplier().add(element);
+ ((Dependency) handle).getSupplier().add((ModelElement) element);
return;
}
throw new IllegalArgumentException("handle: " + handle
@@ -2324,7 +2256,8 @@
public void addSupplierDependency(Object supplier, Object dependency) {
if (supplier instanceof ModelElement
&& dependency instanceof Dependency) {
- ((Dependency) dependency).getSupplier().add(supplier);
+ ((Dependency) dependency).getSupplier()
+ .add((ModelElement) supplier);
return;
}
throw new IllegalArgumentException("supplier: " + supplier
@@ -2341,7 +2274,7 @@
public void addTargetFlow(Object handle, Object flow) {
if (handle instanceof ModelElement && flow instanceof Flow) {
- ((ModelElement) handle).getTargetFlow().add(flow);
+ ((ModelElement) handle).getTargetFlow().add((Flow) flow);
return;
}
@@ -2352,7 +2285,8 @@
public void addTemplateArgument(Object handle, int index, Object argument) {
if (argument instanceof TemplateArgument) {
if (handle instanceof Binding) {
- ((Binding) handle).getArgument().add(index, argument);
+ ((Binding) handle).getArgument().add(index,
+ (TemplateArgument) argument);
return;
}
}
@@ -2364,7 +2298,7 @@
public void addTemplateArgument(Object handle, Object argument) {
if (argument instanceof TemplateArgument
&& handle instanceof Binding) {
- ((Binding) handle).getArgument().add(argument);
+ ((Binding) handle).getArgument().add((TemplateArgument) argument);
return;
}
throw new IllegalArgumentException("handle: " + handle
@@ -2377,7 +2311,7 @@
if (parameter instanceof TemplateParameter) {
if (handle instanceof ModelElement) {
((ModelElement) handle).getTemplateParameter().add(
- index, parameter);
+ index, (TemplateParameter) parameter);
return;
}
}
@@ -2389,7 +2323,8 @@
public void addTemplateParameter(Object handle, Object parameter) {
if (parameter instanceof TemplateParameter) {
if (handle instanceof ModelElement) {
- ((ModelElement) handle).getTemplateParameter().add(parameter);
+ ((ModelElement) handle).getTemplateParameter().add(
+ (TemplateParameter) parameter);
return;
}
}
@@ -2606,7 +2541,7 @@
public void setFeature(Object elem, int i, Object impl) {
if (elem instanceof Classifier && impl instanceof Feature) {
- ((Classifier) elem).getFeature().add(i, impl);
+ ((Classifier) elem).getFeature().add(i, (Feature) impl);
return;
}
@@ -2684,10 +2619,11 @@
((Partition) handle).setActivityGraph((ActivityGraph) container);
} else if (handle instanceof ModelElement
&& container instanceof Partition) {
- ((Partition) container).getContents().add(handle);
+ ((Partition) container).getContents().add((ModelElement) handle);
} else if (handle instanceof Constraint
&& container instanceof Stereotype) {
- ((Stereotype) container).getStereotypeConstraint().add(handle);
+ ((Stereotype) container).getStereotypeConstraint().add(
+ (Constraint) handle);
} else if (handle instanceof Interaction
&& container instanceof Collaboration) {
((Interaction) handle).setContext((Collaboration) container);
@@ -2709,7 +2645,7 @@
} else if (handle instanceof TaggedValue
&& container instanceof Stereotype) {
((TaggedValue) handle).getStereotype().clear();
- ((TaggedValue) handle).getStereotype().add(container);
+ ((TaggedValue) handle).getStereotype().add((Stereotype) container);
} else if (handle instanceof TaggedValue
&& container instanceof ModelElement) {
((TaggedValue) handle).setModelElement((ModelElement) container);
@@ -2720,7 +2656,8 @@
&& container instanceof UmlPackage) {
((ElementImport) handle).setUmlPackage((UmlPackage) container);
} else if (handle instanceof Transition && container instanceof State) {
- ((State) container).getInternalTransition().add(handle);
+ ((State) container).getInternalTransition()
+ .add((Transition) handle);
} else if (handle instanceof State
&& container instanceof StateMachine) {
((State) handle).setStateMachine((StateMachine) container);
@@ -2851,7 +2788,8 @@
setNamespace(handle, null);
((TagDefinition) handle).setOwner((Stereotype) owner);
if (owner != null) {
- ((Stereotype) owner).getDefinedTag().add(handle);
+ ((Stereotype) owner).getDefinedTag()
+ .add((TagDefinition) handle);
}
return;
}
Modified: trunk/src/model-mdr/src/org/argouml/model/mdr/DataTypesFactoryMDRImpl.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/model-mdr/src/org/argouml/model/mdr/DataTypesFactoryMDRImpl.java?view=diff&rev=13255&p1=trunk/src/model-mdr/src/org/argouml/model/mdr/DataTypesFactoryMDRImpl.java&p2=trunk/src/model-mdr/src/org/argouml/model/mdr/DataTypesFactoryMDRImpl.java&r1=13254&r2=13255
==============================================================================
--- trunk/src/model-mdr/src/org/argouml/model/mdr/DataTypesFactoryMDRImpl.java (original)
+++ trunk/src/model-mdr/src/org/argouml/model/mdr/DataTypesFactoryMDRImpl.java 2007-08-06 10:50:41-0700
@@ -61,7 +61,7 @@
private MDRModelImplementation modelImpl;
/**
- * Don't allow instantiation.
+ * Constructor.
*
* @param implementation
* To get other helpers and factories.
@@ -70,9 +70,7 @@
this.modelImpl = implementation;
}
- /*
- * @see org.argouml.model.DataTypesFactory#createActionExpression(java.lang.String, java.lang.String)
- */
+
public Object createActionExpression(String language, String body) {
ActionExpression myActionExpression = modelImpl.getUmlPackage()
.getDataTypes().getActionExpression()
@@ -81,9 +79,7 @@
return myActionExpression;
}
- /*
- * @see org.argouml.model.DataTypesFactory#createArgListsExpression(java.lang.String, java.lang.String)
- */
+
public Object createArgListsExpression(String language, String body) {
ArgListsExpression myArgListsExpression = modelImpl.getUmlPackage()
.getDataTypes().getArgListsExpression()
@@ -92,9 +88,7 @@
return myArgListsExpression;
}
- /*
- * @see org.argouml.model.DataTypesFactory#createBooleanExpression(java.lang.String, java.lang.String)
- */
+
public Object createBooleanExpression(String language, String body) {
BooleanExpression myBooleanExpression = modelImpl.getUmlPackage()
.getDataTypes().getBooleanExpression()
@@ -103,9 +97,7 @@
return myBooleanExpression;
}
- /*
- * @see org.argouml.model.DataTypesFactory#createExpression(java.lang.String, java.lang.String)
- */
+
public Object createExpression(String language, String body) {
Expression myExpression = modelImpl.getUmlPackage().getDataTypes()
.getExpression().createExpression(language, body);
@@ -113,10 +105,7 @@
return myExpression;
}
- /*
- * @see org.argouml.model.DataTypesFactory#createIterationExpression(java.lang.String,
- * java.lang.String)
- */
+
public Object createIterationExpression(String language, String body) {
IterationExpression myIterationExpression = modelImpl.getUmlPackage()
.getDataTypes().getIterationExpression()
@@ -125,9 +114,7 @@
return myIterationExpression;
}
- /*
- * @see org.argouml.model.DataTypesFactory#createMappingExpression(java.lang.String, java.lang.String)
- */
+
public Object createMappingExpression(String language, String body) {
MappingExpression myMappingExpression = modelImpl.getUmlPackage()
.getDataTypes().getMappingExpression().createMappingExpression(
@@ -136,9 +123,7 @@
return myMappingExpression;
}
- /*
- * @see org.argouml.model.DataTypesFactory#createObjectSetExpression(java.lang.String, java.lang.String)
- */
+
public Object createObjectSetExpression(String language, String body) {
ObjectSetExpression myObjectSetExpression = modelImpl.getUmlPackage()
.getDataTypes().getObjectSetExpression()
@@ -147,9 +132,7 @@
return myObjectSetExpression;
}
- /*
- * @see org.argouml.model.DataTypesFactory#createProcedureExpression(java.lang.String, java.lang.String)
- */
+
public Object createProcedureExpression(String language, String body) {
ProcedureExpression myProcedureExpression = modelImpl.getUmlPackage()
.getDataTypes().getProcedureExpression()
@@ -158,9 +141,7 @@
return myProcedureExpression;
}
- /*
- * @see org.argouml.model.DataTypesFactory#createTimeExpression(java.lang.String, java.lang.String)
- */
+
public Object createTimeExpression(String language, String body) {
TimeExpression myTimeExpression = modelImpl.getUmlPackage()
.getDataTypes().getTimeExpression()
@@ -169,9 +150,7 @@
return myTimeExpression;
}
- /*
- * @see org.argouml.model.DataTypesFactory#createTypeExpression(java.lang.String, java.lang.String)
- */
+
public Object createTypeExpression(String language, String body) {
TypeExpression myTypeExpression = modelImpl.getUmlPackage()
.getDataTypes().getTypeExpression()
@@ -180,10 +159,8 @@
return myTypeExpression;
}
- /*
- * @see org.argouml.model.DataTypesFactory#createMultiplicity(int, int)
- */
- public Object createMultiplicity(int lower, int upper) {
+
+ public Multiplicity createMultiplicity(int lower, int upper) {
Multiplicity multiplicity = modelImpl.getUmlPackage().getDataTypes()
.getMultiplicity().createMultiplicity();
multiplicity.getRange().add(createMultiplicityRange(lower, upper));
@@ -198,7 +175,7 @@
*
* @see org.argouml.model.DataTypesFactory#createMultiplicity(java.util.List)
*/
- public Object createMultiplicity(List range) {
+ public Multiplicity createMultiplicity(List range) {
Multiplicity multiplicity = modelImpl.getUmlPackage().getDataTypes()
.getMultiplicity().createMultiplicity();
multiplicity.getRange().addAll(range);
@@ -206,10 +183,8 @@
return multiplicity;
}
- /*
- * @see org.argouml.model.DataTypesFactory#createMultiplicity(java.lang.String)
- */
- public Object createMultiplicity(String str) {
+
+ public Multiplicity createMultiplicity(String str) {
List ranges = Collections.unmodifiableList(parseRanges(str));
return createMultiplicity(ranges);
}
@@ -228,11 +203,8 @@
return rc;
}
-
- /*
- * @see org.argouml.model.DataTypesFactory#createMultiplicityRange(java.lang.String)
- */
- public Object createMultiplicityRange(String str) {
+
+ public MultiplicityRange createMultiplicityRange(String str) {
StringTokenizer stk = new StringTokenizer(str, ". ");
if (!stk.hasMoreTokens()) {
throw new IllegalArgumentException("empty multiplicity range");
@@ -256,10 +228,7 @@
}
- /*
- * @see org.argouml.model.DataTypesFactory#createMultiplicityRange(int, int)
- */
- public Object createMultiplicityRange(int lower, int upper) {
+ public MultiplicityRange createMultiplicityRange(int lower, int upper) {
MultiplicityRange range =
modelImpl.getUmlPackage().getDataTypes().getMultiplicityRange()
.createMultiplicityRange(lower, upper);
Modified: trunk/src/model-mdr/src/org/argouml/model/mdr/ExtensionMechanismsHelperMDRImpl.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/model-mdr/src/org/argouml/model/mdr/ExtensionMechanismsHelperMDRImpl.java?view=diff&rev=13255&p1=trunk/src/model-mdr/src/org/argouml/model/mdr/ExtensionMechanismsHelperMDRImpl.java&p2=trunk/src/model-mdr/src/org/argouml/model/mdr/ExtensionMechanismsHelperMDRImpl.java&r1=13254&r2=13255
==============================================================================
--- trunk/src/model-mdr/src/org/argouml/model/mdr/ExtensionMechanismsHelperMDRImpl.java (original)
+++ trunk/src/model-mdr/src/org/argouml/model/mdr/ExtensionMechanismsHelperMDRImpl.java 2007-08-06 10:50:41-0700
@@ -398,7 +398,8 @@
public void addExtendedElement(Object handle, Object extendedElement) {
if (handle instanceof Stereotype
&& extendedElement instanceof ModelElement) {
- ((ModelElement) extendedElement).getStereotype().add(handle);
+ ((ModelElement) extendedElement).getStereotype().add(
+ (Stereotype) handle);
return;
}
throw new IllegalArgumentException("handle: " + handle
@@ -409,7 +410,7 @@
public void addBaseClass(Object handle, Object baseClass) {
if (handle instanceof Stereotype) {
if (baseClass instanceof String) {
- ((Stereotype) handle).getBaseClass().add(baseClass);
+ ((Stereotype) handle).getBaseClass().add((String) baseClass);
return;
}
if (baseClass instanceof ModelElement) {
@@ -520,7 +521,8 @@
public void addTaggedValue(Object handle, Object taggedValue) {
if (handle instanceof ModelElement
&& taggedValue instanceof TaggedValue) {
- ((ModelElement) handle).getTaggedValue().add(taggedValue);
+ ((ModelElement) handle).getTaggedValue().add(
+ (TaggedValue) taggedValue);
return;
}
throw new IllegalArgumentException("handle: " + handle
Modified: trunk/src/model-mdr/src/org/argouml/model/mdr/StateMachinesHelperMDRImpl.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/model-mdr/src/org/argouml/model/mdr/StateMachinesHelperMDRImpl.java?view=diff&rev=13255&p1=trunk/src/model-mdr/src/org/argouml/model/mdr/StateMachinesHelperMDRImpl.java&p2=trunk/src/model-mdr/src/org/argouml/model/mdr/StateMachinesHelperMDRImpl.java&r1=13254&r2=13255
==============================================================================
--- trunk/src/model-mdr/src/org/argouml/model/mdr/StateMachinesHelperMDRImpl.java (original)
+++ trunk/src/model-mdr/src/org/argouml/model/mdr/StateMachinesHelperMDRImpl.java 2007-08-06 10:50:41-0700
@@ -77,9 +77,7 @@
this.modelImpl = impl;
}
- /*
- * @see org.argouml.model.StateMachinesHelper#getSource(java.lang.Object)
- */
+
public Object getSource(Object trans) {
try {
if (trans instanceof Transition) {
@@ -92,9 +90,7 @@
+ "getSource() - " + trans);
}
- /*
- * @see org.argouml.model.StateMachinesHelper#getDestination(java.lang.Object)
- */
+
public Object getDestination(Object trans) {
try {
if (trans instanceof Transition) {
@@ -107,9 +103,7 @@
+ "getDestination() - " + trans);
}
- /*
- * @see org.argouml.model.StateMachinesHelper#getStateMachine(java.lang.Object)
- */
+
public Object getStateMachine(Object handle) {
if (handle == null) {
throw new IllegalArgumentException("bad argument to "
@@ -136,10 +130,7 @@
}
}
- /*
- * @see org.argouml.model.StateMachinesHelper#setEventAsTrigger(java.lang.Object,
- * java.lang.Object)
- */
+
public void setEventAsTrigger(Object transition, Object event) {
if (!(transition instanceof Transition)) {
throw new IllegalArgumentException("Transition either null or not "
@@ -152,17 +143,13 @@
((Transition) transition).setTrigger((Event) event);
}
- /*
- * @see org.argouml.model.StateMachinesHelper#isAddingStatemachineAllowed(java.lang.Object)
- */
+
public boolean isAddingStatemachineAllowed(Object context) {
return (context instanceof BehavioralFeature
|| context instanceof Classifier);
}
- /*
- * @see org.argouml.model.StateMachinesHelper#isTopState(java.lang.Object)
- */
+
public boolean isTopState(Object o) {
try {
if (o instanceof CompositeState) {
@@ -175,10 +162,7 @@
}
}
- /*
- * @see org.argouml.model.StateMachinesHelper#getAllPossibleStatemachines(java.lang.Object,
- * java.lang.Object)
- */
+
public Collection getAllPossibleStatemachines(Object model,
Object oSubmachineState) {
try {
@@ -196,9 +180,7 @@
"Argument must be a SubmachineState");
}
- /*
- * @see org.argouml.model.StateMachinesHelper#getAllPossibleSubvertices(java.lang.Object)
- */
+
public Collection getAllPossibleSubvertices(Object oState) {
ArrayList v = new ArrayList();
List v2 = new ArrayList();
@@ -217,10 +199,7 @@
return v;
}
- /*
- * @see org.argouml.model.StateMachinesHelper#setStatemachineAsSubmachine(java.lang.Object,
- * java.lang.Object)
- */
+
public void setStatemachineAsSubmachine(Object oSubmachineState,
Object oStatemachine) {
if (oSubmachineState instanceof SubmachineState
@@ -233,10 +212,8 @@
+ oSubmachineState + ",oStatemachine: " + oStatemachine);
}
- /*
- * @see org.argouml.model.StateMachinesHelper#getTop(java.lang.Object)
- */
- public Object getTop(Object sm) {
+
+ public State getTop(Object sm) {
if (!(sm instanceof StateMachine)) {
throw new IllegalArgumentException();
}
@@ -248,9 +225,7 @@
}
}
- /*
- * @see org.argouml.model.StateMachinesHelper#getOutgoingStates(java.lang.Object)
- */
+
public Collection getOutgoingStates(Object ostatevertex) {
try {
if (ostatevertex instanceof StateVertex) {
@@ -269,10 +244,7 @@
"Argument must be a StateVertex");
}
- /*
- * @see org.argouml.model.StateMachinesHelper#findOperationByName(java.lang.Object,
- * java.lang.String)
- */
+
public Object findOperationByName(Object trans, String opname) {
if (!(trans instanceof Transition)) {
throw new IllegalArgumentException();
@@ -297,9 +269,7 @@
return null;
}
- /*
- * @see org.argouml.model.StateMachinesHelper#getAllSubStates(java.lang.Object)
- */
+
public Collection getAllSubStates(Object compState) {
try {
if (compState instanceof CompositeState) {
@@ -322,10 +292,7 @@
"Argument is not a composite state");
}
- /*
- * @see org.argouml.model.StateMachinesHelper#removeSubvertex(java.lang.Object,
- * java.lang.Object)
- */
+
public void removeSubvertex(Object handle, Object subvertex) {
try {
if (handle instanceof CompositeState
@@ -340,10 +307,7 @@
+ " or subvertex: " + subvertex);
}
- /*
- * @see org.argouml.model.StateMachinesHelper#addSubvertex(java.lang.Object,
- * java.lang.Object)
- */
+
public void addSubvertex(Object handle, Object subvertex) {
if (handle instanceof CompositeState
&& subvertex instanceof StateVertex) {
@@ -356,10 +320,7 @@
+ " or subvertex: " + subvertex);
}
- /*
- * @see org.argouml.model.StateMachinesHelper#setBound(java.lang.Object,
- * int)
- */
+
public void setBound(Object handle, int bound) {
if (handle instanceof SynchState) {
((SynchState) handle).setBound(bound);
@@ -369,10 +330,7 @@
+ bound);
}
- /*
- * @see org.argouml.model.StateMachinesHelper#setConcurrent(java.lang.Object,
- * boolean)
- */
+
public void setConcurrent(Object handle, boolean concurrent) {
if (handle instanceof CompositeState) {
((CompositeState) handle).setConcurrent(concurrent);
@@ -381,10 +339,7 @@
throw new IllegalArgumentException("handle: " + handle);
}
- /*
- * @see org.argouml.model.StateMachinesHelper#setContainer(java.lang.Object,
- * java.lang.Object)
- */
+
public void setContainer(Object handle, Object compositeState) {
if (handle instanceof StateVertex
&& (compositeState == null
@@ -397,10 +352,7 @@
+ " or compositeState: " + compositeState);
}
- /*
- * @see org.argouml.model.StateMachinesHelper#setDoActivity(java.lang.Object,
- * java.lang.Object)
- */
+
public void setDoActivity(Object handle, Object value) {
if (handle instanceof State
&& (value == null || value instanceof Action)) {
@@ -411,10 +363,7 @@
+ value);
}
- /*
- * @see org.argouml.model.StateMachinesHelper#setEffect(java.lang.Object,
- * java.lang.Object)
- */
+
public void setEffect(Object handle, Object value) {
if (handle instanceof Transition
&& (value == null || value instanceof Action)) {
@@ -425,10 +374,7 @@
+ value);
}
- /*
- * @see org.argouml.model.StateMachinesHelper#setEntry(java.lang.Object,
- * java.lang.Object)
- */
+
public void setEntry(Object handle, Object value) {
if (handle instanceof State
&& (value == null || value instanceof Action)) {
@@ -439,10 +385,7 @@
+ value);
}
- /*
- * @see org.argouml.model.StateMachinesHelper#setExit(java.lang.Object,
- * java.lang.Object)
- */
+
public void setExit(Object handle, Object value) {
if (handle instanceof State
&& (value == null || value instanceof Action)) {
@@ -453,10 +396,7 @@
+ value);
}
- /*
- * @see org.argouml.model.StateMachinesHelper#setExpression(java.lang.Object,
- * java.lang.Object)
- */
+
public void setExpression(Object handle, Object value) {
if (handle instanceof Guard
&& (value == null || value instanceof BooleanExpression)) {
@@ -479,10 +419,7 @@
+ value);
}
- /*
- * @see org.argouml.model.StateMachinesHelper#setGuard(java.lang.Object,
- * java.lang.Object)
- */
+
public void setGuard(Object handle, Object guard) {
if (handle instanceof Transition
&& (guard == null || guard instanceof Guard)) {
@@ -493,10 +430,7 @@
+ guard);
}
- /*
- * @see org.argouml.model.StateMachinesHelper#setInternalTransitions(java.lang.Object,
- * java.util.Collection)
- */
+
public void setInternalTransitions(Object handle, Collection intTrans) {
if (handle instanceof State) {
Collection internalTransitions =
@@ -522,13 +456,10 @@
/**
* Remove a transition.
- *
- * TODO: This is not part of the public API. Reduce visibility - tfm
- *
* @param handle The state
* @param intTrans The internal transition to remove
*/
- public void removeTransition(Object handle, Object intTrans) {
+ private void removeTransition(Object handle, Object intTrans) {
try {
if (handle instanceof State && intTrans instanceof Transition) {
((State) handle).getInternalTransition().remove(intTrans);
@@ -544,24 +475,19 @@
/**
* Add a transition.
*
- * TODO: This is not part of the public API. Reduce visibility - tfm
- *
* @param handle The state
* @param intTrans The internal transition to add
*/
- public void addTransition(Object handle, Object intTrans) {
+ private void addTransition(Object handle, Object intTrans) {
if (handle instanceof State && intTrans instanceof Transition) {
- ((State) handle).getInternalTransition().add(intTrans);
+ ((State) handle).getInternalTransition().add((Transition) intTrans);
return;
}
throw new IllegalArgumentException("handle: " + handle
+ " or subvertex: " + intTrans);
}
- /*
- * @see org.argouml.model.StateMachinesHelper#setSource(java.lang.Object,
- * java.lang.Object)
- */
+
public void setSource(Object handle, Object state) {
if (handle instanceof Transition && state instanceof StateVertex) {
((Transition) handle).setSource((StateVertex) state);
@@ -571,10 +497,7 @@
+ state);
}
- /*
- * @see org.argouml.model.StateMachinesHelper#setState(java.lang.Object,
- * java.lang.Object)
- */
+
public void setState(Object handle, Object element) {
if (handle instanceof Transition && element instanceof State) {
addTransition(element, handle);
@@ -584,10 +507,7 @@
+ " or element: " + element);
}
- /*
- * @see org.argouml.model.StateMachinesHelper#setStateMachine(java.lang.Object,
- * java.lang.Object)
- */
+
public void setStateMachine(Object handle, Object stm) {
if (handle instanceof State
&& (stm == null || stm instanceof StateMachine)) {
@@ -603,10 +523,7 @@
+ stm);
}
- /*
- * @see org.argouml.model.StateMachinesHelper#setSubvertices(java.lang.Object,
- * java.util.Collection)
- */
+
public void setSubvertices(Object handle, Collection subvertices) {
if (handle instanceof CompositeState) {
Collection vertices = Model.getFacade().getSubvertices(handle);
@@ -630,10 +547,7 @@
+ " or subvertices: " + subvertices);
}
- /*
- * @see org.argouml.model.StateMachinesHelper#setTrigger(java.lang.Object,
- * java.lang.Object)
- */
+
public void setTrigger(Object handle, Object event) {
if (handle instanceof Transition
&& (event == null || event instanceof Event)) {
@@ -644,10 +558,7 @@
+ event);
}
- /*
- * @see org.argouml.model.StateMachinesHelper#setWhen(java.lang.Object,
- * java.lang.Object)
- */
+
public void setWhen(Object handle, Object value) {
if (handle instanceof TimeEvent
&& (value == null || value instanceof TimeExpression)) {
@@ -658,10 +569,7 @@
+ value);
}
- /*
- * @see org.argouml.model.StateMachinesHelper#setChangeExpression(
- * java.lang.Object, java.lang.Object)
- */
+
public void setChangeExpression(Object handle, Object value) {
if (handle instanceof ChangeEvent
&& (value == null || value instanceof BooleanExpression)) {
@@ -673,9 +581,7 @@
+ value);
}
- /*
- * @see org.argouml.model.StateMachinesHelper#getPath(java.lang.Object)
- */
+
public String getPath(Object o) {
try {
if (o instanceof StateVertex) {
@@ -696,13 +602,10 @@
"Argument must be a StateVertex");
}
- /*
- * @see org.argouml.model.StateMachinesHelper#getStatebyName(java.lang.String,
- * java.lang.Object)
- */
+
public Object getStatebyName(String path, Object container) {
try {
- // TODO: This should probably through an exception if it gets
+ // TODO: This should probably throw an exception if it gets
// invalid arguments rather than just returning null
if (container != null
&& Model.getFacade().isACompositeState(container)
@@ -732,10 +635,7 @@
return null;
}
- /*
- * @see org.argouml.model.StateMachinesHelper#setReferenceState(java.lang.Object,
- * java.lang.String)
- */
+
public void setReferenceState(Object o, String referenced) {
if (o instanceof StubState) {
((StubState) o).setReferenceState(referenced);
@@ -744,9 +644,7 @@
throw new IllegalArgumentException("handle: " + o);
}
- /*
- * @see org.argouml.model.StateMachinesHelper#findNamespaceForEvent(java.lang.Object, java.lang.Object)
- */
+
public Object findNamespaceForEvent(Object trans, Object model) {
try {
Object enclosing =
@@ -764,9 +662,7 @@
}
}
- /*
- * @see org.argouml.model.StateMachinesHelper#addDeferrableEvent(java.lang.Object, java.lang.Object)
- */
+
public void addDeferrableEvent(Object state, Object deferrableEvent) {
if (state instanceof State && deferrableEvent instanceof Event) {
modelImpl.getUmlPackage().getStateMachines()
@@ -777,9 +673,8 @@
throw new IllegalArgumentException("handle: " + state + " or evt: "
+ deferrableEvent);
}
- /*
- * @see org.argouml.model.StateMachinesHelper#removeDeferrableEvent(java.lang.Object, java.lang.Object)
- */
+
+
public void removeDeferrableEvent(Object state, Object deferrableEvent) {
try {
if (state instanceof State && deferrableEvent instanceof Event) {
@@ -795,9 +690,7 @@
+ deferrableEvent);
}
- /*
- * @see org.argouml.model.StateMachinesHelper#setContext(java.lang.Object, java.lang.Object)
- */
+
public void setContext(Object statemachine, Object modelElement) {
if (statemachine instanceof StateMachine
&& modelElement instanceof ModelElement) {
Modified: trunk/src/model-mdr/src/org/argouml/model/mdr/UseCasesHelperMDRImpl.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/model-mdr/src/org/argouml/model/mdr/UseCasesHelperMDRImpl.java?view=diff&rev=13255&p1=trunk/src/model-mdr/src/org/argouml/model/mdr/UseCasesHelperMDRImpl.java&p2=trunk/src/model-mdr/src/org/argouml/model/mdr/UseCasesHelperMDRImpl.java&r1=13254&r2=13255
==============================================================================
--- trunk/src/model-mdr/src/org/argouml/model/mdr/UseCasesHelperMDRImpl.java (original)
+++ trunk/src/model-mdr/src/org/argouml/model/mdr/UseCasesHelperMDRImpl.java 2007-08-06 10:50:41-0700
@@ -63,7 +63,7 @@
private MDRModelImplementation modelImpl;
/**
- * Don't allow instantiation.
+ * Constructor.
*
* @param implementation
* To get other helpers and factories.
@@ -72,26 +72,21 @@
modelImpl = implementation;
}
- /*
- * @see org.argouml.model.UseCasesHelper#getAllUseCases(java.lang.Object)
- */
- public Collection getAllUseCases(Object ns) {
+
+ public Collection<UseCase> getAllUseCases(Object ns) {
if (!(ns instanceof Namespace)) {
throw new IllegalArgumentException();
}
- List list = new ArrayList();
+ List<UseCase> list = new ArrayList<UseCase>();
try {
- Iterator it = ((Namespace) ns).getOwnedElement().iterator();
- while (it.hasNext()) {
- Object o = it.next();
+ for (Object o : ((Namespace) ns).getOwnedElement()) {
if (o instanceof Namespace) {
list.addAll(getAllUseCases(o));
}
if (o instanceof UseCase) {
- list.add(o);
+ list.add((UseCase) o);
}
-
}
} catch (InvalidObjectException e) {
throw new InvalidElementException(e);
@@ -99,24 +94,20 @@
return list;
}
- /*
- * @see org.argouml.model.UseCasesHelper#getAllActors(java.lang.Object)
- */
- public Collection getAllActors(Object ns) {
+
+ public Collection<Actor> getAllActors(Object ns) {
if (!(ns instanceof Namespace)) {
throw new IllegalArgumentException();
}
- List list = new ArrayList();
+ List<Actor> list = new ArrayList<Actor>();
try {
- Iterator it = ((Namespace) ns).getOwnedElement().iterator();
- while (it.hasNext()) {
- Object o = it.next();
+ for (Object o : ((Namespace) ns).getOwnedElement()) {
if (o instanceof Namespace) {
list.addAll(getAllActors(o));
}
if (o instanceof Actor) {
- list.add(o);
+ list.add((Actor) o);
}
}
} catch (InvalidObjectException e) {
@@ -125,14 +116,12 @@
return list;
}
- /*
- * @see org.argouml.model.UseCasesHelper#getExtendedUseCases(java.lang.Object)
- */
- public Collection getExtendedUseCases(Object ausecase) {
+
+ public Collection<UseCase> getExtendedUseCases(Object ausecase) {
if (ausecase == null) {
- return new ArrayList();
+ return new ArrayList<UseCase>();
}
- List list = new ArrayList();
+ List<UseCase> list = new ArrayList<UseCase>();
UseCase usecase = (UseCase) ausecase;
try {
Iterator it = usecase.getExtend().iterator();
@@ -147,14 +136,12 @@
return list;
}
- /*
- * @see org.argouml.model.UseCasesHelper#getExtendingUseCases(java.lang.Object)
- */
- public Collection getExtendingUseCases(Object usecase) {
+
+ public Collection<UseCase> getExtendingUseCases(Object usecase) {
if (usecase == null) {
- return new ArrayList();
+ return new ArrayList<UseCase>();
}
- List list = new ArrayList();
+ List<UseCase> list = new ArrayList<UseCase>();
try {
Iterator it = Model.getFacade().getExtenders(usecase).iterator();
while (it.hasNext()) {
@@ -168,9 +155,7 @@
return list;
}
- /*
- * @see org.argouml.model.UseCasesHelper#getExtends(java.lang.Object, java.lang.Object)
- */
+
public Object getExtends(Object abase, Object anextension) {
if (!(abase instanceof UseCase)
|| !(anextension instanceof UseCase)) {
@@ -192,14 +177,12 @@
return null;
}
- /*
- * @see org.argouml.model.UseCasesHelper#getIncludedUseCases(java.lang.Object)
- */
- public Collection getIncludedUseCases(Object ausecase) {
+
+ public Collection<UseCase> getIncludedUseCases(Object ausecase) {
if (!(ausecase instanceof UseCase)) {
throw new IllegalArgumentException();
}
- List list = new ArrayList();
+ List<UseCase> list = new ArrayList<UseCase>();
UseCase usecase = (UseCase) ausecase;
try {
Iterator it = usecase.getInclude().iterator();
@@ -214,9 +197,7 @@
return list;
}
- /*
- * @see org.argouml.model.UseCasesHelper#getIncludes(java.lang.Object, java.lang.Object)
- */
+
public Object getIncludes(Object abase, Object aninclusion) {
if (!(abase instanceof UseCase)
|| !(aninclusion instanceof UseCase)) {
@@ -238,9 +219,7 @@
return null;
}
- /*
- * @see org.argouml.model.UseCasesHelper#getSpecificationPath(java.lang.Object)
- */
+
public Collection getSpecificationPath(Object ausecase) {
UseCase uc = (UseCase) ausecase;
Set set = new HashSet();
@@ -261,9 +240,7 @@
}
}
- /*
- * @see org.argouml.model.UseCasesHelper#setBase(java.lang.Object, java.lang.Object)
- */
+
public void setBase(Object extend, Object base) {
if (base == null) {
throw new IllegalArgumentException(
@@ -308,9 +285,7 @@
}
}
- /*
- * @see org.argouml.model.UseCasesHelper#removeExtend(java.lang.Object, java.lang.Object)
- */
+
public void removeExtend(Object elem, Object extend) {
try {
if (elem instanceof UseCase && extend instanceof Extend) {
@@ -328,9 +303,7 @@
+ extend);
}
- /*
- * @see org.argouml.model.UseCasesHelper#removeExtensionPoint(java.lang.Object, java.lang.Object)
- */
+
public void removeExtensionPoint(Object elem, Object ep) {
try {
if (ep instanceof ExtensionPoint) {
@@ -349,9 +322,7 @@
throw new IllegalArgumentException("elem: " + elem + " or ep: " + ep);
}
- /*
- * @see org.argouml.model.UseCasesHelper#removeInclude(java.lang.Object, java.lang.Object)
- */
+
public void removeInclude(Object usecase, Object include) {
try {
if (usecase instanceof UseCase && include instanceof Include) {
@@ -365,34 +336,29 @@
+ " or include: " + include);
}
- /*
- * @see org.argouml.model.UseCasesHelper#addExtend(java.lang.Object, java.lang.Object)
- */
+
public void addExtend(Object elem, Object extend) {
if (elem instanceof UseCase && extend instanceof Extend) {
- ((UseCase) elem).getExtend().add(extend);
- return;
- }
- if (elem instanceof ExtensionPoint && extend instanceof Extend) {
- ((Extend) extend).getExtensionPoint().add(elem);
- return;
+ ((UseCase) elem).getExtend().add((Extend) extend);
+ } else if (elem instanceof ExtensionPoint && extend instanceof Extend) {
+ ((Extend) extend).getExtensionPoint().add((ExtensionPoint) elem);
+ } else {
+ throw new IllegalArgumentException("elem: " + elem + " or extend: "
+ + extend);
}
-
- throw new IllegalArgumentException("elem: " + elem + " or extend: "
- + extend);
}
- /*
- * @see org.argouml.model.UseCasesHelper#addExtensionPoint(java.lang.Object, java.lang.Object)
- */
+
public void addExtensionPoint(Object handle, Object extensionPoint) {
if (extensionPoint instanceof ExtensionPoint) {
if (handle instanceof UseCase) {
- ((UseCase) handle).getExtensionPoint().add(extensionPoint);
+ ((UseCase) handle).getExtensionPoint().add(
+ (ExtensionPoint) extensionPoint);
return;
}
if (handle instanceof Extend) {
- ((Extend) handle).getExtensionPoint().add(extensionPoint);
+ ((Extend) handle).getExtensionPoint().add(
+ (ExtensionPoint) extensionPoint);
return;
}
}
@@ -400,15 +366,13 @@
+ " or extensionPoint: " + extensionPoint);
}
- /*
- * @see org.argouml.model.UseCasesHelper#addExtensionPoint(java.lang.Object, int, java.lang.Object)
- */
+
public void addExtensionPoint(Object handle, int position,
Object extensionPoint) {
if (extensionPoint instanceof ExtensionPoint) {
if (handle instanceof Extend) {
((Extend) handle).getExtensionPoint().add(position,
- extensionPoint);
+ (ExtensionPoint) extensionPoint);
return;
}
}
@@ -416,12 +380,10 @@
+ " or extensionPoint: " + extensionPoint);
}
- /*
- * @see org.argouml.model.UseCasesHelper#addInclude(java.lang.Object, java.lang.Object)
- */
+
public void addInclude(Object usecase, Object include) {
if (usecase instanceof UseCase && include instanceof Include) {
- ((UseCase) usecase).getInclude().add(include);
+ ((UseCase) usecase).getInclude().add((Include) include);
return;
}
@@ -429,9 +391,7 @@
+ " or include: " + include);
}
- /*
- * @see org.argouml.model.UseCasesHelper#setAddition(java.lang.Object, java.lang.Object)
- */
+
public void setAddition(Object handle, Object useCase) {
if (!(useCase instanceof UseCase)) {
throw new IllegalArgumentException("A UseCase was expected ["
@@ -451,9 +411,7 @@
throw new IllegalArgumentException("handle: " + handle);
}
- /*
- * @see org.argouml.model.UseCasesHelper#setCondition(java.lang.Object, java.lang.Object)
- */
+
public void setCondition(Object handle, Object booleanExpression) {
if (handle instanceof Extend
&& booleanExpression instanceof BooleanExpression) {
@@ -465,9 +423,7 @@
+ " or booleanExpression: " + booleanExpression);
}
- /*
- * @see org.argouml.model.UseCasesHelper#setExtension(java.lang.Object, java.lang.Object)
- */
+
public void setExtension(Object handle, Object useCase) {
if (!(useCase instanceof UseCase)) {
throw new IllegalArgumentException("A use case must be supplied");
@@ -489,9 +445,7 @@
+ useCase);
}
- /*
- * @see org.argouml.model.UseCasesHelper#setExtensionPoints(java.lang.Object, java.util.Collection)
- */
+
public void setExtensionPoints(Object handle, Collection extensionPoints) {
if (handle instanceof UseCase || handle instanceof Extend) {
Collection eps = Model.getFacade().getExtensionPoints(handle);
@@ -515,25 +469,19 @@
+ " or extensionPoints: " + extensionPoints);
}
- /*
- * @see org.argouml.model.UseCasesHelper#setIncludes(java.lang.Object, java.util.Collection)
- */
+
public void setIncludes(Object handle, Collection includes) {
if (handle instanceof UseCase) {
- Collection inc = Model.getFacade().getIncludes(handle);
+ Collection<Include> inc = Model.getFacade().getIncludes(handle);
if (!inc.isEmpty()) {
- Vector in = new Vector();
+ List<Include> in = new ArrayList<Include>();
in.addAll(inc);
- Iterator toRemove = in.iterator();
- while (toRemove.hasNext()) {
- removeInclude(handle, toRemove.next());
+ for (Include i : in) {
+ removeInclude(handle, i);
}
}
- if (!includes.isEmpty()) {
- Iterator toAdd = includes.iterator();
- while (toAdd.hasNext()) {
- addInclude(handle, toAdd.next());
- }
+ for (Include i : (Collection<Include>) includes) {
+ addInclude(handle, i);
}
return;
}
@@ -541,9 +489,7 @@
+ " or includes: " + includes);
}
- /*
- * @see org.argouml.model.UseCasesHelper#setLocation(java.lang.Object, java.lang.String)
- */
+
public void setLocation(Object handle, String loc) {
if (handle instanceof ExtensionPoint) {
((ExtensionPoint) handle).setLocation(loc);
@@ -552,16 +498,13 @@
throw new IllegalArgumentException("handle: " + handle);
}
- /*
- * @see org.argouml.model.UseCasesHelper#setUseCase(java.lang.Object, java.lang.Object)
- */
+
public void setUseCase(Object elem, Object usecase) {
if (elem instanceof ExtensionPoint
&& (usecase instanceof UseCase || usecase == null)) {
((ExtensionPoint) elem).setUseCase((UseCase) usecase);
return;
}
-
throw new IllegalArgumentException("elem: " + elem + " or usecase: "
+ usecase);
}
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.