Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 486d8ac81abd6891e47a5db5d5b82fb1520f4eb3 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/*****************************************************************************
 * Copyright (c) 2014, 2015 Christian W. Damus and others.
 * 
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *   Christian W. Damus - Initial API and implementation
 *   
 *****************************************************************************/
package org.eclipse.papyrus.uml.profile.elementtypesconfigurations.generator

import javax.inject.Inject
import javax.inject.Singleton
import org.eclipse.papyrus.infra.elementtypesconfigurations.ElementTypeConfiguration
import org.eclipse.papyrus.uml.elementtypesconfigurations.applystereotypeadviceconfiguration.ApplyStereotypeAdviceConfiguration
import org.eclipse.papyrus.uml.elementtypesconfigurations.applystereotypeadviceconfiguration.ApplyStereotypeAdviceConfigurationFactory
import org.eclipse.uml2.uml.Stereotype

/**
 * Transformation rule for generating an {@link ApplyStereotypeAdviceConfiguration} from a UML {@link Stereotype}.
 */
@Singleton
class ApplyStereotypeAdviceRule {
    static extension ApplyStereotypeAdviceConfigurationFactory applyStereotypeAdviceConfigurationFactory = ApplyStereotypeAdviceConfigurationFactory.
        eINSTANCE

    @Inject extension ElementTypeRule
    @Inject extension Identifiers

    def create createApplyStereotypeAdviceConfiguration toAdviceConfiguration(Stereotype umlStereotype,
        ImpliedExtension umlExtension, ElementTypeConfiguration supertype) {

        identifier = umlStereotype.name.toFirstLower.qualified + supertype.hintSuffix
        stereotypesToApply.add(umlStereotype.toStereotypeToApply(supertype))
        target = umlExtension.toElementType(supertype)
    }

    private def create createStereotypeToApply toStereotypeToApply(Stereotype umlStereotype, ElementTypeConfiguration supertype) {
        requiredProfiles.add(umlStereotype.profile.qualifiedName)
        stereotypeQualifiedName = umlStereotype.qualifiedName
        updateName = true
    }
}

Back to the top