43-156-157

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;
if (obj == this) { return true; } // now try to reject equality if (!super.equals(obj)) { return false; } if (!(obj instanceof XYPolygonAnnotation)) { return false; } XYPolygonAnnotation that = (XYPolygonAnnotation) obj; if (!Arrays.equals(this.polygon, that.polygon)) { return false; } if (!ObjectUtilities.equal(this.stroke, that.stroke)) { return false; } if (!PaintUtilities.equal(this.outlinePaint, that.outlinePaint)) { return false; } if (!PaintUtilities.equal(this.fillPaint, that.fillPaint)) { 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/chart/annotations/XYDrawableAnnotation.java |  | File path: /jfreechart-1.0.10/src/org/jfree/chart/annotations/XYPolygonAnnotation.java
Method name: `boolean equals(Object)` |  | Method name: `boolean equals(Object)`
Number of AST nodes: 18 |  | Number of AST nodes: 16

1

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

1

    if (obj == this) {↵

2

                return true;↵

2

                return true;↵

3

            }↵

3

            }↵

4

            // now try to reject equality...↵

4

            // now try to reject equality↵

5

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

5

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

6

                return false;↵

6

                return false;↵

7

            }↵

7

            }↵

8

            if (!(obj instanceof XYDrawableAnnotation)) {↵

8

            if (!(obj instanceof XYPolygonAnnotation)) {↵

9

                return false;↵

9

                return false;↵

10

            }↵

10

            }↵

11

            XYDrawableAnnotation that = (XYDrawableAnnotation) obj;↵

11

            XYPolygonAnnotation that = (XYPolygonAnnotation) obj;↵

12

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

12

            if (↵

13

                return false;↵

14

            }↵

15

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

13

    !Arrays.equals(this.polygon, that.polygon)) {↵

16

                return false;↵

14

                return false;   ↵

17

            }↵

15

            }↵

18

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

16

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

19

                return false;↵

17

                return false;↵

20

            }↵

18

            }↵

21

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

19

            if (!PaintUtilities.equal(this.outlinePaint, that.outlinePaint)) {↵

22

                return false;↵

20

                return false;↵

23

            }↵

21

            }↵

24

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

22

            if (!PaintUtilities.equal(this.fillPaint, that.fillPaint)) {↵

25

                return false;↵

23

                return false;↵

26

            }↵

24

            }↵

27

            // seem to be the same...↵

25

            // seem to be the same↵

28

            return true;

26

            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.8
Clones location | Clones are in different classes having the same super class
Number of node comparisons | 87

1. {Non-refactorable}

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

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

   1

       if (obj == this)

   1

       if (obj == this)

   2

       return true;

   2 | return true;
   2 | return true;

   Preondition Violations
   Conditional return true;
   Conditional return true;

   2

       return true;

   3

       if (!super.equals(obj))

   3

       if (!super.equals(obj))

   4

       return false;

   4 | return false;
   4 | return false;

   Preondition Violations
   Conditional return false;
   Conditional return false;

   4

       return false;

   5

       if (!(obj instanceof XYDrawableAnnotation))

   5 | if (!(obj instanceof XYDrawableAnnotation))
   5 | if (!(obj instanceof XYPolygonAnnotation))

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   org.jfree.chart.annotations.XYDrawableAnnotation | org.jfree.chart.annotations.XYPolygonAnnotation | SUBCLASS_TYPE_MISMATCH

   5

       if (!(obj instanceof XYPolygonAnnotation))

   6

       return false;

   6 | return false;
   6 | return false;

   Preondition Violations
   Conditional return false;
   Conditional return false;

   6

       return false;

   7

       XYDrawableAnnotation that = (XYDrawableAnnotation)obj;

   7 | XYDrawableAnnotation that = (XYDrawableAnnotation)obj;
   7 | XYPolygonAnnotation that = (XYPolygonAnnotation)obj;

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   org.jfree.chart.annotations.XYDrawableAnnotation | org.jfree.chart.annotations.XYPolygonAnnotation | SUBCLASS_TYPE_MISMATCH
   org.jfree.chart.annotations.XYDrawableAnnotation | org.jfree.chart.annotations.XYPolygonAnnotation | SUBCLASS_TYPE_MISMATCH
   org.jfree.chart.annotations.XYDrawableAnnotation | org.jfree.chart.annotations.XYPolygonAnnotation | SUBCLASS_TYPE_MISMATCH

   7

       XYPolygonAnnotation that = (XYPolygonAnnotation)obj;

   8

       if (!Arrays.equals(this.polygon, that.polygon))

   9 | return false;

   Preondition Violations
   Unmatched return false;

   9

       return false;

   8

       if (this.x != that.x)

   9

       return false;

   9 | return false;

   Preondition Violations
   Unmatched return false;

   10

       if (this.y != that.y)

   11

       return false;

   11 | return false;

   Preondition Violations
   Unmatched return false;

   12

       if (this.width != that.width)

   13

       return false;

   13 | return false;

   Preondition Violations
   Unmatched return false;

   14

       if (this.height != that.height)

   15

       return false;

   15 | return false;

   Preondition Violations
   Unmatched return false;

   16

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

   16 | if (! ObjectUtilities.equal(this.drawable, that.drawable))
   10 | if (! ObjectUtilities.equal(this.stroke, that.stroke))

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   drawable | stroke | VARIABLE_NAME_MISMATCH
   org.jfree.ui.Drawable | java.awt.Stroke | VARIABLE_TYPE_MISMATCH

   Preondition Violations

   Type org.jfree.ui.Drawable of variable this.drawable does not match with type java.awt.Stroke of variable this.stroke
   - Make classes org.jfree.ui.Drawable and java.awt.Stroke extend a common superclass

   10

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

   17

       return false;

   17 | return false;
   11 | return false;

   Preondition Violations
   Conditional return false;
   Conditional return false;

   11

       return false;

   Precondition Violations (15)
   Row | Violation
   --- | ---
   1 | Unmatched return false;
   2 | Unmatched return false;
   3 | Unmatched return false;
   4 | Unmatched return false;
   5 | Unmatched return false;
   6 | Type org.jfree.ui.Drawable of variable this.drawable does not match with type java.awt.Stroke of variable this.stroke
   7 | Clone fragment #1 returns variable that with type org.jfree.chart.annotations.XYDrawableAnnotation , while Clone fragment #2 returns variable that with type org.jfree.chart.annotations.XYPolygonAnnotation
   8 | Conditional return true;
   9 | Conditional return true;
   10 | Conditional return false;
   11 | Conditional return false;
   12 | Conditional return false;
   13 | Conditional return false;
   14 | Conditional return false;
   15 | Conditional return false;