Entry entry = object; EStructuralFeature entryFeature = entry.getEStructuralFeature(); if (isMany(entryFeature)) { if (entryFeature.isUnique()) { Entry [] entries = (Entry[])data; for (int i = 0; i < size; ++i) { Entry otherEntry = entries[i]; if (otherEntry.equals(entry) && i != index) { throw new IllegalArgumentException("The 'no duplicates' constraint is violated"); } } } } else { FeatureMapUtil.Validator validator = FeatureMapUtil.getValidator(owner.eClass(), entryFeature); Entry [] entries = (Entry[])data; for (int i = 0; i < size; ++i) { Entry otherEntry = entries[i]; if (validator.isValid(otherEntry.getEStructuralFeature())) { throw new IllegalArgumentException("The multiplicity constraint is violated"); } } } doAdd(index, object);
Entry entry = object; EStructuralFeature entryFeature = entry.getEStructuralFeature(); if (isMany(entryFeature)) { if (entryFeature.isUnique()) { Entry [] entries = (Entry[])data; for (int i = 0; i < size; ++i) { Entry otherEntry = entries[i]; if (otherEntry.equals(entry) && i != index) { throw new IllegalArgumentException("The 'no duplicates' constraint is violated"); } } } } else { FeatureMapUtil.Validator validator = FeatureMapUtil.getValidator(owner.eClass(), entryFeature); Entry [] entries = (Entry[])data; for (int i = 0; i < size; ++i) { Entry otherEntry = entries[i]; if (validator.isValid(otherEntry.getEStructuralFeature()) && i != index) { throw new IllegalArgumentException("The multiplicity constraint is violated"); } } } return doSet(index, object);
Clone fragments detected by clone detection tool
File path: /emf-2.4.1/src/org/eclipse/emf/ecore/util/BasicFeatureMap.java File path: /emf-2.4.1/src/org/eclipse/emf/ecore/util/BasicFeatureMap.java
Method name: void add(int, Entry) Method name: Entry set(int, Entry)
Number of AST nodes: 16 Number of AST nodes: 16
1
Entry entry = object;
1
Entry entry = object;
2
    EStructuralFeature entryFeature = entry.getEStructuralFeature();
2
    EStructuralFeature entryFeature = entry.getEStructuralFeature();
3
    if (isMany(entryFeature))
3
    if (isMany(entryFeature))
4
    {
4
    {
5
      if (entryFeature.isUnique())
5
      if (entryFeature.isUnique())
6
      {
6
      {
7
        Entry [] entries = (Entry[])data;
7
        Entry [] entries = (Entry[])data;
8
        for (int i = 0; i < size; ++i)
8
        for (int i = 0; i < size; ++i)
9
        {
9
        {
10
          Entry otherEntry = entries[i];
10
          Entry otherEntry = entries[i];
11
          if (otherEntry.equals(entry) && i != index)
11
          if (otherEntry.equals(entry) && i != index)
12
          {
12
          {
13
            throw new IllegalArgumentException("The 'no duplicates' constraint is violated");
13
            throw new IllegalArgumentException("The 'no duplicates' constraint is violated");
14
          }
14
          }
15
        }
15
        }
16
      }
16
      }
17
    }
17
    }
18
    else
18
    else
19
    {
19
    {
20
      FeatureMapUtil.Validator validator = FeatureMapUtil.getValidator(owner.eClass(), entryFeature);
20
      FeatureMapUtil.Validator validator = FeatureMapUtil.getValidator(owner.eClass(), entryFeature);
21
      Entry [] entries = (Entry[])data;
21
      Entry [] entries = (Entry[])data;
22
      for (int i = 0; i < size; ++i)
22
      for (int i = 0; i < size; ++i)
23
      {
23
      {
24
        Entry otherEntry = entries[i];
24
        Entry otherEntry = entries[i];
25
        if (validator.isValid(otherEntry.getEStructuralFeature()))
25
        if (validator.isValid(otherEntry.getEStructuralFeature()) && i != index)
26
        {
26
        {
27
          throw new IllegalArgumentException("The multiplicity constraint is violated");
27
          throw new IllegalArgumentException("The multiplicity constraint is violated");
28
        }
28
        }
29
      }
29
      }
30
    }
30
    }
31
    doAdd(index, object);
31
    return doSet(index, object);
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)1.0
Clones locationClones are declared in the same class
Number of node comparisons31
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements11
    Number of unmapped statements in the first code fragment0
    Number of unmapped statements in the second code fragment0
    Time elapsed for statement mapping (ms)1.9
    Clone typeType 1
    Mapped Statements
    ID Statement ID Statement
    1
    Entry entry = object;
    1
    Entry entry = object;
    2
    EStructuralFeature entryFeature = entry.getEStructuralFeature();
    2
    EStructuralFeature entryFeature = entry.getEStructuralFeature();
    3
    if (isMany(entryFeature))
    3
    if (isMany(entryFeature))
    4
    if (entryFeature.isUnique())
    4
    if (entryFeature.isUnique())
    5
    Entry[] entries = (Entry[])data;
    5
    Entry[] entries = (Entry[])data;
    6
    for (int i = 0; i < size; ++i)
    6
    for (int i = 0; i < size; ++i)
    7
    Entry otherEntry = entries[i];
    7
    Entry otherEntry = entries[i];
    8
    if (otherEntry.equals(entry) && i != index)
    8
    if (otherEntry.equals(entry) && i != index)
    9
    throw new IllegalArgumentException("The 'no duplicates' constraint is violated");
    9
    throw new IllegalArgumentException("The 'no duplicates' constraint is violated");
    Precondition Violations (1)
    Row Violation
    1Clone fragment #1 returns variables entries, validator , while Clone fragment #2 returns variables entries, validator