public AssociationEnd getAssociationEnd(Object type, Object assoc) { if (!(type instanceof Classifier)) { throw new IllegalArgumentException(); } if (!(assoc instanceof UmlAssociation)) { throw new IllegalArgumentException(); } try { for (AssociationEnd end : (Collection<AssociationEnd>) Model .getFacade().getAssociationEnds(type)) { if (((UmlAssociation) assoc).getConnection().contains(end)) { return end; } } } catch (InvalidObjectException e) { throw new InvalidElementException(e); } return null; }
public Object getAssociationEnd(Object handle, Object assoc) { try { if (handle instanceof Classifier && assoc instanceof UmlAssociation) { Classifier classifier = (Classifier) handle; Iterator it = getAssociationEnds(classifier).iterator(); while (it.hasNext()) { AssociationEnd end = (AssociationEnd) it.next(); if (((UmlAssociation) assoc).getConnection() .contains(end)) { return end; } } return null; } throw new IllegalArgumentException("handle: " + handle + ",assoc: " + assoc); } 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/CoreHelperMDRImpl.java File path: /ArgoUML-0.34-src/argouml/src/argouml-core-model-mdr/src/org/argouml/model/mdr/FacadeMDRImpl.java
Method name: AssociationEnd getAssociationEnd(Object, Object) Method name: Object getAssociationEnd(Object, Object)
Number of AST nodes: 3 Number of AST nodes: 4
1
public AssociationEnd getAssociationEnd(Object type, Object assoc) {
1
public Object getAssociationEnd(Object handle, Object assoc) {
2
        if (!(type instanceof Classifier)) {
2
        try {
3
            throw new IllegalArgumentException();
3
            if (handle instanceof Classifier 
4
        }
4
                    && assoc instanceof UmlAssociation) {
5
        if (!(assoc instanceof UmlAssociation)) {
5
                Classifier classifier = (Classifier) handle;
6
            throw new IllegalArgumentException();
6
                Iterator it = getAssociationEnds(classifier).iterator();
7
        }
7
                while (it.hasNext()) {
8
        try {
8
                    AssociationEnd end = (AssociationEnd) it.next();
9
            for (AssociationEnd end : (Collection<AssociationEnd>) Model
9
                    if (((UmlAssociation) assoc).getConnection()
10
                    .getFacade().getAssociationEnds(type)) {
10
                            .contains(end)) {
11
                if (((UmlAssociation) assoc).getConnection().contains(end)) {
11
                        return end;
12
                    return end;
12
                    }
13
                }
13
                }
14
            }
14
                return null;
15
        } catch (InvalidObjectException e) {
15
            }
16
            throw new InvalidElementException(e);
16
            throw new IllegalArgumentException("handle: " + handle + ",assoc: "
17
        }
17
                    + assoc);
18
        return null;
18
        } catch (InvalidObjectException e) {
19
    }
19
            throw new InvalidElementException(e);
20
        }
21
    }
  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
    6
    for (AssociationEnd end : (Collection<AssociationEnd>)Model.getFacade().getAssociationEnds(type))
    6
    for (AssociationEnd end : (Collection<AssociationEnd>)Model.getFacade().getAssociationEnds(type))
    5
    while (it.hasNext())
    Differences
    Expression1Expression2Difference
    java.util.Collectionjava.util.CollectionVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type java.util.Collection<org.omg.uml.foundation.core.AssociationEnd> of variable (Collection<AssociationEnd>)Model.getFacade().getAssociationEnds(type) does not match with type java.util.Collection of variable getAssociationEnds(classifier)
    • Make classes java.util.Collection and java.util.Collection extend a common superclass
    5
    while (it.hasNext())
                                                                                                    
    6
    AssociationEnd end = (AssociationEnd)it.next();
    7
    if (((UmlAssociation)assoc).getConnection().contains(end))
    7
    if (((UmlAssociation)assoc).getConnection().contains(end))
    8
    return end;
    8
    return end;
    Precondition Violations (1)
    Row Violation
    1Type java.util.Collection<org.omg.uml.foundation.core.AssociationEnd> of variable (Collection<AssociationEnd>)Model.getFacade().getAssociationEnds(type) does not match with type java.util.Collection of variable getAssociationEnds(classifier)