/** * Helper method that gets a stereotype for the given model * element with the given name. * * TODO: this might be a performance bottleneck. If so, caching of * stereotypes for model elements by their stereotypes names could fix it. * * @param modelElement The model element for which to look for the * stereotype with the given name * @param stereotypeName The name of the stereotype. * @return the stereotype model element or null if not found. */ private Object getStereotype(Object modelElement, String stereotypeName) { Object stereotype = null; Collection stereotypes = StereotypeUtility.getAvailableStereotypes( modelElement); for (Iterator it = stereotypes.iterator(); it.hasNext();) { Object candidateStereotype = it.next(); if (getFacade().getName(candidateStereotype).equals( stereotypeName)) { stereotype = candidateStereotype; break; } } return stereotype; }
private Object getStereotype(Object aModel, String stereotypeName) { Collection stereotypes = getExtensionMechanismsHelper().getStereotypes( aModel); for (Object stereotype : stereotypes) { if (stereotypeName.equals(getFacade().getName(stereotype))) { return stereotype; } } return null; }
Clone fragments detected by clone detection tool
File path: /ArgoUML-0.34-src/argouml-cpp/src/org/argouml/language/cpp/reveng/XtorModeler.java File path: /ArgoUML-0.34-src/argouml-cpp/src/org/argouml/language/cpp/profile/BaseProfile.java
Method name: Object getStereotype(Object, String) Method name: Object getStereotype(Object, String)
Number of AST nodes: 5 Number of AST nodes: 3
1
/**
1
private Object getStereotype(Object aModel, String stereotypeName) {
2
     * Helper method that gets a stereotype for the given model
2
        Collection stereotypes = getExtensionMechanismsHelper().getStereotypes(
3
     * element with the given name.
3
                aModel);
4
     *
4
        for (Object stereotype : stereotypes) {
5
     * TODO: this might be a performance bottleneck. If so, caching of
5
            if (stereotypeName.equals(getFacade().getName(stereotype))) {
6
     * stereotypes for model elements by their stereotypes names could fix it.
6
                return stereotype;
7
     *
7
            }
8
     * @param modelElement The model element for which to look for the
8
        }
9
     *            stereotype with the given name
9
        return null;
10
     * @param stereotypeName The name of the stereotype.
10
    }
11
     * @return the stereotype model element or null if not found.
12
     */
13
    private Object getStereotype(Object modelElement, String stereotypeName) {
14
        Object stereotype = null;
15
        Collection stereotypes = StereotypeUtility.getAvailableStereotypes(
16
                modelElement);
17
        for (Iterator it = stereotypes.iterator(); it.hasNext();) {
18
            Object candidateStereotype = it.next();
19
            if (getFacade().getName(candidateStereotype).equals(
20
                stereotypeName)) {
21
                stereotype = candidateStereotype;
22
                break;
23
            }
24
        }
25
        return stereotype;
26
    }
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements3
    Number of unmapped statements in the first code fragment2
    Number of unmapped statements in the second code fragment1
    Time elapsed for statement mapping (ms)0.0
    Similarity Score1.000
    Clone typeType 3
    Mapped Statements
    ID Statement ID Statement
    3
    for (Iterator it = stereotypes.iterator(); it.hasNext(); )
    3
    for (Iterator it = stereotypes.iterator(); it.hasNext(); )
    2
    for (Object stereotype : stereotypes)
    Differences
    Expression1Expression2Difference
    candidateStereotypestereotypeVARIABLE_NAME_MISMATCH
    2
    for (Object stereotype : stereotypes)
    4
    Object candidateStereotype = it.next();
    4
    Object candidateStereotype = it.next();
    Differences
    Expression1Expression2Difference
    candidateStereotypestereotypeVARIABLE_NAME_MISMATCH
                                                                                    
    5
    if (getFacade().getName(candidateStereotype).equals(stereotypeName))
    5
    if (getFacade().getName(candidateStereotype).equals(stereotypeName))
    3
    if (stereotypeName.equals(getFacade().getName(stereotype)))
    Differences
    Expression1Expression2Difference
    stereotypeNamegetFacade().getName(stereotype)TYPE_COMPATIBLE_REPLACEMENT
    getFacade().getName(candidateStereotype)stereotypeNameTYPE_COMPATIBLE_REPLACEMENT
    Preondition Violations
    Expression getFacade().getName(stereotype) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    3
    if (stereotypeName.equals(getFacade().getName(stereotype)))
                                              
    4
    return stereotype;
    Preondition Violations
    Unmatched statement return stereotype; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    Unmatched return stereotype;
    4
    return stereotype;
    6
    stereotype = candidateStereotype;
    6
    stereotype = candidateStereotype;
    Preondition Violations
    Unmatched statement stereotype=candidateStereotype; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                        
    7
    break;
    7
    break;
    Preondition Violations
    Unmatched break;
                      
    Precondition Violations (5)
    Row Violation
    1Expression getFacade().getName(stereotype) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    2Unmatched statement return stereotype; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    3Unmatched return stereotype;
    4Unmatched statement stereotype=candidateStereotype; cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    5Unmatched break;