40-1-4

if (obj == this) { return true; } if (!(obj instanceof PieDataset)) { return false; } PieDataset that = (PieDataset) obj; int count = getItemCount(); if (that.getItemCount() != count) { return false; } for (int i = 0; i < count; i++) { Comparable k1 = getKey(i); Comparable k2 = that.getKey(i); if (!k1.equals(k2)) { return false; } Number v1 = getValue(i); Number v2 = that.getValue(i); if (v1 == null) { if (v2 != null) { return false; } } else { if (!v1.equals(v2)) { return false; } } } return true;
if (obj == this) { return true; } if (!(obj instanceof KeyedObjects)) { return false; } KeyedObjects that = (KeyedObjects) obj; int count = getItemCount(); if (count != that.getItemCount()) { return false; } for (int i = 0; i < count; i++) { Comparable k1 = getKey(i); Comparable k2 = that.getKey(i); if (!k1.equals(k2)) { return false; } Object o1 = getObject(i); Object o2 = that.getObject(i); if (o1 == null) { if (o2 != null) { return false; } } else { if (!o1.equals(o2)) { return false; } } } return true;

Clone fragments detected by clone detection tool
File path: /jfreechart-1.0.10/src/org/jfree/data/category/CategoryToPieDataset.java |  | File path: /jfreechart-1.0.10/src/org/jfree/data/KeyedObjects.java
Method name: `boolean equals(Object)` |  | Method name: `boolean equals(Object)`
Number of AST nodes: 21 |  | Number of AST nodes: 21

1

    if (obj == this) {↵

1

    if (obj == this) {↵

2

                return true;↵

2

                return true;↵

3

            }↵

3

            }↵

4

            if (!(obj instanceof PieDataset)) {↵

4

            if (!(obj instanceof KeyedObjects)) {↵

5

                return false;↵

5

                return false;↵

6

            }↵

6

            }↵

7

            PieDataset that = (PieDataset) obj;↵

7

            KeyedObjects that = (KeyedObjects) obj;↵

8

            int count = getItemCount();↵

8

            int count = getItemCount();↵

9

            if (that.getItemCount() != count) {↵

9

            if (count != that.getItemCount()) {↵

10

                return false;↵

10

                return false;↵

11

            }↵

11

            }↵

12

            for (int i = 0; i < count; i++) {↵

12

            for (int i = 0; i < count; i++) {↵

13

                Comparable k1 = getKey(i);↵

13

                Comparable k1 = getKey(i);↵

14

                Comparable k2 = that.getKey(i);↵

14

                Comparable k2 = that.getKey(i);↵

15

                if (!k1.equals(k2)) {↵

15

                if (!k1.equals(k2)) {↵

16

                    return false;↵

16

                    return false;↵

17

                }↵

17

                }↵

18

                Number v1 = getValue(i);↵

18

                Object o1 = getObject(i);↵

19

                Number v2 = that.getValue(i);↵

19

                Object o2 = that.getObject(i);↵

20

                if (v1 == null) {↵

20

                if (o1 == null) {↵

21

                    if (v2 != null) {↵

21

                    if (o2 != null) {↵

22

                        return false;↵

22

                        return false;↵

23

                    }↵

23

                    }↵

24

                }↵

24

                }↵

25

                else {↵

25

                else {↵

26

                    if (!v1.equals(v2)) {↵

26

                    if (!o1.equals(o2)) {↵

27

                        return false;↵

27

                        return false;↵

28

                    }↵

28

                    }↵

29

                }↵

29

                }↵

30

            }↵

30

            }↵

31

            return true;

31

            return true;

See real code fragment |  | See real code fragment

Summary
Number of common nesting structure subtrees | 1
Number of refactorable cases | 0
Number of non-refactorable cases | 1
Time elapsed for finding largest common nesting structure subtrees (ms) | 1.3
Clones location | Clones are in different classes
Number of node comparisons | 80

1. {Non-refactorable}

   Mapping Summary
   Number of mapped statements | 18
   Number of unmapped statements in the first code fragment | 3
   Number of unmapped statements in the second code fragment | 3
   Time elapsed for statement mapping (ms) | 4.6
   Clone type | Type 2

   Mapped Statements
   ID | Statement |  | ID | Statement
   --- | --- | --- | --- | ---

   1

       if (obj == this)

   1

       if (obj == this)

   2

       return true;

   2

       return true;

   3

       if (!(obj instanceof PieDataset))

   3 | if (!(obj instanceof PieDataset))
   3 | if (!(obj instanceof KeyedObjects))

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   org.jfree.data.general.PieDataset | org.jfree.data.KeyedObjects | VARIABLE_TYPE_MISMATCH

   Preondition Violations

   Type boolean of variable obj instanceof PieDataset does not match with type boolean of variable obj instanceof KeyedObjects
   - Make classes org.jfree.data.general.PieDataset and org.jfree.data.KeyedObjects extend a common superclass

   3

       if (!(obj instanceof KeyedObjects))

   4

       return false;

   4

       return false;

   5

       KeyedObjects that = (KeyedObjects)obj;

   5

       PieDataset that = (PieDataset)obj;

   6

       int count = getItemCount();

   6

       int count = getItemCount();

   7

       if (that.getItemCount() != count)

   7 | if (that.getItemCount() != count)
   7 | if (count != that.getItemCount())

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   that.getItemCount() | count | TYPE_COMPATIBLE_REPLACEMENT
   count | that.getItemCount() | TYPE_COMPATIBLE_REPLACEMENT

   Preondition Violations
   Expression count cannot be parameterized, because it has dependencies to/from statements that will be extracted
   Expression count cannot be parameterized, because it has dependencies to/from statements that will be extracted

   7

       if (count != that.getItemCount())

   8

       return false;

   8

       return false;

   9

       for (int i = 0; i < count; i++)

   9

       for (int i = 0; i < count; i++)

   10

       Comparable k1 = getKey(i);

   10

       Comparable k1 = getKey(i);

   11

       Comparable k2 = that.getKey(i);

   11 | Comparable k2 = that.getKey(i);
   11 | Comparable k2 = that.getKey(i);

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   org.jfree.data.general.PieDataset | org.jfree.data.KeyedObjects | VARIABLE_TYPE_MISMATCH

   Preondition Violations

   Type org.jfree.data.general.PieDataset of variable that does not match with type org.jfree.data.KeyedObjects of variable that
   - Make classes org.jfree.data.general.PieDataset and org.jfree.data.KeyedObjects extend a common superclass

   11

       Comparable k2 = that.getKey(i);

   12

       if (!k1.equals(k2))

   12

       if (!k1.equals(k2))

   13

       return false;

   13

       return false;

   14 | Object o1 = getObject(i);

   Preondition Violations
   Unmatched statement Object o1=getObject(i); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted

   14

       Object o1 = getObject(i);

   14

       Number v1 = getValue(i);

   14 | Number v1 = getValue(i);

   Preondition Violations
   Unmatched statement Number v1=getValue(i); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted

   15 | Object o2 = that.getObject(i);

   Preondition Violations
   Unmatched statement Object o2=that.getObject(i); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted

   15

       Object o2 = that.getObject(i);

   15

       Number v2 = that.getValue(i);

   15 | Number v2 = that.getValue(i);

   Preondition Violations
   Unmatched statement Number v2=that.getValue(i); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted

   16

       if (v1 == null)

   16 | if (v1 == null)
   16 | if (o1 == null)

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   v1 | o1 | VARIABLE_NAME_MISMATCH
   java.lang.Number | java.lang.Object | VARIABLE_TYPE_MISMATCH

   Preondition Violations

   Type java.lang.Number of variable v1 does not match with type java.lang.Object of variable o1
   - Make classes java.lang.Number and java.lang.Object extend a common superclass

   16

       if (o1 == null)

   17

       if (v2 != null)

   17 | if (v2 != null)
   17 | if (o2 != null)

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   v2 | o2 | VARIABLE_NAME_MISMATCH
   java.lang.Number | java.lang.Object | VARIABLE_TYPE_MISMATCH

   Preondition Violations

   Type java.lang.Number of variable v2 does not match with type java.lang.Object of variable o2
   - Make classes java.lang.Number and java.lang.Object extend a common superclass

   17

       if (o2 != null)

   18

       return false;

   18

       return false;

       else

       else

   19

       if (!v1.equals(v2))

   19 | if (! v1.equals(v2))
   19 | if (! o1.equals(o2))

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   v2 | o2 | VARIABLE_NAME_MISMATCH
   java.lang.Number | java.lang.Object | VARIABLE_TYPE_MISMATCH
   v1 | o1 | VARIABLE_NAME_MISMATCH
   java.lang.Number | java.lang.Object | VARIABLE_TYPE_MISMATCH

   Preondition Violations

   Type java.lang.Number of variable v2 does not match with type java.lang.Object of variable o2
   - Make classes java.lang.Number and java.lang.Object extend a common superclass

   Type java.lang.Number of variable v1 does not match with type java.lang.Object of variable o1
   - Make classes java.lang.Number and java.lang.Object extend a common superclass

   19

       if (!o1.equals(o2))

   20

       return false;

   20

       return false;

   21

       return true;

   21

       return true;

   Precondition Violations (12)
   Row | Violation
   --- | ---
   1 | Type boolean of variable obj instanceof PieDataset does not match with type boolean of variable obj instanceof KeyedObjects
   2 | Expression count cannot be parameterized, because it has dependencies to/from statements that will be extracted
   3 | Expression count cannot be parameterized, because it has dependencies to/from statements that will be extracted
   4 | Type org.jfree.data.general.PieDataset of variable that does not match with type org.jfree.data.KeyedObjects of variable that
   5 | Unmatched statement Object o1=getObject(i); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
   6 | Unmatched statement Number v1=getValue(i); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
   7 | Unmatched statement Object o2=that.getObject(i); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
   8 | Unmatched statement Number v2=that.getValue(i); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
   9 | Type java.lang.Number of variable v1 does not match with type java.lang.Object of variable o1
   10 | Type java.lang.Number of variable v2 does not match with type java.lang.Object of variable o2
   11 | Type java.lang.Number of variable v2 does not match with type java.lang.Object of variable o2
   12 | Type java.lang.Number of variable v1 does not match with type java.lang.Object of variable o1