本文整理汇总了Java中org.eclipse.uml2.uml.Association.getOwnedEnd方法的典型用法代码示例。如果您正苦于以下问题:Java Association.getOwnedEnd方法的具体用法?Java Association.getOwnedEnd怎么用?Java Association.getOwnedEnd使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.uml2.uml.Association
的用法示例。
在下文中一共展示了Association.getOwnedEnd方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testSimpleAggregation
import org.eclipse.uml2.uml.Association; //导入方法依赖的package包/类
public void testSimpleAggregation() throws CoreException {
String source = "";
source += "model simple;\n";
source += "aggregation AccountClient\n";
source += " navigable role account : Account[*];\n";
source += " navigable role client : Client[1];\n";
source += "end;\n";
source += "end.";
parseAndCheck(getSimpleModelSource(), source);
final Association association = (Association) getRepository().findNamedElement("simple::AccountClient",
IRepository.PACKAGE.getAssociation(), null);
assertNotNull(association);
Property accountEnd = association.getOwnedEnd("account", null);
assertNotNull(accountEnd);
assertEquals(AggregationKind.SHARED_LITERAL, accountEnd.getAggregation());
Property clientEnd = association.getOwnedEnd("client", null);
assertNotNull(clientEnd);
assertEquals(AggregationKind.NONE_LITERAL, clientEnd.getAggregation());
}
示例2: testSimpleComposition
import org.eclipse.uml2.uml.Association; //导入方法依赖的package包/类
public void testSimpleComposition() throws CoreException {
String source = "";
source += "model simple;\n";
source += "composition AccountClient\n";
source += " navigable role account : Account[*];\n";
source += " navigable role client : Client[1];\n";
source += "end;\n";
source += "end.";
parseAndCheck(getSimpleModelSource(), source);
final Association association = getRepository().findNamedElement("simple::AccountClient",
IRepository.PACKAGE.getAssociation(), null);
assertNotNull(association);
Property accountEnd = association.getOwnedEnd("account", null);
assertNotNull(accountEnd);
assertEquals(AggregationKind.COMPOSITE_LITERAL, accountEnd.getAggregation());
Property clientEnd = association.getOwnedEnd("client", null);
assertNotNull(clientEnd);
assertEquals(AggregationKind.NONE_LITERAL, clientEnd.getAggregation());
}
示例3: testMemberEnd
import org.eclipse.uml2.uml.Association; //导入方法依赖的package包/类
private void testMemberEnd(String keyword, AggregationKind expected) throws CoreException {
String source = "";
source += "model simple;\n";
source += " class ClientWithAccountAttribute\n";
source += " attribute account : AccountWithClientAttribute;\n";
source += " end;\n";
source += " class AccountWithClientAttribute\n";
source += " attribute client : ClientWithAccountAttribute;\n";
source += " end;\n";
source += keyword + " AccountClient\n";
source += " role ClientWithAccountAttribute.account;\n";
source += " role AccountWithClientAttribute.client;\n";
source += "end;\n";
source += "end.";
parseAndCheck(source);
Class accountClass = (Class) getRepository().findNamedElement("simple::AccountWithClientAttribute",
IRepository.PACKAGE.getClass_(), null);
Class clientClass = (Class) getRepository().findNamedElement("simple::ClientWithAccountAttribute",
IRepository.PACKAGE.getClass_(), null);
final Association association = (Association) getRepository().findNamedElement("simple::AccountClient",
IRepository.PACKAGE.getAssociation(), null);
assertNotNull(association);
Property accountEnd = association.getOwnedEnd("account", accountClass);
assertNull(accountEnd);
accountEnd = association.getMemberEnd("account", accountClass);
assertNotNull(accountEnd);
assertEquals(expected, accountEnd.getAggregation());
Property clientEnd = association.getOwnedEnd("client", clientClass);
assertNull(clientEnd);
clientEnd = association.getMemberEnd("client", clientClass);
assertNotNull(clientEnd);
assertEquals(AggregationKind.NONE_LITERAL, clientEnd.getAggregation());
assertEquals(1, ((LiteralUnlimitedNatural) accountEnd.getLowerValue()).getValue());
assertEquals(1, ((LiteralUnlimitedNatural) accountEnd.getUpperValue()).getValue());
assertEquals(1, ((LiteralUnlimitedNatural) clientEnd.getLowerValue()).getValue());
assertEquals(1, ((LiteralUnlimitedNatural) clientEnd.getUpperValue()).getValue());
}
示例4: testMixedMemberEnd
import org.eclipse.uml2.uml.Association; //导入方法依赖的package包/类
public void testMixedMemberEnd() throws CoreException {
String source = "";
source += "model simple;\n";
source += " class Parent\n";
source += " attribute children : Child[*];\n";
source += " end;\n";
source += " class Child\n";
source += " end;\n";
source += " composition Hierarchy\n";
source += " role Parent.children;\n";
source += " role parent : Parent;\n";
source += " end;\n";
source += "end.";
parseAndCheck(source);
Class parentClass = (Class) getRepository().findNamedElement("simple::Parent", IRepository.PACKAGE.getClass_(),
null);
Class childClass = (Class) getRepository().findNamedElement("simple::Child", IRepository.PACKAGE.getClass_(),
null);
final Association association = (Association) getRepository().findNamedElement("simple::Hierarchy",
IRepository.PACKAGE.getAssociation(), null);
Property parentEnd = association.getOwnedEnd("parent", parentClass);
assertNotNull(parentEnd);
assertEquals(AggregationKind.NONE_LITERAL, parentEnd.getAggregation());
Property childrenEnd = association.getOwnedEnd("children", childClass);
assertNull(childrenEnd);
childrenEnd = association.getMemberEnd("children", childClass);
assertNotNull(childrenEnd);
assertEquals(AggregationKind.COMPOSITE_LITERAL, childrenEnd.getAggregation());
assertEquals(0, ((LiteralInteger) childrenEnd.getLowerValue()).getValue());
assertEquals(LiteralUnlimitedNatural.UNLIMITED,
((LiteralUnlimitedNatural) childrenEnd.getUpperValue()).getValue());
assertEquals(1, ((LiteralUnlimitedNatural) parentEnd.getLowerValue()).getValue());
assertEquals(1, ((LiteralUnlimitedNatural) parentEnd.getUpperValue()).getValue());
}
示例5: testSimpleAssociation
import org.eclipse.uml2.uml.Association; //导入方法依赖的package包/类
public void testSimpleAssociation() throws CoreException {
String source = "";
source += "model simple;\n";
source += "association AccountClient\n";
source += " role account : Account[*];\n";
source += " readonly !navigable role client : Client[1];\n";
source += "end;\n";
source += "end.";
parseAndCheck(getSimpleModelSource(), source);
Class accountClass = (Class) getRepository().findNamedElement("simple::Account",
IRepository.PACKAGE.getClass_(), null);
Class clientClass = (Class) getRepository().findNamedElement("simple::Client", IRepository.PACKAGE.getClass_(),
null);
final Association association = (Association) getRepository().findNamedElement("simple::AccountClient",
IRepository.PACKAGE.getAssociation(), null);
assertNotNull(association);
Property accountEnd = association.getOwnedEnd("account", accountClass);
assertNotNull(accountEnd);
assertTrue(accountEnd.isNavigable());
assertTrue(!accountEnd.isReadOnly());
assertEquals(AggregationKind.NONE_LITERAL, accountEnd.getAggregation());
Property clientEnd = association.getOwnedEnd("client", clientClass);
assertNotNull(clientEnd);
assertTrue(!clientEnd.isNavigable());
assertTrue(clientEnd.isReadOnly());
assertEquals(AggregationKind.NONE_LITERAL, clientEnd.getAggregation());
assertEquals(0, ((LiteralInteger) accountEnd.getLowerValue()).getValue());
assertEquals(LiteralUnlimitedNatural.UNLIMITED,
((LiteralUnlimitedNatural) accountEnd.getUpperValue()).getValue());
assertEquals(1, ((LiteralInteger) clientEnd.getLowerValue()).getValue());
assertEquals(1, ((LiteralUnlimitedNatural) clientEnd.getUpperValue()).getValue());
}
示例6: testAssociationRoleStereotypeApplication
import org.eclipse.uml2.uml.Association; //导入方法依赖的package包/类
public void testAssociationRoleStereotypeApplication() throws CoreException {
String profileSource = "";
profileSource += "profile someProfile;\n";
profileSource += "stereotype my_stereotype extends UML::Property end;\n";
profileSource += "end.\n";
String modelSource = "";
modelSource += "model someModel;\n";
modelSource += "import base;\n";
modelSource += "apply someProfile;\n";
modelSource += "class SomeClass\n";
modelSource += " attribute someAttribute : Integer;\n";
modelSource += "end;\n";
modelSource += "class AnotherClass\n";
modelSource += " attribute anotherAttribute : Integer;\n";
modelSource += "end;\n";
modelSource += "association SomeAssoc\n";
modelSource += " [my_stereotype] role anotherAttribute : AnotherClass;\n";
modelSource += " [my_stereotype] navigable role SomeClass.someAttribute;\n";
modelSource += "end;\n";
modelSource += "end.\n";
IProblem[] problems = parse(profileSource, modelSource);
assertTrue(problems.length == 1);
assertTrue(problems[0].getSeverity() == IProblem.Severity.WARNING);
Class class_ = (Class) getRepository().findNamedElement("someModel::SomeClass",
IRepository.PACKAGE.getClassifier(), null);
Property attribute = class_.getAttribute("someAttribute", null);
Association assoc = (Association) getRepository().findNamedElement("someModel::SomeAssoc",
IRepository.PACKAGE.getAssociation(), null);
Stereotype stereotype = (Stereotype) getRepository().findNamedElement("someProfile::my_stereotype",
IRepository.PACKAGE.getStereotype(), null);
assertNotNull(stereotype);
assertNotNull(assoc);
Property anotherEnd = assoc.getOwnedEnd("anotherAttribute", null);
assertNotNull(anotherEnd);
assertTrue(anotherEnd.isStereotypeApplied(stereotype));
assertFalse(attribute.isStereotypeApplied(stereotype));
}