public List<BehavioralFeature> getBehavioralFeatures(Object clazz) { if (clazz instanceof Classifier) { List<BehavioralFeature> ret = new ArrayList<BehavioralFeature>(); try { for (Object o : modelImpl.getFacade().getFeatures(clazz)) { if (o instanceof BehavioralFeature) { ret.add((BehavioralFeature) o); } } } catch (InvalidObjectException e) { throw new InvalidElementException(e); } return ret; } else { throw new IllegalArgumentException("Argument is not a classifier"); } }
public Collection getAllBehavioralFeatures(Object ns) { // Get Classifiers in Namespace ArrayList features = new ArrayList(); try { Collection classifiers = getAllModelElementsOfKind(ns, modelImpl.getMetaTypes().getClassifier()); Iterator i = classifiers.iterator(); // Get Features owned by those Classifiers while (i.hasNext()) { features.addAll(modelImpl.getFacade().getFeatures(i.next())); } } catch (InvalidObjectException e) { throw new InvalidElementException(e); } // Select those Features which are BehavioralFeatures ArrayList behavioralfeatures = new ArrayList(); Iterator ii = features.iterator(); while (ii.hasNext()) { Object f = ii.next(); if (f instanceof BehavioralFeature) { behavioralfeatures.add(f); } } return behavioralfeatures; }
Clone fragments detected by clone detection tool
File path: /ArgoUML-0.34-src/argouml/src/argouml-core-model-mdr/src/org/argouml/model/mdr/CoreHelperMDRImpl.java File path: /ArgoUML-0.34-src/argouml/src/argouml-core-model-mdr/src/org/argouml/model/mdr/ModelManagementHelperMDRImpl.java
Method name: List getBehavioralFeatures(Object) Method name: Collection getAllBehavioralFeatures(Object)
Number of AST nodes: 3 Number of AST nodes: 4
1
public List<BehavioralFeature> getBehavioralFeatures(Object clazz) {
1
public Collection getAllBehavioralFeatures(Object ns) {
2
        if (clazz instanceof Classifier) {
2
        // Get Classifiers in Namespace
3
            List<BehavioralFeature> ret = new ArrayList<BehavioralFeature>();
3
        ArrayList features = new ArrayList();
4
            try {
4
        try {
5
                for (Object o : modelImpl.getFacade().getFeatures(clazz)) {
5
            Collection classifiers = getAllModelElementsOfKind(ns, 
6
                    if (o instanceof BehavioralFeature) {
6
                    modelImpl.getMetaTypes().getClassifier());
7
                        ret.add((BehavioralFeature) o);
7
            Iterator i = classifiers.iterator();
8
                    }
8
            // Get Features owned by those Classifiers
9
                }
9
            while (i.hasNext()) {
10
            } catch (InvalidObjectException e) {
10
                features.addAll(modelImpl.getFacade().getFeatures(i.next()));
11
                throw new InvalidElementException(e);
11
            }
12
            }
12
        } catch (InvalidObjectException e) {
13
            return ret;
13
            throw new InvalidElementException(e);
14
        } else {
14
        }
15
            throw new IllegalArgumentException("Argument is not a classifier");
15
        // Select those Features which are BehavioralFeatures
16
        }
16
        ArrayList behavioralfeatures = new ArrayList();
17
    }
17
        Iterator ii = features.iterator();
18
        while (ii.hasNext()) {
19
            Object f = ii.next();
20
            if (f instanceof BehavioralFeature) {
21
                behavioralfeatures.add(f);
22
            }
23
        }
24
        return behavioralfeatures;
25
    }
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements4
    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.600
    Clone typeType 3
    Mapped Statements
    ID Statement ID Statement
    4
    for (Object o : modelImpl.getFacade().getFeatures(clazz))
    4
    for (Object o : modelImpl.getFacade().getFeatures(clazz))
    9
    while (ii.hasNext())
    Differences
    Expression1Expression2Difference
    ofVARIABLE_NAME_MISMATCH
    modelImpl.getFacade().getFeatures(clazz)featuresTYPE_COMPATIBLE_REPLACEMENT
    9
    while (ii.hasNext())
                                                  
    10
    Object f = ii.next();
    Differences
    Expression1Expression2Difference
    ofVARIABLE_NAME_MISMATCH
    10
    Object f = ii.next();
    5
    if (o instanceof BehavioralFeature)
    5
    if (o instanceof BehavioralFeature)
    11
    if (f instanceof BehavioralFeature)
    Differences
    Expression1Expression2Difference
    ofVARIABLE_NAME_MISMATCH
    11
    if (f instanceof BehavioralFeature)
    6
    ret.add((BehavioralFeature)o);
    6
    ret.add((BehavioralFeature)o);
    Preondition Violations
    Unmatched statement ret.add((BehavioralFeature)o); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                      
                                                                
    12
    behavioralfeatures.add(f);
    Preondition Violations
    Unmatched statement behavioralfeatures.add(f); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    12
    behavioralfeatures.add(f);
    Precondition Violations (2)
    Row Violation
    1Unmatched statement ret.add((BehavioralFeature)o); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    2Unmatched statement behavioralfeatures.add(f); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted