private static void addListenersForEvent(NotationProvider np, Object event) { if (event != null) { if (Model.getFacade().isAEvent(event)) { np.addElementListener(event, new String[] { "parameter", "name"}); } if (Model.getFacade().isATimeEvent(event)) { np.addElementListener(event, new String[] {"when"}); } if (Model.getFacade().isAChangeEvent(event)) { np.addElementListener(event, new String[] {"changeExpression"}); } /* And the parameter names and values: */ Collection prms = Model.getFacade().getParameters(event); Iterator i = prms.iterator(); while (i.hasNext()) { Object parameter = i.next(); np.addElementListener(parameter, new String[] {"defaultValue", "name", "type", "kind"}); } } }
@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"}); } } }
Clone fragments detected by clone detection tool
File path: /ArgoUML-0.34-src/argouml/src/argouml-app/src/org/argouml/notation/providers/NotationUtilityProviders.java File path: /ArgoUML-0.34-src/argouml/src/argouml-app/src/org/argouml/notation/providers/ObjectFlowStateStateNotation.java
Method name: void addListenersForEvent(NotationProvider, Object) Method name: void initialiseListener(Object)
Number of AST nodes: 3 Number of AST nodes: 2
1
private static void addListenersForEvent(NotationProvider np, 
1
@Override
2
            Object event) {
2
    public void initialiseListener(Object modelElement) {
3
        if (event != null) {
3
        addElementListener(modelElement);
4
            if (Model.getFacade().isAEvent(event)) {
4
        Object cis = Model.getFacade().getType(modelElement);
5
                np.addElementListener(event,
5
        if (Model.getFacade().isAClassifierInState(cis)) {
6
                        new String[] {
6
            addElementListener(cis,
7
                            "parameter", "name"});
7
                    new String[] {"remove", "inState"});
8
            }
8
            Collection<Object> c = Model.getFacade().getInStates(cis);
9
            if (Model.getFacade().isATimeEvent(event)) {
9
            for (Object state : c) {
10
                np.addElementListener(event, new String[] {"when"});
10
                addElementListener(state,
11
            }
11
                        new String[] {"remove", "name"});
12
            if (Model.getFacade().isAChangeEvent(event)) {
12
            }
13
                np.addElementListener(event,
13
        }
14
                        new String[] {"changeExpression"});
14
    }
15
            }
16
            /* And the parameter names and values: */
17
            Collection prms = Model.getFacade().getParameters(event);
18
            Iterator i = prms.iterator();
19
            while (i.hasNext()) {
20
                Object parameter = i.next();
21
                np.addElementListener(parameter, 
22
                      new String[] {"defaultValue", "name", "type", "kind"});
23
            }
24
        }
25
    }
  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 fragment0
    Time elapsed for statement mapping (ms)0.0
    Similarity Score0.750
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    10
    while (i.hasNext())
    10
    while (i.hasNext())
    6
    for (Object state : c)
    Differences
    Expression1Expression2Difference
    parameterstateVARIABLE_NAME_MISMATCH
    java.util.Collectionjava.util.CollectionVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type java.util.Collection of variable prms does not match with type java.util.Collection<java.lang.Object> of variable c
    • Make classes java.util.Collection and java.util.Collection extend a common superclass
    6
    for (Object state : c)
    11
    Object parameter = i.next();
    11
    Object parameter = i.next();
    Differences
    Expression1Expression2Difference
    parameterstateVARIABLE_NAME_MISMATCH
                                                                
    12
    np.addElementListener(parameter, new String[] {"defaultValue", "name", "type", "kind"});
    12
    np.addElementListener(parameter, new String[] {"defaultValue", "name", "type", "kind"});
    7
    addElementListener(state, new String[] {"remove", "name"});
    Differences
    Expression1Expression2Difference
    parameterstateVARIABLE_NAME_MISMATCH
    {"defaultValue","name","type","kind"}{"remove","name"}ARRAY_INITIALIZER_EXPRESSION_NUMBER_MISMATCH
    npMISSING_METHOD_INVOCATION_EXPRESSION
    Preondition Violations
    Expression addElementListener(state,new String[]{"remove","name"}) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression np.addElementListener(parameter,new String[]{"defaultValue","name","type","kind"}) is a void method call, and thus it cannot be parameterized
    Expression addElementListener(state,new String[]{"remove","name"}) is a void method call, and thus it cannot be parameterized
    7
    addElementListener(state, new String[] {"remove", "name"});
    Precondition Violations (4)
    Row Violation
    1Type java.util.Collection of variable prms does not match with type java.util.Collection<java.lang.Object> of variable c
    2Expression addElementListener(state,new String[]{"remove","name"}) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    3Expression np.addElementListener(parameter,new String[]{"defaultValue","name","type","kind"}) is a void method call, and thus it cannot be parameterized
    4Expression addElementListener(state,new String[]{"remove","name"}) is a void method call, and thus it cannot be parameterized