@Override public void initialiseListener(Object modelElement) { addElementListener(modelElement); Object cis = Model.getFacade().getType(modelElement); if (Model.getFacade().isAClassifierInState(cis)) { addElementListener(cis, new String[] {"remove", "inState"}); Collection<Object> c = Model.getFacade().getInStates(cis); for (Object state : c) { addElementListener(state, new String[] {"remove", "name"}); } } }
@Override protected void updateListeners(Object oldOwner, Object newOwner) { super.updateListeners(oldOwner, newOwner); if (newOwner != null) { Collection c = Model.getFacade().getStereotypes(newOwner); Iterator i = c.iterator(); while (i.hasNext()) { Object st = i.next(); addElementListener(st, "name"); } } }
Clone fragments detected by clone detection tool
File path: /ArgoUML-0.34-src/argouml/src/argouml-app/src/org/argouml/notation/providers/ObjectFlowStateStateNotation.java File path: /ArgoUML-0.34-src/argouml/src/argouml-app/src/org/argouml/uml/diagram/deployment/ui/AbstractFigComponent.java
Method name: void initialiseListener(Object) Method name: void updateListeners(Object, Object)
Number of AST nodes: 2 Number of AST nodes: 3
1
@Override
1
@Override
2
    public void initialiseListener(Object modelElement) {
2
    protected void updateListeners(Object oldOwner, Object newOwner) {
3
        addElementListener(modelElement);
3
        super.updateListeners(oldOwner, newOwner);
4
        Object cis = Model.getFacade().getType(modelElement);
4
        if (newOwner != null) {
5
        if (Model.getFacade().isAClassifierInState(cis)) {
5
            Collection c = Model.getFacade().getStereotypes(newOwner);
6
            addElementListener(cis,
6
            Iterator i = c.iterator();
7
                    new String[] {"remove", "inState"});
7
            while (i.hasNext()) {
8
            Collection<Object> c = Model.getFacade().getInStates(cis);
8
                Object st = i.next();
9
            for (Object state : c) {
9
                addElementListener(st, "name");
10
                addElementListener(state,
10
            }
11
                        new String[] {"remove", "name"});
11
        }
12
            }
12
    }
13
        }
14
    }
  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
    6
    for (Object state : c)
    6
    for (Object state : c)
    5
    while (i.hasNext())
    Differences
    Expression1Expression2Difference
    statestVARIABLE_NAME_MISMATCH
    java.util.Collectionjava.util.CollectionVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type java.util.Collection<java.lang.Object> of variable c does not match with type java.util.Collection of variable c
    • Make classes java.util.Collection and java.util.Collection extend a common superclass
    5
    while (i.hasNext())
                                                
    6
    Object st = i.next();
    Differences
    Expression1Expression2Difference
    statestVARIABLE_NAME_MISMATCH
    6
    Object st = i.next();
                                                                      
    7
    addElementListener(st, "name");
    Preondition Violations
    Unmatched statement addElementListener(st,"name"); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    7
    addElementListener(st, "name");
    7
    addElementListener(state, new String[] {"remove", "name"});
    7
    addElementListener(state, new String[] {"remove", "name"});
    Preondition Violations
    Unmatched statement addElementListener(state,new String[]{"remove","name"}); 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
    1Type java.util.Collection<java.lang.Object> of variable c does not match with type java.util.Collection of variable c
    2Unmatched statement addElementListener(st,"name"); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    3Unmatched statement addElementListener(state,new String[]{"remove","name"}); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted