43-1-157

if (obj == this) { return true; } if (!(obj instanceof PieLabelRecord)) { return false; } PieLabelRecord that = (PieLabelRecord) obj; if (!this.key.equals(that.key)) { return false; } if (this.angle != that.angle) { return false; } if (this.gap != that.gap) { return false; } if (this.allocatedY != that.allocatedY) { return false; } if (this.baseY != that.baseY) { return false; } if (this.labelHeight != that.labelHeight) { return false; } if (this.linkPercent != that.linkPercent) { return false; } if (!this.label.equals(that.label)) { return false; } 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/plot/PieLabelRecord.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: 22 |  | Number of AST nodes: 16

1

    if (obj == this) {↵

1

    if (obj == this) {↵

2

                return true;↵

2

                return true;↵

3

            }↵

3

            }↵

4

            if (!(obj instanceof PieLabelRecord)) {↵

4

            ↵

5

                return false;↵

6

            }↵

7

            PieLabelRecord that = (PieLabelRecord) obj;↵

8

            if (!this.key.equals(that.key↵

5

    // now try to reject equality↵

9

    )) {↵

6

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

10

                return false;↵

7

                return false;↵

11

            }↵

8

            }↵

12

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

9

            if (!(obj instanceof XYPolygonAnnotation)) {↵

13

                return false;↵

10

                return false;↵

14

            }↵

11

            }↵

15

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

12

            ↵

16

                return false;↵

17

            }↵

18

            if (this.allocatedY != that.allocatedY↵

13

    XYPolygonAnnotation that = (XYPolygonAnnotation) obj;↵

19

    ) {↵

14

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

20

                return false;↵

15

                return false;   ↵

21

            }↵

16

            }↵

22

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

17

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

23

                return false;↵

18

                return false;↵

24

            }↵

19

            }↵

25

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

20

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

26

                return false;↵

21

                return false;↵

27

            }↵

22

            }↵

28

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

23

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

29

                return false;↵

24

                return false;↵

30

            }↵

25

            }↵

31

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

26

            ↵

32

                return false;↵

33

            }↵

27

    // seem to be the same↵

34

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

1. {Non-refactorable}

   Mapping Summary
   Number of mapped statements | 6
   Number of unmapped statements in the first code fragment | 1
   Number of unmapped statements in the second code fragment | 0
   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 (!(obj instanceof PieLabelRecord))

   3 | if (!(obj instanceof PieLabelRecord))
   5 | if (!(obj instanceof XYPolygonAnnotation))

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   org.jfree.chart.plot.PieLabelRecord | org.jfree.chart.annotations.XYPolygonAnnotation | VARIABLE_TYPE_MISMATCH

   Preondition Violations

   Type boolean of variable obj instanceof PieLabelRecord does not match with type boolean of variable obj instanceof XYPolygonAnnotation
   - Make classes org.jfree.chart.plot.PieLabelRecord and org.jfree.chart.annotations.XYPolygonAnnotation extend a common superclass

   5

       if (!(obj instanceof XYPolygonAnnotation))

   4

       return false;

   4 | return false;
   6 | return false;

   Preondition Violations
   Conditional return false;
   Conditional return false;

   6

       return false;

   5

       PieLabelRecord that = (PieLabelRecord)obj;

   6

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

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

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

   3

       if (!super.equals(obj))

   7

       return false;

   7 | return false;
   4 | return false;

   Preondition Violations
   Conditional return false;
   Conditional return false;

   4

       return false;

   Precondition Violations (7)
   Row | Violation
   --- | ---
   1 | Type boolean of variable obj instanceof PieLabelRecord does not match with type boolean of variable obj instanceof XYPolygonAnnotation
   2 | Conditional return true;
   3 | Conditional return true;
   4 | Conditional return false;
   5 | Conditional return false;
   6 | Conditional return false;
   7 | Conditional return false;