Java Code Examples for org.eclipse.uml2.uml.Classifier#getOperations()

The following examples show how to use org.eclipse.uml2.uml.Classifier#getOperations() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ClassNode.java    From txtUML with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Creates a ClassNode based on the EMF-UML model-element and layout
 * information provided
 * 
 * 
 * @param clazz
 *            the EMF-UML model-element which holds informations of this
 *            diagram element
 * @param id
 *            the layout id of this element
 */
public ClassNode(Classifier clazz, String id) {
	/*
	 * position = layout.getPosition(); width = layout.getWidth(); height =
	 * layout.getHeight(); id = layout.getName();
	 */
	this.id = id;
	name = clazz.getName();
	attributes = new ArrayList<Attribute>();
	// creating attributes
	for (Property attr : clazz.getAttributes()) {
		if (attr.getAssociation() == null) {
			attributes.add(new Attribute(attr));
		}
	}

	operations = new ArrayList<MemberOperation>();
	// creating operations
	for (Operation op : clazz.getOperations()) {
		operations.add(new MemberOperation(op));
	}

	if (clazz.isAbstract()) {
		type = CDNodeType.ABSTRACT_CLASS;
	} else {
		type = CDNodeType.CLASS;
	}
}
 
Example 2
Source File: Repository.java    From textuml with Eclipse Public License 1.0 5 votes vote down vote up
public Operation getEntryPointOperation(Package package_) {
    for (NamedElement element : package_.getOwnedMembers()) {
        if (!(element instanceof Classifier))
            continue;
        Classifier classifier = (Classifier) element;
        for (Operation operation : classifier.getOperations())
            if (MDDExtensionUtils.isEntryPoint(operation))
                return operation;
    }
    return null;
}
 
Example 3
Source File: FeatureUtils.java    From textuml with Eclipse Public License 1.0 5 votes vote down vote up
public static List<? extends BehavioralFeature> getBehavioralFeatures(Classifier classifier) {
    if (!(classifier instanceof Interface) && !(classifier instanceof Class))
        return classifier.getOperations();
    List<BehavioralFeature> combined = new ArrayList<>(classifier.getOperations());
    EList<Reception> receptions = (classifier instanceof Interface) ? ((Interface) classifier).getOwnedReceptions()
            : ((Class) classifier).getOwnedReceptions();
    combined.addAll(receptions);
    return combined;
}
 
Example 4
Source File: FeatureUtils.java    From textuml with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * Finds an operation in the given classifier.
 * 
 * @param arguments
 *            the arguments to match, or null for name-based matching only
 */
public static Operation findOperation(IRepository repository, Classifier classifier, String operationName,
        List<TypedElement> arguments, ParameterSubstitutionMap substitutions, boolean ignoreCase, boolean recurse) {
    for (Operation operation : classifier.getOperations()) {
        if (isNameMatch(operation, operationName, ignoreCase)
                && (isMatch(repository, operation, arguments, substitutions)))
            return operation;
    }
    if (!recurse)
        return null;
    Operation found;
    final EList<TemplateBinding> templateBindings = classifier.getTemplateBindings();
    if (!templateBindings.isEmpty())
        for (TemplateBinding templateBinding : templateBindings) {
            TemplateSignature signature = templateBinding.getSignature();
            ParameterSubstitutionMap newSubstitutions = new ParameterSubstitutionMap(templateBinding);
            found = findOperation(repository, (Classifier) signature.getTemplate(), operationName, arguments,
                    newSubstitutions, ignoreCase, true);
            if (found != null)
                return found;
        }
    for (Generalization generalization : classifier.getGeneralizations())
        if ((found = findOperation(repository, generalization.getGeneral(), operationName, arguments,
                substitutions, ignoreCase, true)) != null)
            return found;
    // recurse to owning classifier
    for (Namespace owner = (Namespace) classifier.getOwner(); owner instanceof Classifier; owner = (Namespace) owner
            .getOwner())
        if ((found = findOperation(repository, (Classifier) owner, operationName, arguments, substitutions,
                ignoreCase, true)) != null)
            return found;
    // fallback to interfaces realized
    if (classifier instanceof BehavioredClassifier) {
        BehavioredClassifier asBehaviored = (BehavioredClassifier) classifier;
        for (Interface implemented : asBehaviored.getImplementedInterfaces())
            if ((found = findOperation(repository, implemented, operationName, arguments, substitutions,
                    ignoreCase, true)) != null)
                return found;
    }

    return null;
}