if (collection.isEmpty()) { return ECollections.emptyEList(); } else { Collection<E> filteredResult = useEquals() ? new BasicEList<E>(collection.size()) : new BasicEList.FastCompare<E>(collection.size()); for (E object : this) { if (collection.contains(object)) { filteredResult.add(object); } } return filteredResult; }
if (collection.isEmpty()) { return ECollections.emptyEList(); } else { Collection<E> filteredResult = useEquals() ? new BasicEList<E>(collection.size()) : new FastCompare<E>(collection.size()); for (E object : this) { if (collection.contains(object)) { filteredResult.add(object); } } return filteredResult; }
Clone fragments detected by clone detection tool
File path: /emf-2.4.1/src/org/eclipse/emf/common/util/DelegatingEList.java File path: /emf-2.4.1/src/org/eclipse/emf/common/util/BasicEList.java
Method name: Collection getDuplicates(Collection) Method name: Collection getDuplicates(Collection)
Number of AST nodes: 7 Number of AST nodes: 7
1
if (collection.isEmpty())
1
if (collection.isEmpty())
2
    {
2
    {
3
      return ECollections.emptyEList();
3
      return ECollections.emptyEList();
4
    }
4
    }
5
    else
5
    else
6
    {
6
    {
7
      Collection<E> filteredResult = useEquals() ? new BasicEList<E>(collection.size()) : new BasicEList.FastCompare<E>(collection.size());
7
      Collection<E> filteredResult = useEquals() ? new BasicEList<E>(collection.size()) : new FastCompare<E>(collection.size());
8
      for (E object : this)
8
      for (E object : this)
9
      {
9
      {
10
        if (collection.contains(object))
10
        if (collection.contains(object))
11
        {
11
        {
12
          filteredResult.add(object);
12
          filteredResult.add(object);
13
        }
13
        }
14
      }
14
      }
15
      return filteredResult;
15
      return filteredResult;
16
    }
16
    }
Summary
Number of common nesting structure subtrees1
Number of refactorable cases0
Number of non-refactorable cases1
Time elapsed for finding largest common nesting structure subtrees (ms)0.2
Clones locationClones are in different classes having the same super class
Number of node comparisons21
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements6
    Number of unmapped statements in the first code fragment1
    Number of unmapped statements in the second code fragment1
    Time elapsed for statement mapping (ms)2.1
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    1
    if (collection.isEmpty())
    1
    if (collection.isEmpty())
    1
    if (collection.isEmpty())
    Differences
    Expression1Expression2Difference
    java.util.Collection<>java.util.Collection<>VARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type java.util.Collection<> of variable collection does not match with type java.util.Collection<> of variable collection
    • Make classes java.util.Collection<> and java.util.Collection<> extend a common superclass
    1
    if (collection.isEmpty())
    2
    return ECollections.emptyEList();
    2
    return ECollections.emptyEList();
    else
    else
                                                                                                                                                                                                                                                          
    3
    Collection<E> filteredResult = useEquals() ? new BasicEList<E>(collection.size()) : new FastCompare<E>(collection.size());
    Preondition Violations
    Unmatched statement Collection<E> filteredResult=useEquals() ? new BasicEList<E>(collection.size()) : new FastCompare<E>(collection.size()); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    3
    Collection<E> filteredResult = useEquals() ? new BasicEList<E>(collection.size()) : new FastCompare<E>(collection.size());
    3
    Collection<E> filteredResult = useEquals() ? new BasicEList<E>(collection.size()) : new BasicEList.FastCompare<E>(collection.size());
    3
    Collection<E> filteredResult = useEquals() ? new BasicEList<E>(collection.size()) : new BasicEList.FastCompare<E>(collection.size());
    Preondition Violations
    Unmatched statement Collection<E> filteredResult=useEquals() ? new BasicEList<E>(collection.size()) : new BasicEList.FastCompare<E>(collection.size()); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                                                                                                                                                                                                                                
    4
    for (E object : this)
    4
    for (E object : this)
    5
    if (collection.contains(object))
    5
    if (collection.contains(object))
    5
    if (collection.contains(object))
    Differences
    Expression1Expression2Difference
    java.util.Collection<>java.util.Collection<>VARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type java.util.Collection<> of variable collection does not match with type java.util.Collection<> of variable collection
    • Make classes java.util.Collection<> and java.util.Collection<> extend a common superclass
    5
    if (collection.contains(object))
    6
    filteredResult.add(object);
    6
    filteredResult.add(object);
    7
    return filteredResult;
    7
    return filteredResult;
    Precondition Violations (4)
    Row Violation
    1Type java.util.Collection<> of variable collection does not match with type java.util.Collection<> of variable collection
    2Unmatched statement Collection<E> filteredResult=useEquals() ? new BasicEList<E>(collection.size()) : new FastCompare<E>(collection.size()); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    3Unmatched statement Collection<E> filteredResult=useEquals() ? new BasicEList<E>(collection.size()) : new BasicEList.FastCompare<E>(collection.size()); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    4Type java.util.Collection<> of variable collection does not match with type java.util.Collection<> of variable collection