本文整理汇总了Java中org.eclipse.uml2.uml.Property.setVisibility方法的典型用法代码示例。如果您正苦于以下问题:Java Property.setVisibility方法的具体用法?Java Property.setVisibility怎么用?Java Property.setVisibility使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.uml2.uml.Property
的用法示例。
在下文中一共展示了Property.setVisibility方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setElementInfo
import org.eclipse.uml2.uml.Property; //导入方法依赖的package包/类
/**
* setElementInfo
* void
*/
private void setElementInfo() {
if (viewModel.getNodeType().equals(NodeType.ATTRIBUTE)) {
Property property = (Property) viewModel.getUmlModel();
if (newText.contains("-")) {
property.setVisibility(VisibilityKind.PRIVATE_LITERAL);
} else if (newText.contains("+")) {
property.setVisibility(VisibilityKind.PUBLIC_LITERAL);
} else if (newText.contains("~")) {
property.setVisibility(VisibilityKind.PACKAGE_LITERAL);
} else if (newText.contains("#")) {
property.setVisibility(VisibilityKind.PROTECTED_LITERAL);
}
} else if (viewModel.getNodeType().equals(NodeType.ATTRIBUTE)) {
}
}
示例2: testAttribute
import org.eclipse.uml2.uml.Property; //导入方法依赖的package包/类
@Test
public void testAttribute() {
// given
List<String> attrNames = Arrays.asList("a", "b", "c", "d", "e", "f");
ArrayList<Type> attrTypes = new ArrayList<>();
attrTypes.add(classA);
attrTypes.addAll(primitives.getSecond());
List<String> attrTypeNames = new ArrayList<>();
attrTypeNames.add("A");
attrTypeNames.addAll(primitives.getFirst());
List<VisibilityKind> expectedVisibilities = Arrays.asList(VisibilityKind.PUBLIC_LITERAL,
VisibilityKind.PROTECTED_LITERAL, VisibilityKind.PRIVATE_LITERAL, VisibilityKind.PACKAGE_LITERAL,
VisibilityKind.PUBLIC_LITERAL, VisibilityKind.PROTECTED_LITERAL);
List<Boolean> expectedStaticnesses = Arrays.asList(true, false, true, false, true, false);
// when
List<Attribute> instances = new ArrayList<>();
for (int i = 0; i < attrNames.size(); ++i) {
Property p = classA.createOwnedAttribute(attrNames.get(i), attrTypes.get(i));
p.setVisibility(expectedVisibilities.get(i));
p.setIsStatic(expectedStaticnesses.get(i));
instances.add(new Attribute(p));
}
// then
IntStream.range(0, instances.size()).forEach(i -> {
Attribute instanceAttribute = instances.get(i);
Assert.assertEquals(attrNames.get(i), instanceAttribute.getName());
Assert.assertEquals(attrTypeNames.get(i), instanceAttribute.getType());
Assert.assertEquals(expectedVisibilities.get(i), instanceAttribute.getVisibility());
Assert.assertEquals(expectedStaticnesses.get(i), instanceAttribute.isStatic());
});
}
示例3: transformAttributes
import org.eclipse.uml2.uml.Property; //导入方法依赖的package包/类
/**
* transform attributes for target class or interface
*
* @param sourceType
* @param targetType
* @param targetStructureTransformationData
*/
private static void transformAttributes(Type sourceType, Type targetType,
TargetStructureTransformationData targetStructureTransformationData) {
EList<Property> sourceProperties = null;
Property sourceProperty = null;
Property targetProperty = null;
boolean isNewlyCreated = false;
// Source(분석 모델)요소가 Class인 경우
if (sourceType instanceof Class) {
sourceProperties = ((Class) sourceType).getOwnedAttributes();
// Source(분석 모델)요소가 Interface인 경우
} else if (sourceType instanceof Interface) {
sourceProperties = ((Interface) sourceType).getOwnedAttributes();
}
for (Iterator<Property> propertyIterator = sourceProperties.iterator(); propertyIterator.hasNext();) {
sourceProperty = propertyIterator.next();
if (targetType instanceof Interface) {
targetProperty = ((Interface) targetType).getOwnedAttribute(sourceProperty.getName(), null);
if (targetProperty == null) {
/**
* 2011.03.09 조승현 원래는 모든 property 의 Type을 다 복사해야 맞지만,
* Primitive 타입이 아닐 경우에는 아직 만들어 지지 않은 Type(Class) 일 수도 있어서,
* 현재는 Primitive 타입일 경우에만 Type을 복사 함. 전개 순서를 패키지 -> Type ->
* Attribute -> Operation... 으로 바꾸는 작업이 선행 되어야 함.
*/
if (sourceProperty.getType() instanceof PrimitiveType) {
targetProperty = ((Class) targetType).createOwnedAttribute(sourceProperty.getName(),
sourceProperty.getType());
} else {
targetProperty = ((Class) targetType).createOwnedAttribute(sourceProperty.getName(), null);
}
isNewlyCreated = true;
}
} else if (targetType instanceof Class) {
targetProperty = ((Class) targetType).getOwnedAttribute(sourceProperty.getName(), null);
/**
* 2011.03.09 조승현 원래는 모든 property 의 Type을 다 복사해야 맞지만, Primitive
* 타입이 아닐 경우에는 아직 만들어 지지 않은 Type(Class) 일 수도 있어서, 현재는 Primitive
* 타입일 경우에만 Type을 복사 함. 전개 순서를 패키지 -> Type -> Attribute ->
* Operation... 으로 바꾸는 작업이 선행 되어야 함.
*/
if (targetProperty == null) {
if (sourceProperty.getType() instanceof PrimitiveType) {
targetProperty = ((Class) targetType).createOwnedAttribute(sourceProperty.getName(),
sourceProperty.getType());
} else {
targetProperty = ((Class) targetType).createOwnedAttribute(sourceProperty.getName(), null);
}
isNewlyCreated = true;
}
}
if (targetStructureTransformationData != null
&& targetStructureTransformationData.getPropertyApplicableStereotype() != null
&& targetProperty != null) {
applyStereotype(sourceProperty, targetProperty, targetStructureTransformationData.getPropertyApplicableStereotype());
}
// 신규 생성인 경우
if (isNewlyCreated) {
// 코멘트를 복사한다
copyComment(sourceProperty, targetProperty);
}
targetProperty.setVisibility(sourceProperty.getVisibility());
}
}