public boolean hasStereotype(Object handle, String name) { if (name == null || !(handle instanceof ModelElement)) { throw new IllegalArgumentException(); } try { ModelElement element = (ModelElement) handle; for (Stereotype stereotype : element.getStereotype()) { if (name.equals(stereotype.getName())) { return true; } } } catch (InvalidObjectException e) { throw new InvalidElementException(e); } return false; }
public boolean isStereotype(Object handle, String stereotypeName) { try { if (handle instanceof ModelElement) { Collection stereotypes = ((ModelElement) handle).getStereotype(); Iterator it = stereotypes.iterator(); Stereotype stereotype; while (it.hasNext()) { stereotype = (Stereotype) it.next(); if (stereotypeName.equals(stereotype.getName())) { return true; } } return false; } return illegalArgumentBoolean(handle); } catch (InvalidObjectException e) { throw new InvalidElementException(e); } }
Clone fragments detected by clone detection tool
File path: /ArgoUML-0.34-src/argouml/src/argouml-core-model-mdr/src/org/argouml/model/mdr/ExtensionMechanismsHelperMDRImpl.java File path: /ArgoUML-0.34-src/argouml/src/argouml-core-model-mdr/src/org/argouml/model/mdr/FacadeMDRImpl.java
Method name: boolean hasStereotype(Object, String) Method name: boolean isStereotype(Object, String)
Number of AST nodes: 3 Number of AST nodes: 4
1
public boolean hasStereotype(Object handle, String name) {
1
public boolean isStereotype(Object handle, String stereotypeName) {
2
        if (name == null || !(handle instanceof ModelElement)) {
2
        try {
3
            throw new IllegalArgumentException();
3
            if (handle instanceof ModelElement) {
4
        }
4
                Collection stereotypes =
5
        try {
5
                    ((ModelElement) handle).getStereotype();
6
            ModelElement element = (ModelElement) handle;
6
                Iterator it = stereotypes.iterator();
7
            for (Stereotype stereotype : element.getStereotype()) {
7
                Stereotype stereotype;
8
                if (name.equals(stereotype.getName())) {
8
                while (it.hasNext()) {
9
                    return true;
9
                    stereotype = (Stereotype) it.next();
10
                }
10
                    if (stereotypeName.equals(stereotype.getName())) {
11
            }
11
                        return true;
12
        } catch (InvalidObjectException e) {
12
                    }
13
            throw new InvalidElementException(e);
13
                }
14
        }
14
                return false;
15
        return false;
15
            }
16
    }
16
            return illegalArgumentBoolean(handle);
17
        } catch (InvalidObjectException e) {
18
            throw new InvalidElementException(e);
19
        }
20
    }
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements4
    Number of unmapped statements in the first code fragment0
    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
    5
    for (Stereotype stereotype : element.getStereotype())
    5
    for (Stereotype stereotype : element.getStereotype())
    6
    while (it.hasNext())
    Differences
    Expression1Expression2Difference
    java.util.Collectionjava.util.CollectionVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type java.util.Collection<org.omg.uml.foundation.core.Stereotype> of variable element.getStereotype() does not match with type java.util.Collection of variable stereotypes
    • Make classes java.util.Collection and java.util.Collection extend a common superclass
    6
    while (it.hasNext())
                                                                            
    7
    stereotype = (Stereotype)it.next();
    Preondition Violations
    Unmatched statement stereotype=(Stereotype)it.next(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    7
    stereotype = (Stereotype)it.next();
    6
    if (name.equals(stereotype.getName()))
    6
    if (name.equals(stereotype.getName()))
    8
    if (stereotypeName.equals(stereotype.getName()))
    Differences
    Expression1Expression2Difference
    namestereotypeNameVARIABLE_NAME_MISMATCH
    8
    if (stereotypeName.equals(stereotype.getName()))
    7
    return true;
    9
    return true;
    Precondition Violations (2)
    Row Violation
    1Type java.util.Collection<org.omg.uml.foundation.core.Stereotype> of variable element.getStereotype() does not match with type java.util.Collection of variable stereotypes
    2Unmatched statement stereotype=(Stereotype)it.next(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted