274-1-3

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 (!(obj instanceof ColorBar)) { return false; } ColorBar that = (ColorBar) obj; if (!this.axis.equals(that.axis)) { return false; } if (this.colorBarThickness != that.colorBarThickness) { return false; } if (this.colorBarThicknessPercent != that.colorBarThicknessPercent) { return false; } if (!this.colorPalette.equals(that.colorPalette)) { return false; } if (this.colorBarLength != that.colorBarLength) { return false; } if (this.outerGap != that.outerGap) { 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/axis/ColorBar.java
Method name: `boolean equals(Object)` |  | Method name: `boolean equals(Object)`
Number of AST nodes: 18 |  | Number of AST nodes: 18

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

            ↵

5

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

5

    if (!(obj instanceof ColorBar)) {↵

6

                return false;↵

6

                return false;   ↵

7

            }↵

7

            }↵

8

            if (!(obj instanceof XYDrawableAnnotation)) {↵

8

            ↵

9

                return false;↵

10

            }↵

11

            XYDrawableAnnotation that = (XYDrawableAnnotation) obj;↵

12

            if (this.x != that.x↵

9

    ColorBar that = (ColorBar) obj;↵

10

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

11

                return false;↵

12

            }↵

13

    ) {↵

13

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

14

                return false;↵

14

                return false;↵

15

            }↵

15

            }↵

16

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

16

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

17

                return false;↵

17

                return false;↵

18

            }↵

18

            }↵

19

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

19

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

20

                return false;↵

20

                return false;↵

21

            }↵

21

            }↵

22

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

22

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

23

                return false;↵

23

                return false;↵

24

            }↵

24

            }↵

25

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

25

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

26

                return false;↵

26

                return false;↵

27

            }↵

27

            }↵

28

            // seem to be the same...↵

29

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

1. {Non-refactorable}

   Mapping Summary
   Number of mapped statements | 8
   Number of unmapped statements in the first code fragment | 1
   Number of unmapped statements in the second code fragment | 3
   Time elapsed for statement mapping (ms) | 1.1
   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))
   3 | if (!(obj instanceof ColorBar))

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   super.equals(obj) | (obj instanceof ColorBar) | TYPE_COMPATIBLE_REPLACEMENT

   3

       if (!(obj instanceof ColorBar))

   4

       return false;

   4 | return false;
   4 | return false;

   Preondition Violations
   Conditional return false;
   Conditional return false;

   4

       return false;

   5

       ColorBar that = (ColorBar)obj;

   5

       if (!(obj instanceof XYDrawableAnnotation))

   5 | if (!(obj instanceof XYDrawableAnnotation))
   6 | if (! this.axis.equals(that.axis))

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   (obj instanceof XYDrawableAnnotation) | this.axis.equals(that.axis) | TYPE_COMPATIBLE_REPLACEMENT

   6

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

   6

       return false;

   6 | return false;
   7 | return false;

   Preondition Violations
   Conditional return false;
   Conditional return false;

   7

       return false;

   7

       XYDrawableAnnotation that = (XYDrawableAnnotation)obj;

   8

       if (this.colorBarThickness != that.colorBarThickness)

   9 | return false;

   Preondition Violations
   Unmatched return false;

   9

       return false;

   8

       if (this.x != that.x)

   8 | if (this.x != that.x)
   10 | if (this.colorBarThicknessPercent != that.colorBarThicknessPercent)

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   x | colorBarThicknessPercent | VARIABLE_NAME_MISMATCH
   org.jfree.chart.annotations.XYDrawableAnnotation | org.jfree.chart.axis.ColorBar | VARIABLE_TYPE_MISMATCH
   x | colorBarThicknessPercent | VARIABLE_NAME_MISMATCH

   Preondition Violations

   Type org.jfree.chart.annotations.XYDrawableAnnotation of variable that does not match with type org.jfree.chart.axis.ColorBar of variable that
   - Make classes org.jfree.chart.annotations.XYDrawableAnnotation and org.jfree.chart.axis.ColorBar extend a common superclass

   10

       if (this.colorBarThicknessPercent != that.colorBarThicknessPercent)

   9

       return false;

   9 | return false;
   11 | return false;

   Preondition Violations
   Conditional return false;
   Conditional return false;

   11

       return false;

   Precondition Violations (10)
   Row | Violation
   --- | ---
   1 | Unmatched return false;
   2 | Type org.jfree.chart.annotations.XYDrawableAnnotation of variable that does not match with type org.jfree.chart.axis.ColorBar of variable that
   3 | Conditional return true;
   4 | Conditional return true;
   5 | Conditional return false;
   6 | Conditional return false;
   7 | Conditional return false;
   8 | Conditional return false;
   9 | Conditional return false;
   10 | Conditional return false;