public Collection getAssociatedClasses(Object handle) { try { Collection col = new ArrayList(); if (handle instanceof Classifier) { Classifier classifier = (Classifier) handle; Collection ends = getAssociationEnds(classifier); Iterator it = ends.iterator(); Set associations = new HashSet(); while (it.hasNext()) { AssociationEnd ae = (AssociationEnd) it.next(); associations.add(ae.getAssociation()); } Collection otherEnds = new ArrayList(); it = associations.iterator(); while (it.hasNext()) { otherEnds.addAll(((UmlAssociation) it.next()) .getConnection()); } otherEnds.removeAll(ends); it = otherEnds.iterator(); while (it.hasNext()) { col.add(((AssociationEnd) it.next()).getParticipant()); } return col; } } catch (InvalidObjectException e) { throw new InvalidElementException(e); } return illegalArgumentCollection(handle); }
public Collection<UmlAssociation> getAssociations(Object oclassifier) { Collection<UmlAssociation> result = new ArrayList<UmlAssociation>(); try { if (oclassifier instanceof Classifier) { for (Object end : Model.getFacade().getAssociationEnds( oclassifier)) { result.add(((AssociationEnd) end).getAssociation()); } } } catch (InvalidObjectException e) { throw new InvalidElementException(e); } return result; }
Clone fragments detected by clone detection tool
File path: /ArgoUML-0.34-src/argouml/src/argouml-core-model-mdr/src/org/argouml/model/mdr/FacadeMDRImpl.java File path: /ArgoUML-0.34-src/argouml/src/argouml-core-model-mdr/src/org/argouml/model/mdr/CoreHelperMDRImpl.java
Method name: Collection getAssociatedClasses(Object) Method name: Collection getAssociations(Object)
Number of AST nodes: 3 Number of AST nodes: 2
1
public Collection getAssociatedClasses(Object handle) {
1
public Collection<UmlAssociation> getAssociations(Object oclassifier) {
2
        try {
2
        Collection<UmlAssociation> result = new ArrayList<UmlAssociation>();
3
            Collection col = new ArrayList();
3
        try {
4
            if (handle instanceof Classifier) {
4
            if (oclassifier instanceof Classifier) {
5
                Classifier classifier = (Classifier) handle;
5
                for (Object end : Model.getFacade().getAssociationEnds(
6
                Collection ends = getAssociationEnds(classifier);
6
                        oclassifier)) {
7
                Iterator it = ends.iterator();
7
                    result.add(((AssociationEnd) end).getAssociation());
8
                Set associations = new HashSet();
8
                }
9
                while (it.hasNext()) {
9
            }
10
                    AssociationEnd ae = (AssociationEnd) it.next();
10
        } catch (InvalidObjectException e) {
11
                    associations.add(ae.getAssociation());
11
            throw new InvalidElementException(e);
12
                }
12
        }
13
                Collection otherEnds = new ArrayList();
13
        return result;
14
                it = associations.iterator();
14
    }
15
                while (it.hasNext()) {
16
                    otherEnds.addAll(((UmlAssociation) it.next())
17
                            .getConnection());
18
                }
19
                otherEnds.removeAll(ends);
20
                it = otherEnds.iterator();
21
                while (it.hasNext()) {
22
                    col.add(((AssociationEnd) it.next()).getParticipant());
23
                }
24
                return col;
25
            }
26
        } catch (InvalidObjectException e) {
27
            throw new InvalidElementException(e);
28
        }
29
        return illegalArgumentCollection(handle);
30
    }
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements3
    Number of unmapped statements in the first code fragment1
    Number of unmapped statements in the second code fragment1
    Time elapsed for statement mapping (ms)0.0
    Similarity Score0.500
    Clone typeType 3
    Mapped Statements
    ID Statement ID Statement
    8
    while (it.hasNext())
    8
    while (it.hasNext())
    4
    for (Object end : Model.getFacade().getAssociationEnds(oclassifier))
    Differences
    Expression1Expression2Difference
    endsModel.getFacade().getAssociationEnds(oclassifier)TYPE_COMPATIBLE_REPLACEMENT
    4
    for (Object end : Model.getFacade().getAssociationEnds(oclassifier))
                                                                                                                
    5
    result.add(((AssociationEnd)end).getAssociation());
    Preondition Violations
    Unmatched statement result.add(((AssociationEnd)end).getAssociation()); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    5
    result.add(((AssociationEnd)end).getAssociation());
    9
    AssociationEnd ae = (AssociationEnd)it.next();
                                                                                                  
    10
    associations.add(ae.getAssociation());
    10
    associations.add(ae.getAssociation());
    Preondition Violations
    Unmatched statement associations.add(ae.getAssociation()); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                                        
    Precondition Violations (3)
    Row Violation
    1Unmatched statement result.add(((AssociationEnd)end).getAssociation()); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    2Unmatched statement associations.add(ae.getAssociation()); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    3Clone fragment #1 returns variable ae with type org.omg.uml.foundation.core.AssociationEnd , while Clone fragment #2 returns variable end with type java.lang.Object