/** * Find a class within the given namespace that has the given identifier. * * @param identifier the class identifier * @param ns namespace to look in * @return the class if found, null otherwise */ private static Object findClass(String identifier, Object ns) { Collection classes = getCoreHelper().getAllClasses(ns); Iterator it = classes.iterator(); while (it.hasNext()) { Object candidateClass = it.next(); if (Model.getFacade().getName(candidateClass).equals(identifier)) { return candidateClass; } } return null; }
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/ModelerImpl.java File path: /ArgoUML-0.34-src/argouml-cpp/src/org/argouml/language/cpp/profile/BaseProfile.java
Method name: Object findClass(String, Object) Method name: Object getStereotype(Object, String)
Number of AST nodes: 4 Number of AST nodes: 3
1
/**
1
private Object getStereotype(Object aModel, String stereotypeName) {
2
     * Find a class within the given namespace that has the given identifier.
2
        Collection stereotypes = getExtensionMechanismsHelper().getStereotypes(
3
     *
3
                aModel);
4
     * @param identifier the class identifier
4
        for (Object stereotype : stereotypes) {
5
     * @param ns namespace to look in
5
            if (stereotypeName.equals(getFacade().getName(stereotype))) {
6
     * @return the class if found, null otherwise
6
                return stereotype;
7
     */
7
            }
8
    private static Object findClass(String identifier, Object ns) {
8
        }
9
        Collection classes = getCoreHelper().getAllClasses(ns);
9
        return null;
10
        Iterator it = classes.iterator();
10
    }
11
        while (it.hasNext()) {
12
            Object candidateClass = it.next();
13
            if (Model.getFacade().getName(candidateClass).equals(identifier)) {
14
                return candidateClass;
15
            }
16
        }
17
        return null;
18
    }
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements5
    Number of unmapped statements in the first code fragment0
    Number of unmapped statements in the second code fragment0
    Time elapsed for statement mapping (ms)0.0
    Similarity Score0.833
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    3
    while (it.hasNext())
    3
    while (it.hasNext())
    2
    for (Object stereotype : stereotypes)
    Differences
    Expression1Expression2Difference
    candidateClassstereotypeVARIABLE_NAME_MISMATCH
    2
    for (Object stereotype : stereotypes)
    4
    Object candidateClass = it.next();
    4
    Object candidateClass = it.next();
    Differences
    Expression1Expression2Difference
    candidateClassstereotypeVARIABLE_NAME_MISMATCH
                                                                          
    5
    if (Model.getFacade().getName(candidateClass).equals(identifier))
    5
    if (Model.getFacade().getName(candidateClass).equals(identifier))
    3
    if (stereotypeName.equals(getFacade().getName(stereotype)))
    Differences
    Expression1Expression2Difference
    identifiergetFacade().getName(stereotype)TYPE_COMPATIBLE_REPLACEMENT
    Model.getFacade().getName(candidateClass)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)))
    6
    return candidateClass;
    6
    return candidateClass;
    4
    return stereotype;
    Differences
    Expression1Expression2Difference
    candidateClassstereotypeVARIABLE_NAME_MISMATCH
    4
    return stereotype;
    Precondition Violations (1)
    Row Violation
    1Expression getFacade().getName(stereotype) cannot be parameterized, because it has dependencies to/from statements that will be extracted