/** * Validate every association for the given relation. * * @param relation */ private void validateAssociations(Object relation) { Collection associationEnds = Model.getFacade().getAssociationEnds( relation); Iterator it = associationEnds.iterator(); while (it.hasNext()) { Object relationAssocEnd = it.next(); Object association = Model.getFacade().getAssociation( relationAssocEnd); validateAssociation(association); } }
public List getInEdges(Object port) { List res = new ArrayList(); if (Model.getFacade().isANode(port)) { Collection ends = Model.getFacade().getAssociationEnds(port); if (ends == null) { return Collections.EMPTY_LIST; } for (Object end : ends) { res.add(Model.getFacade().getAssociation(end)); } } if (Model.getFacade().isANodeInstance(port)) { Object noi = port; Collection ends = Model.getFacade().getLinkEnds(noi); res.addAll(ends); } if (Model.getFacade().isAComponent(port)) { Collection ends = Model.getFacade().getAssociationEnds(port); if (ends == null) { return Collections.EMPTY_LIST; } for (Object end : ends) { res.add(Model.getFacade().getAssociation(end)); } } if (Model.getFacade().isAComponentInstance(port)) { Object coi = port; Collection ends = Model.getFacade().getLinkEnds(coi); res.addAll(ends); } if (Model.getFacade().isAClass(port)) { Collection ends = Model.getFacade().getAssociationEnds(port); if (ends == null) { return Collections.EMPTY_LIST; } for (Object end : ends) { res.add(Model.getFacade().getAssociation(end)); } } if (Model.getFacade().isAInterface(port)) { Collection ends = Model.getFacade().getAssociationEnds(port); if (ends == null) { return Collections.EMPTY_LIST; } for (Object end : ends) { res.add(Model.getFacade().getAssociation(end)); } } if (Model.getFacade().isAObject(port)) { Object clo = port; Collection ends = Model.getFacade().getLinkEnds(clo); res.addAll(ends); } return res; }
Clone fragments detected by clone detection tool
File path: /ArgoUML-0.34-src/argouml-sql/src/org/argouml/language/sql/ModelValidator.java File path: /ArgoUML-0.34-src/argouml/src/argouml-app/src/org/argouml/uml/diagram/deployment/DeploymentDiagramGraphModel.java
Method name: void validateAssociations(Object) Method name: List getInEdges(Object)
Number of AST nodes: 4 Number of AST nodes: 2
1
/**
1
public List getInEdges(Object port) {
2
     * Validate every association for the given relation.
2
        List res = new ArrayList();
3
     * 
3
        if (Model.getFacade().isANode(port)) {
4
     * @param relation
4
            Collection ends = Model.getFacade().getAssociationEnds(port);
5
     */
5
            if (ends == null) {
6
    private void validateAssociations(Object relation) {
6
                return Collections.EMPTY_LIST;
7
        Collection associationEnds = Model.getFacade().getAssociationEnds(
7
            }
8
                relation);
8
            for (Object end : ends) {
9
        Iterator it = associationEnds.iterator();
9
                res.add(Model.getFacade().getAssociation(end));
10
        while (it.hasNext()) {
10
            }
11
            Object relationAssocEnd = it.next();
11
        }
12
            Object association = Model.getFacade().getAssociation(
12
        if (Model.getFacade().isANodeInstance(port)) {
13
                    relationAssocEnd);
13
            Object noi = port;
14
            validateAssociation(association);
14
            Collection ends = Model.getFacade().getLinkEnds(noi);
15
        }
15
            res.addAll(ends);
16
    }
16
        }
17
        if (Model.getFacade().isAComponent(port)) {
18
            Collection ends = Model.getFacade().getAssociationEnds(port);
19
            if (ends == null) {
20
                return Collections.EMPTY_LIST;
21
            }
22
            for (Object end : ends) {
23
                res.add(Model.getFacade().getAssociation(end));
24
            }
25
        }
26
        if (Model.getFacade().isAComponentInstance(port)) {
27
            Object coi = port;
28
            Collection ends = Model.getFacade().getLinkEnds(coi);
29
            res.addAll(ends);
30
        }
31
        if (Model.getFacade().isAClass(port)) {
32
            Collection ends = Model.getFacade().getAssociationEnds(port);
33
            if (ends == null) {
34
                return Collections.EMPTY_LIST;
35
            }
36
            for (Object end : ends) {
37
                res.add(Model.getFacade().getAssociation(end));
38
            }
39
        }
40
        if (Model.getFacade().isAInterface(port)) {
41
            Collection ends = Model.getFacade().getAssociationEnds(port);
42
            if (ends == null) {
43
                return Collections.EMPTY_LIST;
44
            }
45
            for (Object end : ends) {
46
                res.add(Model.getFacade().getAssociation(end));
47
            }
48
        }
49
        if (Model.getFacade().isAObject(port)) {
50
            Object clo = port;
51
            Collection ends = Model.getFacade().getLinkEnds(clo);
52
            res.addAll(ends);
53
        }
54
55
56
        return res;
57
    }
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements3
    Number of unmapped statements in the first code fragment2
    Number of unmapped statements in the second code fragment1
    Time elapsed for statement mapping (ms)0.0
    Similarity Score0.571
    Clone typeType 3
    Mapped Statements
    ID Statement ID Statement
    3
    while (it.hasNext())
    3
    while (it.hasNext())
    6
    for (Object end : ends)
    Differences
    Expression1Expression2Difference
    relationAssocEndendVARIABLE_NAME_MISMATCH
    6
    for (Object end : ends)
    4
    Object relationAssocEnd = it.next();
    4
    Object relationAssocEnd = it.next();
    Differences
    Expression1Expression2Difference
    relationAssocEndendVARIABLE_NAME_MISMATCH
                                                                              
    5
    Object association = Model.getFacade().getAssociation(relationAssocEnd);
    5
    Object association = Model.getFacade().getAssociation(relationAssocEnd);
    Preondition Violations
    Unmatched statement Object association=Model.getFacade().getAssociation(relationAssocEnd); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                                                                                                      
    6
    validateAssociation(association);
                                                                            
                                                                                                        
    7
    res.add(Model.getFacade().getAssociation(end));
    Preondition Violations
    Unmatched statement res.add(Model.getFacade().getAssociation(end)); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    7
    res.add(Model.getFacade().getAssociation(end));
    Precondition Violations (2)
    Row Violation
    1Unmatched statement Object association=Model.getFacade().getAssociation(relationAssocEnd); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    2Unmatched statement res.add(Model.getFacade().getAssociation(end)); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted