当前位置: 首页>>代码示例>>Java>>正文


Java Class.getOwnedAttribute方法代码示例

本文整理汇总了Java中org.eclipse.uml2.uml.Class.getOwnedAttribute方法的典型用法代码示例。如果您正苦于以下问题:Java Class.getOwnedAttribute方法的具体用法?Java Class.getOwnedAttribute怎么用?Java Class.getOwnedAttribute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.uml2.uml.Class的用法示例。


在下文中一共展示了Class.getOwnedAttribute方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testAssociationShorthand

import org.eclipse.uml2.uml.Class; //导入方法依赖的package包/类
public void testAssociationShorthand() throws CoreException {
    String source = "";
    source += "model simple;\n";
    source += "class A\n";
    source += "end;\n";
    source += "class C\n";
    source += "end;\n";
    source += "class B\n";
    source += "  reference a : A;\n";
    source += "end;\n";
    source += "end.";
    parseAndCheck(source);
    Class classA = (Class) getRepository().findNamedElement("simple::A", IRepository.PACKAGE.getClass_(), null);
    Class classB = (Class) getRepository().findNamedElement("simple::B", IRepository.PACKAGE.getClass_(), null);

    Property propertyA = classB.getOwnedAttribute("a", null);
    assertNotNull(propertyA);

    Association association = propertyA.getAssociation();
    assertNotNull(association);

    assertTrue(association.getMemberEnds().contains(propertyA));
    assertFalse(association.getOwnedEnds().contains(propertyA));
    assertEquals(AggregationKind.NONE_LITERAL, propertyA.getAggregation());
    assertSame(classA, propertyA.getType());

    Property otherEnd = propertyA.getOtherEnd();
    assertTrue(association.getMemberEnds().contains(otherEnd));
    assertTrue(association.getOwnedEnds().contains(otherEnd));
    assertEquals(AggregationKind.NONE_LITERAL, otherEnd.getAggregation());
    assertSame(classB, otherEnd.getType());
}
 
开发者ID:abstratt,项目名称:textuml,代码行数:33,代码来源:AssociationTests.java

示例2: testAggregationShorthand

import org.eclipse.uml2.uml.Class; //导入方法依赖的package包/类
public void testAggregationShorthand() throws CoreException {
    String source = "";
    source += "model simple;\n";
    source += "class A\n";
    source += "end;\n";
    source += "class C\n";
    source += "end;\n";
    source += "class B\n";
    source += "  aggregation a : A;\n";
    source += "end;\n";
    source += "end.";
    parseAndCheck(source);
    Class classA = (Class) getRepository().findNamedElement("simple::A", IRepository.PACKAGE.getClass_(), null);
    Class classB = (Class) getRepository().findNamedElement("simple::B", IRepository.PACKAGE.getClass_(), null);

    Property propertyA = classB.getOwnedAttribute("a", null);
    assertNotNull(propertyA);

    Association association = propertyA.getAssociation();
    assertNotNull(association);

    assertTrue(association.getMemberEnds().contains(propertyA));
    assertFalse(association.getOwnedEnds().contains(propertyA));
    assertEquals(AggregationKind.SHARED_LITERAL, propertyA.getAggregation());
    assertSame(classA, propertyA.getType());

    Property otherEnd = propertyA.getOtherEnd();
    assertTrue(association.getMemberEnds().contains(otherEnd));
    assertTrue(association.getOwnedEnds().contains(otherEnd));
    assertEquals(AggregationKind.NONE_LITERAL, otherEnd.getAggregation());
    assertSame(classB, otherEnd.getType());
}
 
开发者ID:abstratt,项目名称:textuml,代码行数:33,代码来源:AssociationTests.java

示例3: testCompositionShorthand

import org.eclipse.uml2.uml.Class; //导入方法依赖的package包/类
public void testCompositionShorthand() throws CoreException {
    String source = "";
    source += "model simple;\n";
    source += "class A\n";
    source += "end;\n";
    source += "class C\n";
    source += "end;\n";
    source += "class B\n";
    source += "  composition a : A;\n";
    source += "end;\n";
    source += "end.";
    parseAndCheck(source);
    Class classA = (Class) getRepository().findNamedElement("simple::A", IRepository.PACKAGE.getClass_(), null);
    Class classB = (Class) getRepository().findNamedElement("simple::B", IRepository.PACKAGE.getClass_(), null);

    Property propertyA = classB.getOwnedAttribute("a", null);
    assertNotNull(propertyA);

    Association association = propertyA.getAssociation();
    assertNotNull(association);

    assertTrue(association.getMemberEnds().contains(propertyA));
    assertFalse(association.getOwnedEnds().contains(propertyA));
    assertEquals(AggregationKind.COMPOSITE_LITERAL, propertyA.getAggregation());
    assertSame(classA, propertyA.getType());

    Property otherEnd = propertyA.getOtherEnd();
    assertTrue(association.getMemberEnds().contains(otherEnd));
    assertTrue(association.getOwnedEnds().contains(otherEnd));
    assertEquals(AggregationKind.NONE_LITERAL, otherEnd.getAggregation());
    assertSame(classB, otherEnd.getType());
}
 
开发者ID:abstratt,项目名称:textuml,代码行数:33,代码来源:AssociationTests.java

示例4: testAttributeWithInvariants

import org.eclipse.uml2.uml.Class; //导入方法依赖的package包/类
public void testAttributeWithInvariants() throws CoreException {
    String source = "";
    source += "model someModel;\n";
    source += "import base;\n";
    source += "class SomeClass\n";
    source += "attribute attr1: Boolean\n";
    source += "invariant condition1 { true }\n";
    source += "invariant { true }\n";
    source += "invariant condition3 { not self.attr1 };\n";
    source += "end;\n";
    source += "end.";
    parseAndCheck(source);
    Class class_ = (Class) getRepository().findNamedElement("someModel::SomeClass",
            IRepository.PACKAGE.getClass_(), null);
    assertNotNull(class_);
    Property property = class_.getOwnedAttribute("attr1", null);
    assertNotNull(property);
    assertEquals(3, class_.getOwnedRules().size());

    assertEquals("condition1", class_.getOwnedRules().get(0).getName());
    assertNull(class_.getOwnedRules().get(1).getName());
    assertEquals("condition3", class_.getOwnedRules().get(2).getName());

    assertNotNull(class_.getOwnedRules().get(0).getSpecification());

    for (Constraint constraint : class_.getOwnedRules()) {
        // expect only the return parameter
        checkConstraint(constraint, 1);
        assertEquals(Arrays.asList(property), constraint.getConstrainedElements());
    }
}
 
开发者ID:abstratt,项目名称:textuml,代码行数:32,代码来源:ClassifierTests.java


注:本文中的org.eclipse.uml2.uml.Class.getOwnedAttribute方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。