private Object getDefaultType(String typeName) { for (Object model : profileModels) { Collection dataTypes = Model.getCoreHelper().getAllDataTypes(model); for (Object dataType : dataTypes) { if (typeName.equals(Model.getFacade().getName(dataType))) { return dataType; } } } return null; }
/** * 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; }
Clone fragments detected by clone detection tool
File path: /ArgoUML-0.34-src/argouml-cpp/src/org/argouml/language/cpp/profile/DefaultTypeStrategyCpp.java File path: /ArgoUML-0.34-src/argouml-cpp/src/org/argouml/language/cpp/reveng/ModelerImpl.java
Method name: Object getDefaultType(String) Method name: Object findClass(String, Object)
Number of AST nodes: 3 Number of AST nodes: 4
1
private Object getDefaultType(String typeName) {
1
/**
2
        for (Object model : profileModels) {
2
     * Find a class within the given namespace that has the given identifier.
3
            Collection dataTypes = Model.getCoreHelper().getAllDataTypes(model);
3
     *
4
            for (Object dataType : dataTypes) {
4
     * @param identifier the class identifier
5
                if (typeName.equals(Model.getFacade().getName(dataType))) {
5
     * @param ns namespace to look in
6
                    return dataType;
6
     * @return the class if found, null otherwise
7
                }
7
     */
8
            }
8
    private static Object findClass(String identifier, Object ns) {
9
        }
9
        Collection classes = getCoreHelper().getAllClasses(ns);
10
        return null;
10
        Iterator it = classes.iterator();
11
    }
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 Score1.000
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    3
    for (Object dataType : dataTypes)
    3
    for (Object dataType : dataTypes)
    3
    while (it.hasNext())
    Differences
    Expression1Expression2Difference
    dataTypecandidateClassVARIABLE_NAME_MISMATCH
    3
    while (it.hasNext())
                                                                          
    4
    Object candidateClass = it.next();
    Differences
    Expression1Expression2Difference
    dataTypecandidateClassVARIABLE_NAME_MISMATCH
    4
    Object candidateClass = it.next();
    4
    if (typeName.equals(Model.getFacade().getName(dataType)))
    4
    if (typeName.equals(Model.getFacade().getName(dataType)))
    5
    if (Model.getFacade().getName(candidateClass).equals(identifier))
    Differences
    Expression1Expression2Difference
    Model.getFacade().getName(dataType)identifierTYPE_COMPATIBLE_REPLACEMENT
    typeNameModel.getFacade().getName(candidateClass)TYPE_COMPATIBLE_REPLACEMENT
    Preondition Violations
    Expression Model.getFacade().getName(dataType) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    5
    if (Model.getFacade().getName(candidateClass).equals(identifier))
    5
    return dataType;
    5
    return dataType;
    6
    return candidateClass;
    Differences
    Expression1Expression2Difference
    dataTypecandidateClassVARIABLE_NAME_MISMATCH
    6
    return candidateClass;
    Precondition Violations (1)
    Row Violation
    1Expression Model.getFacade().getName(dataType) cannot be parameterized, because it has dependencies to/from statements that will be extracted