43-112-156

if (obj == this) { return true; } if (!(obj instanceof DatasetGroup)) { return false; } DatasetGroup that = (DatasetGroup) obj; if (!this.id.equals(that.id)) { return false; } return true;
if (obj == this) { // simple case return true; } // now try to reject equality... if (!super.equals(obj)) { return false; } if (!(obj instanceof XYDrawableAnnotation)) { return false; } XYDrawableAnnotation that = (XYDrawableAnnotation) obj; if (this.x != that.x) { return false; } if (this.y != that.y) { return false; } if (this.width != that.width) { return false; } if (this.height != that.height) { return false; } if (!ObjectUtilities.equal(this.drawable, that.drawable)) { return false; } // seem to be the same... return true;

Clone fragments detected by clone detection tool
File path: /jfreechart-1.0.10/src/org/jfree/data/general/DatasetGroup.java |  | File path: /jfreechart-1.0.10/src/org/jfree/chart/annotations/XYDrawableAnnotation.java
Method name: `boolean equals(Object)` |  | Method name: `boolean equals(Object)`
Number of AST nodes: 8 |  | Number of AST nodes: 18

1

    if (obj == this) {↵

1

    if (obj == this) { // simple case↵

2

                return true;   ↵

2

                return true;↵

3

            }↵

4

            // now try to reject equality...↵

5

            if (!super.equals(obj)) {↵

6

                return false;↵

3

            }↵

7

            }↵

4

            if (!(obj instanceof DatasetGroup)) {↵

8

            if (!(obj instanceof XYDrawableAnnotation)) {↵

5

                return false;   ↵

9

                return false;↵

6

            }↵

10

            }↵

7

            DatasetGroup that = (DatasetGroup) obj;↵

11

            ↵

8

            if (!this.id.equals(that.id)) {↵

9

                return false;   ↵

10

            }↵

12

    XYDrawableAnnotation that = (XYDrawableAnnotation) obj;↵

13

            if (this.x != that.x) {↵

14

                return false;↵

15

            }↵

16

            if (this.y != that.y) {↵

17

                return false;↵

18

            }↵

19

            if (this.width != that.width) {↵

20

                return false;↵

21

            }↵

22

            if (this.height != that.height) {↵

23

                return false;↵

24

            }↵

25

            if (!ObjectUtilities.equal(this.drawable, that.drawable)) {↵

26

                return false;↵

27

            }↵

28

            // seem to be the same...↵

11

            return true;

29

            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) | 0.7
Clones location | Clones are in different classes
Number of node comparisons | 46

1. {Non-refactorable}

   Mapping Summary
   Number of mapped statements | 7
   Number of unmapped statements in the first code fragment | 1
   Number of unmapped statements in the second code fragment | 11
   Time elapsed for statement mapping (ms) | 0.7
   Clone type | Type 3

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

   1

       if (obj == this)

   1

       if (obj == this)

   2

       return true;

   2

       return true;

   3

       if (!(obj instanceof DatasetGroup))

   3 | if (!(obj instanceof DatasetGroup))
   5 | if (!(obj instanceof XYDrawableAnnotation))

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   org.jfree.data.general.DatasetGroup | org.jfree.chart.annotations.XYDrawableAnnotation | VARIABLE_TYPE_MISMATCH

   Preondition Violations

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

   5

       if (!(obj instanceof XYDrawableAnnotation))

   4

       return false;

   6

       return false;

   5

       DatasetGroup that = (DatasetGroup)obj;

   6

       if (!this.id.equals(that.id))

   6 | if (! this.id.equals(that.id))
   3 | if (! super.equals(obj))

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   this.id.equals(that.id) | super.equals(obj) | TYPE_COMPATIBLE_REPLACEMENT

   3

       if (!super.equals(obj))

   7

       return false;

   4

       return false;

   7

       XYDrawableAnnotation that = (XYDrawableAnnotation)obj;

   8

       if (this.x != that.x)

   9 | return false;

   Preondition Violations
   Unmatched return false;

   9

       return false;

   10

       if (this.y != that.y)

   11 | return false;

   Preondition Violations
   Unmatched return false;

   11

       return false;

   12

       if (this.width != that.width)

   13 | return false;

   Preondition Violations
   Unmatched return false;

   13

       return false;

   14

       if (this.height != that.height)

   15 | return false;

   Preondition Violations
   Unmatched return false;

   15

       return false;

   16

       if (!ObjectUtilities.equal(this.drawable, that.drawable))

   17 | return false;

   Preondition Violations
   Unmatched return false;

   17

       return false;

   8

       return true;

   18

       return true;

   Precondition Violations (6)
   Row | Violation
   --- | ---
   1 | Type boolean of variable obj instanceof DatasetGroup does not match with type boolean of variable obj instanceof XYDrawableAnnotation
   2 | Unmatched return false;
   3 | Unmatched return false;
   4 | Unmatched return false;
   5 | Unmatched return false;
   6 | Unmatched return false;