diff options
| author | Christian W. Damus | 2017-01-10 17:19:49 +0000 |
|---|---|---|
| committer | Christian W. Damus | 2017-01-10 17:29:35 +0000 |
| commit | 2d669b9d9d93423b0804139050cb4323021a0aaa (patch) | |
| tree | 32deb6f048afee13db1a38de48b7e19b4e54592c | |
| parent | 5662cf63394f1969362bf2b132061a4f253327ff (diff) | |
| download | org.eclipse.papyrus-rt-2d669b9d9d93423b0804139050cb4323021a0aaa.tar.gz org.eclipse.papyrus-rt-2d669b9d9d93423b0804139050cb4323021a0aaa.tar.xz org.eclipse.papyrus-rt-2d669b9d9d93423b0804139050cb4323021a0aaa.zip | |
Bug 467545: [UML-RT] PapyrusRT shall provide a UML specific implementation to support redefinition
Provide initial support for specialization of the UML-RT Façade API in clients
that extend/customize the UML-RT Profile. Includes letting the classes not
be final and exposing as public or protected a variety of operations that are
potentially useful to access or even override in subclasses.
The FacadeObject/FacadeType/FacadeReference framework is not yet ready for
exposure as a generic mechanism for implementing new façades classes and
properties.
(addresses post facto comments from https://git.eclipse.org/r/#/c/88008/)
(🍒-picked from branch committers/cdamus/inheritance)
https://bugs.eclipse.org/bugs/show_bug.cgi?id=467545
Change-Id: I942cba82aea8a2873d7a006b182f84590db51212
11 files changed, 176 insertions, 72 deletions
diff --git a/plugins/umlrt/profile/org.eclipse.papyrusrt.umlrt.uml/src/org/eclipse/papyrusrt/umlrt/uml/UMLRTCapsule.java b/plugins/umlrt/profile/org.eclipse.papyrusrt.umlrt.uml/src/org/eclipse/papyrusrt/umlrt/uml/UMLRTCapsule.java index 94adf6db1..699aeb4d2 100644 --- a/plugins/umlrt/profile/org.eclipse.papyrusrt.umlrt.uml/src/org/eclipse/papyrusrt/umlrt/uml/UMLRTCapsule.java +++ b/plugins/umlrt/profile/org.eclipse.papyrusrt.umlrt.uml/src/org/eclipse/papyrusrt/umlrt/uml/UMLRTCapsule.java @@ -1,5 +1,5 @@ /***************************************************************************** - * Copyright (c) 2016 Christian W. Damus and others. + * Copyright (c) 2016, 2017 Christian W. Damus and others. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -38,7 +38,7 @@ import org.eclipse.uml2.uml.util.UMLUtil; * A façade for UML {@link Class} elements that represent UML-RT {@link Capsule Capsule}s, * providing a view of the element more in keeping with the UML-RT semantics. */ -public final class UMLRTCapsule extends UMLRTClassifier { +public class UMLRTCapsule extends UMLRTClassifier { static final FacadeType<Class, Capsule, UMLRTCapsule> TYPE = new FacadeType<>( UMLRTCapsule.class, @@ -66,7 +66,7 @@ public final class UMLRTCapsule extends UMLRTClassifier { ExtUMLExtPackage.Literals.STRUCTURED_CLASSIFIER__IMPLICIT_CONNECTOR, UMLPackage.Literals.CONNECTOR); - UMLRTCapsule(Capsule capsule) { + protected UMLRTCapsule(Capsule capsule) { super(capsule.getBase_Class(), capsule); } @@ -93,17 +93,22 @@ public final class UMLRTCapsule extends UMLRTClassifier { } @Override - Capsule toRT() { + protected Capsule toRT() { return (Capsule) super.toRT(); } + @Override + public UMLRTCapsule getGeneral() { + return (UMLRTCapsule) super.getGeneral(); + } + /** * Obtains the capsule that is my supertype, if any. * * @return my supertype, or {@code null} if I am a root capsule type */ public UMLRTCapsule getSuperclass() { - return (UMLRTCapsule) getGeneral(); + return getGeneral(); } /** @@ -356,32 +361,6 @@ public final class UMLRTCapsule extends UMLRTClassifier { } /** - * Obtains all of the ports, parts, and connectors that I have excluded - * from inheritance. - * - * @return my excluded features - */ - @Override - public List<UMLRTNamedElement> getExcludedElements() { - return super.getExcludedElements(); - } - - /** - * Obtains the named excluded element. - * - * @param name - * the name of the element to find - * @param facadeType - * the kind of excluded element to find - * - * @return the excluded element, or {@code null} if none - */ - @Override - public <T extends UMLRTNamedElement> T getExcludedElement(String name, java.lang.Class<T> facadeType) { - return super.getExcludedElement(name, facadeType); - } - - /** * Obtains my local redefinition of the given inherited element, even if it * just the local façade representation of that element inherited as is. * If the element is a local definition, then it is returned as is. diff --git a/plugins/umlrt/profile/org.eclipse.papyrusrt.umlrt.uml/src/org/eclipse/papyrusrt/umlrt/uml/UMLRTCapsulePart.java b/plugins/umlrt/profile/org.eclipse.papyrusrt.umlrt.uml/src/org/eclipse/papyrusrt/umlrt/uml/UMLRTCapsulePart.java index f1bfee967..3710a6c96 100644 --- a/plugins/umlrt/profile/org.eclipse.papyrusrt.umlrt.uml/src/org/eclipse/papyrusrt/umlrt/uml/UMLRTCapsulePart.java +++ b/plugins/umlrt/profile/org.eclipse.papyrusrt.umlrt.uml/src/org/eclipse/papyrusrt/umlrt/uml/UMLRTCapsulePart.java @@ -52,7 +52,7 @@ public class UMLRTCapsulePart extends UMLRTReplicatedElement { UMLRTCapsulePart::getRedefinedPart, UMLRTCapsulePart::new); - UMLRTCapsulePart(CapsulePart capsulePart) { + protected UMLRTCapsulePart(CapsulePart capsulePart) { super(capsulePart.getBase_Property(), capsulePart); } @@ -174,7 +174,15 @@ public class UMLRTCapsulePart extends UMLRTReplicatedElement { return (rtRole != null) && rtRole.redefines(port); } - Stream<UMLRTCapsulePart> allRedefinitions() { + /** + * Obtains a stream over all of the currently loaded redefinitions of my in + * the inheritance hierarchy of my {@link #getCapsule() capsule}. + * + * @return my currently loaded redefinitions + * + * @see UMLRTCapsule#getHierarchy() + */ + protected Stream<UMLRTCapsulePart> allRedefinitions() { Predicate<UMLRTCapsulePart> excluded = UMLRTCapsulePart::isExcluded; UMLRTCapsule capsule = getCapsule(); return (capsule == null) ? Stream.empty() : capsule.getHierarchy() diff --git a/plugins/umlrt/profile/org.eclipse.papyrusrt.umlrt.uml/src/org/eclipse/papyrusrt/umlrt/uml/UMLRTCapsulePartKind.java b/plugins/umlrt/profile/org.eclipse.papyrusrt.umlrt.uml/src/org/eclipse/papyrusrt/umlrt/uml/UMLRTCapsulePartKind.java index 77a52be8a..1e673c513 100644 --- a/plugins/umlrt/profile/org.eclipse.papyrusrt.umlrt.uml/src/org/eclipse/papyrusrt/umlrt/uml/UMLRTCapsulePartKind.java +++ b/plugins/umlrt/profile/org.eclipse.papyrusrt.umlrt.uml/src/org/eclipse/papyrusrt/umlrt/uml/UMLRTCapsulePartKind.java @@ -1,5 +1,5 @@ /***************************************************************************** - * Copyright (c) 2016 Christian W. Damus and others. + * Copyright (c) 2016, 2017 Christian W. Damus and others. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -17,10 +17,14 @@ package org.eclipse.papyrusrt.umlrt.uml; * Enumeration of UML-RT capsule-part kinds. */ public enum UMLRTCapsulePartKind { - FIXED("Fixed", true, true), // - OPTIONAL("Optional", false, true), // - PLUG_IN("Plug-in", false, false), // - NULL("<invalid>", false, false); // + /** A fixed capsule-part has always as many instantiations as its replication factor permits. */ + FIXED("Fixed", true, true), + /** An optional capsule-part is not required to be instantiated. */ + OPTIONAL("Optional", false, true), + /** An plug-in capsule-part {@linkplain #OPTIONAL optional} and is not instantiated by the capsule. */ + PLUG_IN("Plug-in", false, false), + /** A capsule-part kind indicating that no valid kind can be inferred from the UML model. */ + NULL("<invalid>", false, false); private final String label; private final boolean required; diff --git a/plugins/umlrt/profile/org.eclipse.papyrusrt.umlrt.uml/src/org/eclipse/papyrusrt/umlrt/uml/UMLRTClassifier.java b/plugins/umlrt/profile/org.eclipse.papyrusrt.umlrt.uml/src/org/eclipse/papyrusrt/umlrt/uml/UMLRTClassifier.java index 27727f2c6..9f449a951 100644 --- a/plugins/umlrt/profile/org.eclipse.papyrusrt.umlrt.uml/src/org/eclipse/papyrusrt/umlrt/uml/UMLRTClassifier.java +++ b/plugins/umlrt/profile/org.eclipse.papyrusrt.umlrt.uml/src/org/eclipse/papyrusrt/umlrt/uml/UMLRTClassifier.java @@ -38,11 +38,11 @@ import org.eclipse.uml2.uml.Generalization; */ public abstract class UMLRTClassifier extends UMLRTNamedElement { - UMLRTClassifier(Classifier element, EObject stereotype) { + protected UMLRTClassifier(Classifier element, EObject stereotype) { super(element, stereotype); } - static UMLRTClassifier getInstance(Classifier classifier) { + protected static UMLRTClassifier getInstance(Classifier classifier) { UMLRTNamedElement result = (classifier == null) ? null : UMLRTFactory.create(classifier); @@ -72,19 +72,50 @@ public abstract class UMLRTClassifier extends UMLRTNamedElement { return UMLRTPackage.getInstance(toUML().getPackage()); } - UMLRTClassifier getGeneral() { + /** + * Obtains my general classifier, which if not {@code null} will be + * of the same meta-type as myself. + * + * @return my general classifier, or {@code null} if I have none or the + * underlying UML model has a general that is of the wrong meta-type + */ + public UMLRTClassifier getGeneral() { EList<Classifier> generals = toUML().getGenerals(); - Classifier result = generals.isEmpty() ? null : generals.get(0); - return UMLRTClassifier.getInstance(result); + Classifier general = generals.isEmpty() ? null : generals.get(0); + + UMLRTClassifier result = getInstance(general); + return getClass().isInstance(result) ? result : null; } - void setGeneral(UMLRTClassifier general) { + /** + * Sets my general classifier. + * + * @param general + * my general classifier, or {@code null} if I am to be a root type + * + * @throws IllegalArgumentException + * if the {@code general} is not {@code null} and is not + * of the same meta-type as myself or a supertype of my meta-type + */ + public void setGeneral(UMLRTClassifier general) { + if ((general != null) && !general.getClass().isInstance(this)) { + throw new IllegalArgumentException("incompatible meta-type: " + general); + } + if (getGeneral() != general) { setGeneral(toUML(), (general == null) ? null : general.toUML()); } } - static <C extends Classifier> void setGeneral(C specific, C general) { + /** + * Assigns the {@code general} of a {@code specific} classifier. + * + * @param specific + * a classifier + * @param general + * the classifier to set as the {@code specific}'s {@code general} + */ + protected static <C extends Classifier> void setGeneral(C specific, C general) { EList<Classifier> generals = specific.getGenerals(); if (general == null) { new ArrayList<>(specific.getGeneralizations()).forEach(Element::destroy); @@ -110,12 +141,30 @@ public abstract class UMLRTClassifier extends UMLRTNamedElement { .map(sc -> isSuperTypeOf(sc)).orElse(false); } - List<? extends UMLRTClassifier> getSpecifics() { + /** + * Obtains those of my immediate specializing classifiers that are currently loaded. + * + * @return an unmodifiable list of my known immediate subtypes + */ + protected List<? extends UMLRTClassifier> getSpecifics() { return getSpecifics(false).collect( collectingAndThen(toList(), Collections::unmodifiableList)); } - Stream<? extends UMLRTClassifier> getSpecifics(boolean recursive) { + /** + * Obtains a stream over of my specializing classifiers that are currently loaded, with the + * option of including also their specializations and so one, {@code recursive}ly. This is + * like the {@link #getHierarchy() hierarchy} except that it does not include me as a + * specific of myself. + * + * @param recursive + * whether to include recursively the entire specialization tree + * + * @return my specifics, perhaps {@code recursive}ly + * + * @see #getHierarchy() + */ + protected Stream<? extends UMLRTClassifier> getSpecifics(boolean recursive) { Stream<Classifier> specifics = specifics(toUML()); if (!recursive) { diff --git a/plugins/umlrt/profile/org.eclipse.papyrusrt.umlrt.uml/src/org/eclipse/papyrusrt/umlrt/uml/UMLRTConnector.java b/plugins/umlrt/profile/org.eclipse.papyrusrt.umlrt.uml/src/org/eclipse/papyrusrt/umlrt/uml/UMLRTConnector.java index 16060713a..70d6de6e2 100644 --- a/plugins/umlrt/profile/org.eclipse.papyrusrt.umlrt.uml/src/org/eclipse/papyrusrt/umlrt/uml/UMLRTConnector.java +++ b/plugins/umlrt/profile/org.eclipse.papyrusrt.umlrt.uml/src/org/eclipse/papyrusrt/umlrt/uml/UMLRTConnector.java @@ -26,7 +26,7 @@ import org.eclipse.uml2.uml.UMLPackage; * A façade for UML {@link Connector} elements that represent UML-RT {@link RTConnector Connector}s, * providing a view of the element more in keeping with the UML-RT semantics. */ -public final class UMLRTConnector extends UMLRTNamedElement { +public class UMLRTConnector extends UMLRTNamedElement { static final FacadeType<Connector, RTConnector, UMLRTConnector> TYPE = new FacadeType<>( UMLRTConnector.class, UMLPackage.Literals.CONNECTOR, @@ -35,7 +35,7 @@ public final class UMLRTConnector extends UMLRTNamedElement { UMLRTConnector::getRedefinedConnector, UMLRTConnector::new); - UMLRTConnector(RTConnector rtConnector) { + protected UMLRTConnector(RTConnector rtConnector) { super(rtConnector.getBase_Connector(), rtConnector); } diff --git a/plugins/umlrt/profile/org.eclipse.papyrusrt.umlrt.uml/src/org/eclipse/papyrusrt/umlrt/uml/UMLRTModel.java b/plugins/umlrt/profile/org.eclipse.papyrusrt.umlrt.uml/src/org/eclipse/papyrusrt/umlrt/uml/UMLRTModel.java index 278ccc00d..2e3918f42 100644 --- a/plugins/umlrt/profile/org.eclipse.papyrusrt.umlrt.uml/src/org/eclipse/papyrusrt/umlrt/uml/UMLRTModel.java +++ b/plugins/umlrt/profile/org.eclipse.papyrusrt.umlrt.uml/src/org/eclipse/papyrusrt/umlrt/uml/UMLRTModel.java @@ -1,5 +1,5 @@ /***************************************************************************** - * Copyright (c) 2016 Christian W. Damus and others. + * Copyright (c) 2016, 2017 Christian W. Damus and others. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -36,7 +36,7 @@ public class UMLRTModel { private final Resource resource; - UMLRTModel(Resource resource) { + protected UMLRTModel(Resource resource) { super(); this.resource = resource; diff --git a/plugins/umlrt/profile/org.eclipse.papyrusrt.umlrt.uml/src/org/eclipse/papyrusrt/umlrt/uml/UMLRTNamedElement.java b/plugins/umlrt/profile/org.eclipse.papyrusrt.umlrt.uml/src/org/eclipse/papyrusrt/umlrt/uml/UMLRTNamedElement.java index 335e6d6bd..be641cdd3 100644 --- a/plugins/umlrt/profile/org.eclipse.papyrusrt.umlrt.uml/src/org/eclipse/papyrusrt/umlrt/uml/UMLRTNamedElement.java +++ b/plugins/umlrt/profile/org.eclipse.papyrusrt.umlrt.uml/src/org/eclipse/papyrusrt/umlrt/uml/UMLRTNamedElement.java @@ -55,11 +55,11 @@ public abstract class UMLRTNamedElement extends FacadeObject { return (NamedElement) super.toUML(); } - CacheAdapter getCacheAdapter() { + protected CacheAdapter getCacheAdapter() { return CacheAdapter.getCacheAdapter(toUML()); } - static Object cacheKey(String key) { + protected static Object cacheKey(String key) { class CacheKey { private final String name; @@ -108,7 +108,7 @@ public abstract class UMLRTNamedElement extends FacadeObject { } } - static String initialLower(String name) { + protected static String initialLower(String name) { String result; if (UML2Util.isEmpty(name)) { @@ -258,6 +258,15 @@ public abstract class UMLRTNamedElement extends FacadeObject { return result; } + /** + * If I am a {@linkplain #isVirtualRedefinition() virtual redefinition} representing + * a purely inherited element, converts me to a real redefinition in the UML model proper. + * There should be very few reasons, indeed, for clients to do this explicitly as it is + * almost always best to let it be done automatically in response to some change in the + * virtual element that causes it to redefine the inherited element. + * + * @see #addReificationListener(ReificationListener) + */ public void reify() { internal().filter(InternalUMLRTElement::rtIsVirtual) .ifPresent(InternalUMLRTElement::rtReify); @@ -381,7 +390,7 @@ public abstract class UMLRTNamedElement extends FacadeObject { * * @return my redefinition chain */ - List<UMLRTNamedElement> redefinitionChain() { + protected List<UMLRTNamedElement> redefinitionChain() { List<UMLRTNamedElement> result; UMLRTNamedElement redef = getRedefinedElement(); @@ -399,7 +408,7 @@ public abstract class UMLRTNamedElement extends FacadeObject { return result; } - Stream<UMLRTNamedElement> excludedElements() { + protected Stream<? extends UMLRTNamedElement> excludedElements() { Stream<UMLRTNamedElement> result = Stream.empty(); NamedElement uml = toUML(); @@ -414,12 +423,28 @@ public abstract class UMLRTNamedElement extends FacadeObject { return result; } - List<UMLRTNamedElement> getExcludedElements() { + /** + * Obtains all of the elements that I have excluded from inheritance: these are + * redefinitions that I own for the sole purpose of excluding them. + * + * @return my excluded elements + */ + public List<UMLRTNamedElement> getExcludedElements() { return excludedElements().collect( collectingAndThen(toList(), Collections::unmodifiableList)); } - <T extends UMLRTNamedElement> T getExcludedElement(String name, Class<T> facadeType) { + /** + * Obtains the named excluded element. + * + * @param name + * the name of the element to find + * @param facadeType + * the kind of excluded element to find + * + * @return the excluded element, or {@code null} if none + */ + public <T extends UMLRTNamedElement> T getExcludedElement(String name, Class<T> facadeType) { return excludedElements() .filter(facadeType::isInstance) .filter(e -> Objects.equals(e.getName(), name)) diff --git a/plugins/umlrt/profile/org.eclipse.papyrusrt.umlrt.uml/src/org/eclipse/papyrusrt/umlrt/uml/UMLRTPackage.java b/plugins/umlrt/profile/org.eclipse.papyrusrt.umlrt.uml/src/org/eclipse/papyrusrt/umlrt/uml/UMLRTPackage.java index 60a4f1145..364b39ca7 100644 --- a/plugins/umlrt/profile/org.eclipse.papyrusrt.umlrt.uml/src/org/eclipse/papyrusrt/umlrt/uml/UMLRTPackage.java +++ b/plugins/umlrt/profile/org.eclipse.papyrusrt.umlrt.uml/src/org/eclipse/papyrusrt/umlrt/uml/UMLRTPackage.java @@ -56,7 +56,7 @@ public class UMLRTPackage extends UMLRTNamedElement { null, UMLPackage.Literals.PACKAGE); - UMLRTPackage(Package package_) { + protected UMLRTPackage(Package package_) { super(package_, null); } diff --git a/plugins/umlrt/profile/org.eclipse.papyrusrt.umlrt.uml/src/org/eclipse/papyrusrt/umlrt/uml/UMLRTPort.java b/plugins/umlrt/profile/org.eclipse.papyrusrt.umlrt.uml/src/org/eclipse/papyrusrt/umlrt/uml/UMLRTPort.java index f000ad4d1..431aa6fb6 100644 --- a/plugins/umlrt/profile/org.eclipse.papyrusrt.umlrt.uml/src/org/eclipse/papyrusrt/umlrt/uml/UMLRTPort.java +++ b/plugins/umlrt/profile/org.eclipse.papyrusrt.umlrt.uml/src/org/eclipse/papyrusrt/umlrt/uml/UMLRTPort.java @@ -42,7 +42,7 @@ import org.eclipse.uml2.uml.VisibilityKind; * A façade for UML {@link Port} elements that represent UML-RT {@link RTPort Port}s, * providing a view of the element more in keeping with the UML-RT semantics. */ -public final class UMLRTPort extends UMLRTReplicatedElement { +public class UMLRTPort extends UMLRTReplicatedElement { static final FacadeType<Port, RTPort, UMLRTPort> TYPE = new FacadeType<>( UMLRTPort.class, UMLPackage.Literals.PORT, @@ -57,7 +57,7 @@ public final class UMLRTPort extends UMLRTReplicatedElement { private static final Object IS_CONNECTED_OUTSIDE_KEY = cacheKey("isConnectedOutside"); private static final Object IS_CONNECTED_KEY = cacheKey("isConnected"); - UMLRTPort(RTPort rtPort) { + protected UMLRTPort(RTPort rtPort) { super(rtPort.getBase_Port(), rtPort); } @@ -210,7 +210,12 @@ public final class UMLRTPort extends UMLRTReplicatedElement { return result; } - Stream<UMLRTConnector> insideConnectors() { + /** + * Obtains a stream over my inside connectors, those which are owned by context {@link #getCapsule() capsule}. + * + * @return my inside connectors + */ + protected Stream<UMLRTConnector> insideConnectors() { UMLRTCapsule capsule = getCapsule(); Predicate<UMLRTConnector> excluded = UMLRTConnector::isExcluded; @@ -221,7 +226,13 @@ public final class UMLRTPort extends UMLRTReplicatedElement { .distinct(); } - Stream<UMLRTConnector> allConnectors() { + /** + * Obtains a stream over all of my connectors, both {@linkplain #insideConnectors() inside} and + * {@linkplain #outsideConnectors() outside}. + * + * @return all of my connectors + */ + protected Stream<UMLRTConnector> allConnectors() { return redefinitionChain().stream() .map(UMLRTPort.class::cast) .flatMap(UMLRTPort::getEnds) @@ -292,7 +303,15 @@ public final class UMLRTPort extends UMLRTReplicatedElement { return result; } - Stream<UMLRTConnector> outsideConnectors() { + /** + * Obtains a stream over my outside connectors, those that are owned by capsules (and connect) parts + * of my {@link #getCapsule() capsule} type. + * + * @return my outside connectors + * + * @see #allPartsWithPort() + */ + protected Stream<UMLRTConnector> outsideConnectors() { return getPartsWithPort().stream() .flatMap(part -> part.getConnectorsOf(this).stream()) .distinct(); @@ -313,7 +332,12 @@ public final class UMLRTPort extends UMLRTReplicatedElement { .collect(collectingAndThen(toList(), Collections::unmodifiableList)); } - Stream<UMLRTPort> allRedefinitions() { + /** + * Obtains a stream over all ports currently loaded that redefine me. + * + * @return my currently known redefinitions + */ + protected Stream<UMLRTPort> allRedefinitions() { Predicate<UMLRTPort> excluded = UMLRTPort::isExcluded; UMLRTCapsule capsule = getCapsule(); return (capsule == null) ? Stream.empty() : capsule.getHierarchy() @@ -321,7 +345,12 @@ public final class UMLRTPort extends UMLRTReplicatedElement { .filter(excluded.negate()); } - Stream<UMLRTCapsulePart> allPartsWithPort() { + /** + * Obtains a steam over all of the currently loaded capsule-parts that expose me as a port. + * + * @return all known parts that feature me + */ + protected Stream<UMLRTCapsulePart> allPartsWithPort() { CacheAdapter cache = CacheAdapter.getCacheAdapter(toUML()); return allRedefinitions() diff --git a/plugins/umlrt/profile/org.eclipse.papyrusrt.umlrt.uml/src/org/eclipse/papyrusrt/umlrt/uml/UMLRTProtocol.java b/plugins/umlrt/profile/org.eclipse.papyrusrt.umlrt.uml/src/org/eclipse/papyrusrt/umlrt/uml/UMLRTProtocol.java index f39bc6408..562eb0ec0 100644 --- a/plugins/umlrt/profile/org.eclipse.papyrusrt.umlrt.uml/src/org/eclipse/papyrusrt/umlrt/uml/UMLRTProtocol.java +++ b/plugins/umlrt/profile/org.eclipse.papyrusrt.umlrt.uml/src/org/eclipse/papyrusrt/umlrt/uml/UMLRTProtocol.java @@ -46,7 +46,7 @@ import org.eclipse.uml2.uml.util.UMLUtil.StereotypeApplicationHelper; * A façade for UML {@link Collaboration} elements that represent UML-RT {@link Protocol}s, * providing a view of the element more in keeping with the UML-RT semantics. */ -public final class UMLRTProtocol extends UMLRTClassifier { +public class UMLRTProtocol extends UMLRTClassifier { static final FacadeType<Collaboration, Protocol, UMLRTProtocol> TYPE = new FacadeType<>( UMLRTProtocol.class, UMLPackage.Literals.COLLABORATION, @@ -155,7 +155,7 @@ public final class UMLRTProtocol extends UMLRTClassifier { */ @Override public void setName(String newName) { - if (isConjugate()) { + if ((newName != null) && isConjugate()) { if (!newName.endsWith("~")) { throw new IllegalArgumentException("conjugate name must end with ~"); //$NON-NLS-1$ } @@ -234,12 +234,22 @@ public final class UMLRTProtocol extends UMLRTClassifier { } /** + * Overrides the inherited operation to account for conjugation. + * + * @return my general protocol, if any, of the same conjugation as myself + */ + @Override + public UMLRTProtocol getGeneral() { + return forConjugation((UMLRTProtocol) super.getGeneral()); + } + + /** * Obtains the protocol that is my supertype, if any. * * @return my supertype, or {@code null} if I am a root protocol type */ public UMLRTProtocol getSuperProtocol() { - return forConjugation((UMLRTProtocol) getGeneral()); + return getGeneral(); } /** diff --git a/plugins/umlrt/profile/org.eclipse.papyrusrt.umlrt.uml/src/org/eclipse/papyrusrt/umlrt/uml/UMLRTProtocolMessage.java b/plugins/umlrt/profile/org.eclipse.papyrusrt.umlrt.uml/src/org/eclipse/papyrusrt/umlrt/uml/UMLRTProtocolMessage.java index 874ad9e98..7815e6731 100644 --- a/plugins/umlrt/profile/org.eclipse.papyrusrt.umlrt.uml/src/org/eclipse/papyrusrt/umlrt/uml/UMLRTProtocolMessage.java +++ b/plugins/umlrt/profile/org.eclipse.papyrusrt.umlrt.uml/src/org/eclipse/papyrusrt/umlrt/uml/UMLRTProtocolMessage.java @@ -38,7 +38,7 @@ import org.eclipse.uml2.uml.UMLPackage; * A façade for UML {@link Operation} elements that represent UML-RT {@code ProtocolMessage}s, * providing a view of the element more in keeping with the UML-RT semantics. */ -public final class UMLRTProtocolMessage extends UMLRTNamedElement { +public class UMLRTProtocolMessage extends UMLRTNamedElement { static final FacadeType<Operation, EObject, UMLRTProtocolMessage> TYPE = new FacadeType<>( UMLRTProtocolMessage.class, UMLPackage.Literals.OPERATION, @@ -129,7 +129,7 @@ public final class UMLRTProtocolMessage extends UMLRTNamedElement { * * @return whether I am a conjugate */ - boolean isConjugate() { + public boolean isConjugate() { return isConjugate; } @@ -139,7 +139,7 @@ public final class UMLRTProtocolMessage extends UMLRTNamedElement { * * @return my conjugate */ - UMLRTProtocolMessage getConjugate() { + public UMLRTProtocolMessage getConjugate() { return conjugate.get(); } |
