EStructuralFeature entryFeature = object.getEStructuralFeature(); if (isMany(entryFeature)) { if (entryFeature.isUnique()) { for (int i = 0, size = delegateSize(); i < size; ++i) { Entry otherEntry = delegateGet(i); if (otherEntry.equals(object) && i != index) { throw new IllegalArgumentException("The 'no duplicates' constraint is violated"); } } } } else { FeatureMapUtil.Validator validator = FeatureMapUtil.getValidator(owner.eClass(), entryFeature); for (int i = 0, size = delegateSize(); i < size; ++i) { Entry otherEntry = delegateGet(i); if (validator.isValid(otherEntry.getEStructuralFeature()) && i != index) { throw new IllegalArgumentException("The multiplicity constraint is violated"); } } } return doSet(index, object);
EStructuralFeature entryFeature = object.getEStructuralFeature(); if (isMany(entryFeature)) { if (entryFeature.isUnique()) { for (int i = 0, size = delegateSize(); i < size; ++i) { Entry otherEntry = delegateGet(i); if (otherEntry.equals(object) && i != index) { throw new IllegalArgumentException("The 'no duplicates' constraint is violated"); } } } } else { FeatureMapUtil.Validator validator = FeatureMapUtil.getValidator(owner.eClass(), entryFeature); for (int i = 0, size = delegateSize(); i < size; ++i) { Entry otherEntry = delegateGet(i); if (validator.isValid(otherEntry.getEStructuralFeature())) { throw new IllegalArgumentException("The multiplicity constraint is violated"); } } } doAdd(index, object);
Clone fragments detected by clone detection tool
File path: /emf-2.4.1/src/org/eclipse/emf/ecore/util/DelegatingFeatureMap.java File path: /emf-2.4.1/src/org/eclipse/emf/ecore/util/DelegatingFeatureMap.java
Method name: Entry set(int, Entry) Method name: void add(int, Entry)
Number of AST nodes: 13 Number of AST nodes: 13
1
EStructuralFeature entryFeature = object.getEStructuralFeature();
1
EStructuralFeature entryFeature = object.getEStructuralFeature();
2
    if (isMany(entryFeature))
2
    if (isMany(entryFeature))
3
    {
3
    {
4
      if (entryFeature.isUnique())
4
      if (entryFeature.isUnique())
5
      {
5
      {
6
        for (int i = 0, size = delegateSize(); i < size; ++i)
6
        for (int i = 0, size = delegateSize(); i < size; ++i)
7
        {
7
        {
8
          Entry otherEntry = delegateGet(i);
8
          Entry otherEntry = delegateGet(i);
9
          if (otherEntry.equals(object) && i != index)
9
          if (otherEntry.equals(object) && i != index)
10
          {
10
          {
11
            throw new IllegalArgumentException("The 'no duplicates' constraint is violated");
11
            throw new IllegalArgumentException("The 'no duplicates' constraint is violated");
12
          }
12
          }
13
        }
13
        }
14
      }
14
      }
15
    }
15
    }
16
    else
16
    else
17
    {
17
    {
18
      FeatureMapUtil.Validator validator = FeatureMapUtil.getValidator(owner.eClass(), entryFeature);
18
      FeatureMapUtil.Validator validator = FeatureMapUtil.getValidator(owner.eClass(), entryFeature);
19
      for (int i = 0, size = delegateSize(); i < size; ++i)
19
      for (int i = 0, size = delegateSize(); i < size; ++i)
20
      {
20
      {
21
        Entry otherEntry = delegateGet(i);
21
        Entry otherEntry = delegateGet(i);
22
        if (validator.isValid(otherEntry.getEStructuralFeature()) && i != index)
22
        if (validator.isValid(otherEntry.getEStructuralFeature()))
23
        {
23
        {
24
          throw new IllegalArgumentException("The multiplicity constraint is violated");
24
          throw new IllegalArgumentException("The multiplicity constraint is violated");
25
        }
25
        }
26
      }
26
      }
27
    }
27
    }
28
    return doSet(index, object);
28
    doAdd(index, object);
Summary
Number of common nesting structure subtrees1
Number of refactorable cases1
Number of non-refactorable cases0
Time elapsed for finding largest common nesting structure subtrees (ms)1.0
Clones locationClones are declared in the same class
Number of node comparisons20
  1. {Refactorable}
    Mapping Summary
    Number of mapped statements8
    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.3
    Clone typeType 1
    Mapped Statements
    ID Statement ID Statement
    1
    EStructuralFeature entryFeature = object.getEStructuralFeature();
    1
    EStructuralFeature entryFeature = object.getEStructuralFeature();
    2
    if (isMany(entryFeature))
    2
    if (isMany(entryFeature))
    3
    if (entryFeature.isUnique())
    3
    if (entryFeature.isUnique())
    4
    for (int i = 0, size = delegateSize(); i < size; ++i)
    4
    for (int i = 0, size = delegateSize(); i < size; ++i)
    5
    Entry otherEntry = delegateGet(i);
    5
    Entry otherEntry = delegateGet(i);
    6
    if (otherEntry.equals(object) && i != index)
    6
    if (otherEntry.equals(object) && i != index)
    7
    throw new IllegalArgumentException("The 'no duplicates' constraint is violated");
    7
    throw new IllegalArgumentException("The 'no duplicates' constraint is violated");
    Precondition Violations (0)
    Row Violation