protected void setTarget(Object target) { assert (getTarget() == null); assert (Model.getFacade().isAElement(target)); setListTarget(target); Collection bases = Model.getFacade().getBases(getTarget()); Iterator it = bases.iterator(); while (it.hasNext()) { Object base = it.next(); Model.getPump().addModelEventListener( this, base, "feature"); } // make sure we know it when a classifier is added as a base Model.getPump().addModelEventListener( this, getTarget(), "base"); removeAllElements(); setBuildingModel(true); buildModelList(); setBuildingModel(false); if (getSize() > 0) { fireIntervalAdded(this, 0, getSize() - 1); } }
@Override protected void removeOtherModelEventListeners(Object oldTarget) { super.removeOtherModelEventListeners(oldTarget); for (Object classifier : others) { Model.getPump().removeModelEventListener(this, classifier, "feature"); } others.clear(); }
Clone fragments detected by clone detection tool
File path: /ArgoUML-0.34-src/argouml/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/UMLClassifierRoleAvailableFeaturesListModel.java File path: /ArgoUML-0.34-src/argouml/src/argouml-core-umlpropertypanels/src/org/argouml/core/propertypanels/ui/UMLAssociationRoleBaseComboBoxModel.java
Method name: void setTarget(Object) Method name: void removeOtherModelEventListeners(Object)
Number of AST nodes: 3 Number of AST nodes: 2
1
protected void setTarget(Object target) {
1
@Override
2
        assert (getTarget() == null);
2
    protected void removeOtherModelEventListeners(Object oldTarget) {
3
        assert (Model.getFacade().isAElement(target));
3
        super.removeOtherModelEventListeners(oldTarget);
4
        
4
        for (Object classifier : others) {
5
        
5
            Model.getPump().removeModelEventListener(this, 
6
        setListTarget(target);
6
                    classifier, "feature");
7
        
7
        }
8
        Collection bases = Model.getFacade().getBases(getTarget());
8
        others.clear();
9
        Iterator it = bases.iterator();
9
    }
10
        while (it.hasNext()) {
11
            Object base = it.next();
12
            Model.getPump().addModelEventListener(
13
                this,
14
                base,
15
                "feature");
16
        }
17
        // make sure we know it when a classifier is added as a base
18
        Model.getPump().addModelEventListener(
19
            this,
20
            getTarget(),
21
            "base");
22
        removeAllElements();
23
        setBuildingModel(true);
24
        buildModelList();
25
        setBuildingModel(false);
26
        if (getSize() > 0) {
27
            fireIntervalAdded(this, 0, getSize() - 1);
28
        }
29
    }
  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.667
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    6
    while (it.hasNext())
    6
    while (it.hasNext())
    2
    for (Object classifier : others)
    Differences
    Expression1Expression2Difference
    baseclassifierVARIABLE_NAME_MISMATCH
    basesothersVARIABLE_NAME_MISMATCH
    2
    for (Object classifier : others)
    7
    Object base = it.next();
    7
    Object base = it.next();
    Differences
    Expression1Expression2Difference
    baseclassifierVARIABLE_NAME_MISMATCH
                                                      
    8
    Model.getPump().addModelEventListener(this, base, "feature");
    8
    Model.getPump().addModelEventListener(this, base, "feature");
    3
    Model.getPump().removeModelEventListener(this, classifier, "feature");
    Differences
    Expression1Expression2Difference
    addModelEventListenerremoveModelEventListenerMETHOD_INVOCATION_NAME_MISMATCH
    baseclassifierVARIABLE_NAME_MISMATCH
    Preondition Violations
    Expression Model.getPump().removeModelEventListener(this,classifier,"feature") cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression Model.getPump().addModelEventListener(this,base,"feature") is a void method call, and thus it cannot be parameterized
    Expression Model.getPump().removeModelEventListener(this,classifier,"feature") is a void method call, and thus it cannot be parameterized
    3
    Model.getPump().removeModelEventListener(this, classifier, "feature");
    Precondition Violations (3)
    Row Violation
    1Expression Model.getPump().removeModelEventListener(this,classifier,"feature") cannot be parameterized, because it has dependencies to/from statements that will be extracted
    2Expression Model.getPump().addModelEventListener(this,base,"feature") is a void method call, and thus it cannot be parameterized
    3Expression Model.getPump().removeModelEventListener(this,classifier,"feature") is a void method call, and thus it cannot be parameterized