43-156-158

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; } if (!super.equals(obj)) { return false; } if (!(obj instanceof WaterfallBarRenderer)) { return false; } WaterfallBarRenderer that = (WaterfallBarRenderer) obj; if (!PaintUtilities.equal(this.firstBarPaint, that.firstBarPaint)) { return false; } if (!PaintUtilities.equal(this.lastBarPaint, that.lastBarPaint)) { return false; } if (!PaintUtilities.equal(this.positiveBarPaint, that.positiveBarPaint)) { return false; } if (!PaintUtilities.equal(this.negativeBarPaint, that.negativeBarPaint)) { return false; } 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/renderer/category/WaterfallBarRenderer.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...↵

5

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

4

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

6

                return false;↵

5

                return false;↵

7

            }↵

6

            }↵

8

            if (!(obj instanceof XYDrawableAnnotation)) {↵

7

            if (!(obj instanceof WaterfallBarRenderer)) {↵

9

                return false;↵

8

                return false;↵

10

            }↵

9

            }↵

11

            XYDrawableAnnotation that = (XYDrawableAnnotation) obj;↵

10

            ↵

12

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

13

                return false;↵

14

            }↵

15

            if (this.y != that.y↵

11

    WaterfallBarRenderer that = (WaterfallBarRenderer) obj;↵

12

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

13

                return false;↵

14

            }↵

16

    ) {↵

15

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

17

                return false;↵

16

                return false;↵

18

            }↵

17

            }↵

19

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

18

            if (↵

20

                return false;↵

19

    !PaintUtilities.equal(this.positiveBarPaint,↵

21

            }↵

20

            ↵

22

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

21

            that.positiveBarPaint)) {↵

23

                return false;↵

22

                return false;↵

24

            }↵

23

            }↵

25

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

24

            if (!PaintUtilities.equal(this.negativeBarPaint,↵

26

    )) {↵

25

                    that.negativeBarPaint)) {↵

27

                return false;↵

26

                return false;↵

28

            }↵

27

            }↵

29

            // seem to be the same...↵

30

            return true;

28

            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.7
Clones location | Clones are in different classes
Number of node comparisons | 87

1. {Non-refactorable}

   Mapping Summary
   Number of mapped statements | 8
   Number of unmapped statements in the first code fragment | 9
   Number of unmapped statements in the second code fragment | 1
   Time elapsed for statement mapping (ms) | 0.8
   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 WaterfallBarRenderer))

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   org.jfree.chart.annotations.XYDrawableAnnotation | org.jfree.chart.renderer.category.WaterfallBarRenderer | VARIABLE_TYPE_MISMATCH

   Preondition Violations

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

   5

       if (!(obj instanceof WaterfallBarRenderer))

   6

       return false;

   6 | return false;
   6 | return false;

   Preondition Violations
   Conditional return false;
   Conditional return false;

   6

       return false;

   7

       WaterfallBarRenderer that = (WaterfallBarRenderer)obj;

   7

       XYDrawableAnnotation that = (XYDrawableAnnotation)obj;

   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))
   8 | if (! PaintUtilities.equal(this.firstBarPaint, that.firstBarPaint))

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   drawable | firstBarPaint | VARIABLE_NAME_MISMATCH
   org.jfree.ui.Drawable | java.awt.Paint | VARIABLE_TYPE_MISMATCH
   org.jfree.util.ObjectUtilities | org.jfree.util.PaintUtilities | VARIABLE_TYPE_MISMATCH

   Preondition Violations

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

   Type org.jfree.util.ObjectUtilities of variable ObjectUtilities does not match with type org.jfree.util.PaintUtilities of variable PaintUtilities
   - Make classes org.jfree.util.ObjectUtilities and org.jfree.util.PaintUtilities extend a common superclass

   8

       if (!PaintUtilities.equal(this.firstBarPaint, that.firstBarPaint))

   17

       return false;

   17 | return false;
   9 | return false;

   Preondition Violations
   Conditional return false;
   Conditional return false;

   9

       return false;

   Precondition Violations (15)
   Row | Violation
   --- | ---
   1 | Type boolean of variable obj instanceof XYDrawableAnnotation does not match with type boolean of variable obj instanceof WaterfallBarRenderer
   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.Paint of variable this.firstBarPaint
   7 | Type org.jfree.util.ObjectUtilities of variable ObjectUtilities does not match with type org.jfree.util.PaintUtilities of variable PaintUtilities
   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;