本文整理汇总了Java中org.eclipse.uml2.uml.Class类的典型用法代码示例。如果您正苦于以下问题:Java Class类的具体用法?Java Class怎么用?Java Class使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Class类属于org.eclipse.uml2.uml包,在下文中一共展示了Class类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getContainedValidElementCount
import org.eclipse.uml2.uml.Class; //导入依赖的package包/类
/**
* 입력된 패키지의 하위패키지 중 의미있는 엘리먼트를 가지고 있는지 카운트를 반환한다. 몇개가 있는지가 중요한것이 아니라, 있는지
* 없는지만 알면 되므로 cnt 가 0을 넘으면 더 이상 수행하지 않고 그냥 cnt 를 반환한다. 이 메소드는 전개 후 불필요하게
* 생성된 빈 패키지를 없애기 위해 수행된다. 재귀 메소드 임. 의미있는 엘리먼트 : 더 필요하면 추가 할 것 - 클래스, 인터페이스,
* Collaboration, Actor, Component, Interaction
*
* @param targetPackage
* @param cnt
* @return int
*/
public static int getContainedValidElementCount(Package targetPackage, int cnt) {
if (cnt > 0)
return cnt;
for (Package p : targetPackage.getNestedPackages()) {
for (Element element : p.getOwnedElements()) {
if (element instanceof Class || element instanceof Interface || element instanceof Collaboration
|| element instanceof Actor || element instanceof Component || element instanceof Interaction) {
cnt++;
}
}
cnt = getContainedValidElementCount(p, cnt);
}
return cnt;
}
示例2: getHyperlinks
import org.eclipse.uml2.uml.Class; //导入依赖的package包/类
/**
* @see org.eclipse.papyrus.infra.hyperlink.service.HyperlinkContributor#getHyperlinks(java.lang.Object)
*
* @param object
* @return
*/
@Override
public List<HyperLinkObject> getHyperlinks(Object object) {
List<HyperLinkObject> hyperlinks = new ArrayList<>();
if (object instanceof Class) {
Class clazz = (Class) object;
if (UMLUtil.getStereotypeApplication(clazz, Book.class) != null) {
// TODO: extract a method to get the borrower from a book in the
// java implementation of the profile
EList<DirectedRelationship> targetDirectedRelationships = clazz.getTargetDirectedRelationships();
for (DirectedRelationship dependency : targetDirectedRelationships) {
if (UMLUtil.getStereotypeApplication(dependency, Borrows.class) != null) {
EList<Element> targets = dependency.getSources();
for (Element element : targets) {
Set<View> crossReferencingViews = CrossReferencerUtil.getCrossReferencingViews(element,null);
// we take the first available view
Object firstView = crossReferencingViews.toArray()[0];
HyperLinkSpecificObject hyperlink = new HyperLinkSpecificObject((EObject) firstView);
hyperlinks.add(hyperlink);
}
}
}
}
}
return hyperlinks;
}
示例3: getNavigableElements
import org.eclipse.uml2.uml.Class; //导入依赖的package包/类
@Override
public List<NavigableElement> getNavigableElements(Object fromElement) {
List<NavigableElement> result = new LinkedList<>();
Element element = org.eclipse.papyrus.uml.tools.utils.UMLUtil.resolveUMLElement(fromElement);
if (element instanceof Class){
final Book book = UMLUtil.getStereotypeApplication(element, Book.class);
if (book != null) {
final BookCategory category = book.getCategory();
Resource eResource = book.eResource();
EList<EObject> contents = eResource.getContents();
result =
contents.stream()
.filter(l -> !l.equals(book))
.filter(l -> l instanceof Book)
.map(l -> (Book) l)
.filter(l -> category.equals(l.getCategory()))
.map(l -> l.getBase_Class())
.map(clazz -> new SameCategoryNavigableElement(clazz))
.collect(Collectors.toList());
}
}
return result;
}
示例4: getApplicableStereotypes
import org.eclipse.uml2.uml.Class; //导入依赖的package包/类
/**
* find applicable stereotypes for meta class
*
* @param profile
* @param metaClassName
* @return
*/
public static List<Stereotype> getApplicableStereotypes(Profile profile, String metaClassName) {
if (profile == null || metaClassName == null)
return null;
List<Stereotype> applicableStereotypes = new ArrayList<Stereotype>();
for (Iterator<Stereotype> iter = profile.getOwnedStereotypes().iterator(); iter.hasNext();) {
Stereotype stereotype = (Stereotype) iter.next();
EList<Class> extendedMetaClasses = stereotype.getExtendedMetaclasses();
for (int clazzCount = 0; clazzCount < extendedMetaClasses.size(); clazzCount++) {
Class clazz = extendedMetaClasses.get(clazzCount);
if (clazz.getName().equals(metaClassName))
applicableStereotypes.add(stereotype);
}
}
return applicableStereotypes;
}
示例5: getSameNameOperation
import org.eclipse.uml2.uml.Class; //导入依赖的package包/类
/**
* Checks if a class contains the same name operation
*
* @param obj
* class or interface
* @param op
* The operation
* @return True if the class contains the operation.
*/
public static Operation getSameNameOperation(Object obj, String opName) {
Operation foundOperation = null;
if (opName == null || obj == null)
return null;
Iterator iter = null;
if (obj instanceof Class) {
Class cls = (Class) obj;
iter = cls.getOperations().iterator();
} else if (obj instanceof Interface) {
Interface inter = (Interface) obj;
iter = inter.getOperations().iterator();
}
while (foundOperation == null && iter.hasNext()) {
Operation ownedOp = (Operation) iter.next();
if (opName.equals(ownedOp.getName()))
foundOperation = ownedOp;
}
return foundOperation;
}
示例6: hasComponentChild
import org.eclipse.uml2.uml.Class; //导入依赖的package包/类
/**
*
* SelectedElement 하위에 컴포넌트가 있는지 검사.
*
* @param parentElement
* @return
*/
private boolean hasComponentChild(Element parentElement) {
for( Element child : parentElement.getOwnedElements() ) {
if( child instanceof org.eclipse.uml2.uml.Class ) {
if( COMPONENT_STEREOTYPE.equals( ProjectUtil.getStereotypeLabel(child).trim() ) ) {
return true;
}
}
if (child instanceof PackageableElement) {
if(hasComponentChild( child )){
return true;
}
}
}
return false;
}
示例7: createClassDataModelList
import org.eclipse.uml2.uml.Class; //导入依赖的package包/类
/**
* Class 데이터 모델 리스트를 생성합니다.
*
* @param pkg
* @return List<DataModel>
*/
private List<DataModel> createClassDataModelList(Package pkg) {
List<DataModel> classModelList = new ArrayList<DataModel>();
DataModel classModel;
List<PackageableElement> list = pkg.getPackagedElements();
List<Class> classes = new ArrayList<Class>();
for (PackageableElement packageableElement : list) {
if (packageableElement.eClass() == UMLPackage.Literals.CLASS) {
classes.add((Class) packageableElement);
}
}
ProjectUtil.getSortedList(classes);
if (!classes.isEmpty()) {
for (Class clazz : classes) {
classModel = new DataModel();
setDataModel(classModel, UICoreConstant.REPORT__CLASS_NAME, clazz.getName());
setDataModel(classModel, UICoreConstant.REPORT__CLASS_STEREOTYPE, ProjectUtil.getStereotypeLabel(clazz));
setDataModel(classModel,
UICoreConstant.REPORT__CLASS_DOCUMENTATION,
getCommentToString(clazz.getOwnedComments()));
setDataModel(classModel, UICoreConstant.REPORT__ATTRIBUTE_LIST, createAttributeDataModelList(clazz));
setDataModel(classModel, UICoreConstant.REPORT__OPERATION_LIST, createOperationDataModelList(clazz));
classModelList.add(classModel);
}
}
return classModelList;
}
示例8: getTypeList
import org.eclipse.uml2.uml.Class; //导入依赖的package包/类
/**
*
* void
*/
private void getTypeList() {
typeList.clear();
typeList.add(pType);
if (pType instanceof Class) {
Class clazz = (Class) pType;
List<Interface> interfaces = clazz.getAllImplementedInterfaces();
typeList.addAll(interfaces);
}
typeCombo.removeAll();
for (Type t : typeList) {
typeCombo.add(t.getName());
}
typeCombo.select(0);
}
示例9: createClass
import org.eclipse.uml2.uml.Class; //导入依赖的package包/类
/**
* Lifeline의 Type에 새 클래스 생성. (생성된 클래스를 Type에 붙이는 것은 transaction 때문에
* execute()에서 처리) void
*
* @param parentNodeModel
*/
public static org.eclipse.uml2.uml.Class createClass(AbstractNode parentNodeModel) {
PackageableElement parentElement = UMLManager.getParentPackage(parentNodeModel);
org.eclipse.uml2.uml.Class umlClass = null;
CreateClassDialog dialog = new CreateClassDialog(RealizationPlugin.getShell());
if (dialog.open() == Window.OK) {
String className = dialog.getClassName();
umlClass = UMLHelper.createClass();
if (className.equals(UICoreConstant.PROJECT_CONSTANTS__EMPTY_STRING)) {
umlClass.setName(UMLManager.getPackagedUniqueName((Namespace) parentElement, umlClass.getName()));
} else {
umlClass.setName(className);
}
}
return umlClass;
}
示例10: generateConstants
import org.eclipse.uml2.uml.Class; //导入依赖的package包/类
/**
* Generate Enumeration constants.
*
* @param clazz
* the UML class
* @param ast
* the JDT Java AST
* @param ed
* Enumeration declaration for Java JDT
*/
public void generateConstants(Classifier clazz, PrintWriter writer) {
// Get all properties for this enumeration class
Class enumerationClass = (Class) clazz;
EList<Property> attributes = enumerationClass.getAttributes();
int count=0;
for (Property enumLiteral : attributes) {
count++;
String comments=andromdaHelper.concatComments(enumLiteral.getOwnedComments());
if(StringUtils.isNotEmpty(comments)){
generateSimpleComment(writer, comments.split("\n"));
}
String literalName = nameMasker.mask(enumLiteral.getName(),NameMasker.UPPERUNDERSCORE);
writer.format("%s(%s)",literalName,resolveConstantValue(enumLiteral));
if(count < attributes.size()){
writer.println(",");
} else {
writer.println(";");
}
}
}
示例11: validateCooperateModel
import org.eclipse.uml2.uml.Class; //导入依赖的package包/类
@Override
public boolean validateCooperateModel(IValidationContext ctx, Association target) {
Collection<java.lang.Class<?>> relevantEndTypes = Arrays.asList(Class.class, Interface.class);
if (!target.getEndTypes().stream().allMatch(
testType -> relevantEndTypes.stream().anyMatch(relevantType -> relevantType.isInstance(testType)))) {
// The association is not in a class diagram and therefore not relevant for this constraint
return true;
}
if (!StringUtils.isBlank(target.getName())) {
return true;
}
Collection<Type> wantedTypes = getTypes(target);
return target.getNearestPackage().getMembers().stream().filter(Association.class::isInstance)
.map(Association.class::cast).filter(a -> a != target).allMatch(a -> !getTypes(a).equals(wantedTypes));
}
开发者ID:Cooperate-Project,项目名称:CooperateModelingEnvironment,代码行数:18,代码来源:ClassDiagramAssociationConstraint.java
示例12: testLink
import org.eclipse.uml2.uml.Class; //导入依赖的package包/类
@Test
public void testLink() throws Exception {
Model model = model("hu.elte.txtuml.export.uml2.tests.models.link_and_unlink");
Class clsA = cls(model, "A");
Property otherEnd = property(clsA, "OtherEnd", "B");
Class clsB = cls(model, "B");
Property thisEnd = property(clsB, "ThisEnd", "A");
SequenceNode body = loadActionCode(model, "A", "testLink");
SequenceNode linkStmt = node(body, 0, "link inst1 to inst2;", SequenceNode.class);
node(linkStmt, 0, "inst1", ReadVariableAction.class);
node(linkStmt, 1, "inst2", ReadVariableAction.class);
CreateLinkAction linkNode = node(linkStmt, 2, "link inst1 to inst2", CreateLinkAction.class);
assertEquals(thisEnd, linkNode.getEndData().get(0).getEnd());
assertNotNull(linkNode.getEndData().get(0).getValue());
assertEquals(otherEnd, linkNode.getEndData().get(1).getEnd());
assertNotNull(linkNode.getEndData().get(1).getValue());
}
示例13: testUnlink
import org.eclipse.uml2.uml.Class; //导入依赖的package包/类
@Test
public void testUnlink() throws Exception {
Model model = model("hu.elte.txtuml.export.uml2.tests.models.link_and_unlink");
Class clsA = cls(model, "A");
Property otherEnd = property(clsA, "OtherEnd", "B");
Class clsB = cls(model, "B");
Property thisEnd = property(clsB, "ThisEnd", "A");
SequenceNode body = loadActionCode(model, "A", "testUnlink");
SequenceNode linkStmt = node(body, 0, "unlink inst1 from inst2;", SequenceNode.class);
node(linkStmt, 0, "inst1", ReadVariableAction.class);
node(linkStmt, 1, "inst2", ReadVariableAction.class);
DestroyLinkAction linkNode = node(linkStmt, 2, "unlink inst1 from inst2", DestroyLinkAction.class);
assertEquals(thisEnd, linkNode.getEndData().get(0).getEnd());
assertNotNull(linkNode.getEndData().get(0).getValue());
assertEquals(otherEnd, linkNode.getEndData().get(1).getEnd());
assertNotNull(linkNode.getEndData().get(1).getValue());
}
示例14: testSMActions
import org.eclipse.uml2.uml.Class; //导入依赖的package包/类
@Test
public void testSMActions() throws Exception {
Model model = model("hu.elte.txtuml.export.uml2.tests.models.sm_actions");
Class cls = cls(model, "TestClass");
SignalEvent sig = signalEvent(model, "TestSignal");
Region reg = region(cls);
Pseudostate init = pseudoState(reg, "Init", PseudostateKind.INITIAL_LITERAL);
State s1 = state(reg, "S1");
SequenceNode entryBody = getActivityBody((Activity) s1.getEntry());
node(entryBody, 0, "Action.log(\"entry S1\");", SequenceNode.class);
SequenceNode exitBody = getActivityBody((Activity) s1.getExit());
node(exitBody, 0, "Action.log(\"exit S1\");", SequenceNode.class);
assertNotNull(s1.getEntry());
Transition tr1 = transition(reg, init, s1, null);
SequenceNode effectBody = getActivityBody((Activity) tr1.getEffect());
node(effectBody, 0, "Action.log(\"Init -> S1\");", SequenceNode.class);
Transition tr2 = transition(reg, s1, s1, sig);
Activity guardActivity = getGuardActivity(tr2);
node(guardActivity, 2, "return", ActivityParameterNode.class);
SequenceNode guardBody = getActivityBody(guardActivity);
node(guardBody, 0, "return false", SequenceNode.class);
}
示例15: testGeneralization
import org.eclipse.uml2.uml.Class; //导入依赖的package包/类
@Test
public void testGeneralization() throws Exception {
Model model = model("hu.elte.txtuml.export.uml2.tests.models.generalization");
Class abstractBase = cls(model, "AbstractBaseClass");
Operation baseMethod = operation(abstractBase, "baseMethod");
assertTrue(baseMethod.isAbstract());
Class concreteBase = cls(model, "ConcreteBaseClass");
checkSubclass(concreteBase, abstractBase);
Operation baseMethodInConcBase = operation(concreteBase, "baseMethod");
overrides(baseMethodInConcBase, baseMethod);
assertFalse(baseMethodInConcBase.isAbstract());
property(concreteBase, "baseField", "Integer");
Class concreteSub = cls(model, "ConcreteSubclass");
checkSubclass(concreteSub, concreteBase);
Operation baseMethodInConcSub = operation(concreteSub, "baseMethod");
Operation newMethod = operation(concreteSub, "newMethod");
Activity activity = (Activity) newMethod.getMethods().get(0);
SequenceNode actBody = (SequenceNode) activity.getNode("#body");
SequenceNode callStmt = (SequenceNode) actBody.getNode("this.baseMethod();");
CallOperationAction callExpr = (CallOperationAction) callStmt.getNode("this.baseMethod()");
assertEquals(baseMethodInConcSub, callExpr.getOperation());
}