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;
Summary
Number of common nesting structure subtrees1
Number of refactorable cases0
Number of non-refactorable cases1
Time elapsed for finding largest common nesting structure subtrees (ms)4.0
Clones locationClones are in different classes
Number of node comparisons119
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements17
    Number of unmapped statements in the first code fragment1
    Number of unmapped statements in the second code fragment1
    Time elapsed for statement mapping (ms)39.3
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    1
    if (obj == this)
    1
    if (obj == this)
    2
    return true;
    2
    return true;
    3
    if (!super.equals(obj))
    3
    if (!super.equals(obj))
    3
    if (!(obj instanceof ColorBar))
    Differences
    Expression1Expression2Difference
    super.equals(obj)(obj instanceof ColorBar)TYPE_COMPATIBLE_REPLACEMENT
    Preondition Violations
    Super method call if(!super.equals(obj)) cannot be extracted from method
    3
    if (!(obj instanceof ColorBar))
    4
    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
    Expression1Expression2Difference
    (obj instanceof XYDrawableAnnotation)this.axis.equals(that.axis)TYPE_COMPATIBLE_REPLACEMENT
    Preondition Violations
    Expression this.axis.equals(that.axis) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    6
    if (!this.axis.equals(that.axis))
    6
    return false;
    7
    return false;
    7
    XYDrawableAnnotation that = (XYDrawableAnnotation)obj;
                                                                                                                  
    8
    if (this.x != that.x)
    8
    if (this.x != that.x)
    10
    if (this.colorBarThicknessPercent != that.colorBarThicknessPercent)
    Differences
    Expression1Expression2Difference
    xcolorBarThicknessPercentVARIABLE_NAME_MISMATCH
    org.jfree.chart.annotations.XYDrawableAnnotationorg.jfree.chart.axis.ColorBarVARIABLE_TYPE_MISMATCH
    xcolorBarThicknessPercentVARIABLE_NAME_MISMATCH
    Preondition Violations
    Type double of variable that.x does not match with type double of variable that.colorBarThicknessPercent
    • Make classes org.jfree.chart.annotations.XYDrawableAnnotation and org.jfree.chart.axis.ColorBar extend a common superclass
    Expression that.x cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression that.colorBarThicknessPercent cannot be parameterized, because it has dependencies to/from statements that will be extracted
    10
    if (this.colorBarThicknessPercent != that.colorBarThicknessPercent)
    9
    return false;
    11
    return false;
    10
    if (this.y != that.y)
    10
    if (this.y != that.y)
    8
    if (this.colorBarThickness != that.colorBarThickness)
    Differences
    Expression1Expression2Difference
    ycolorBarThicknessVARIABLE_NAME_MISMATCH
    doubleintVARIABLE_TYPE_MISMATCH
    org.jfree.chart.annotations.XYDrawableAnnotationorg.jfree.chart.axis.ColorBarVARIABLE_TYPE_MISMATCH
    ycolorBarThicknessVARIABLE_NAME_MISMATCH
    doubleintVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type double of variable this.y does not match with type int of variable this.colorBarThickness
    Type double of variable that.y does not match with type int of variable that.colorBarThickness
    • Make classes org.jfree.chart.annotations.XYDrawableAnnotation and org.jfree.chart.axis.ColorBar extend a common superclass
    Expression that.y cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression that.colorBarThickness cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Type double of variable that.y does not match with type int of variable that.colorBarThickness
    8
    if (this.colorBarThickness != that.colorBarThickness)
    11
    return false;
    9
    return false;
    12
    if (this.width != that.width)
    12
    if (this.width != that.width)
    14
    if (this.colorBarLength != that.colorBarLength)
    Differences
    Expression1Expression2Difference
    widthcolorBarLengthVARIABLE_NAME_MISMATCH
    doubleintVARIABLE_TYPE_MISMATCH
    org.jfree.chart.annotations.XYDrawableAnnotationorg.jfree.chart.axis.ColorBarVARIABLE_TYPE_MISMATCH
    widthcolorBarLengthVARIABLE_NAME_MISMATCH
    doubleintVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type double of variable this.width does not match with type int of variable this.colorBarLength
    Type double of variable that.width does not match with type int of variable that.colorBarLength
    • Make classes org.jfree.chart.annotations.XYDrawableAnnotation and org.jfree.chart.axis.ColorBar extend a common superclass
    Expression that.width cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression that.colorBarLength cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Type double of variable that.width does not match with type int of variable that.colorBarLength
    14
    if (this.colorBarLength != that.colorBarLength)
    13
    return false;
    15
    return false;
    14
    if (this.height != that.height)
    14
    if (this.height != that.height)
    16
    if (this.outerGap != that.outerGap)
    Differences
    Expression1Expression2Difference
    heightouterGapVARIABLE_NAME_MISMATCH
    doubleintVARIABLE_TYPE_MISMATCH
    org.jfree.chart.annotations.XYDrawableAnnotationorg.jfree.chart.axis.ColorBarVARIABLE_TYPE_MISMATCH
    heightouterGapVARIABLE_NAME_MISMATCH
    doubleintVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type double of variable this.height does not match with type int of variable this.outerGap
    Type double of variable that.height does not match with type int of variable that.outerGap
    • Make classes org.jfree.chart.annotations.XYDrawableAnnotation and org.jfree.chart.axis.ColorBar extend a common superclass
    Expression that.height cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression that.outerGap cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Type double of variable that.height does not match with type int of variable that.outerGap
    16
    if (this.outerGap != that.outerGap)
    15
    return false;
    17
    return false;
    16
    if (!ObjectUtilities.equal(this.drawable, that.drawable))
    16
    if (!ObjectUtilities.equal(this.drawable, that.drawable))
    12
    if (!this.colorPalette.equals(that.colorPalette))
    Differences
    Expression1Expression2Difference
    ObjectUtilities.equal(this.drawable,that.drawable)this.colorPalette.equals(that.colorPalette)TYPE_COMPATIBLE_REPLACEMENT
    Preondition Violations
    Expression ObjectUtilities.equal(this.drawable,that.drawable) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression this.colorPalette.equals(that.colorPalette) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    12
    if (!this.colorPalette.equals(that.colorPalette))
    17
    return false;
    13
    return false;
    18
    return true;
    18
    return true;
    Precondition Violations (23)
    Row Violation
    1Super method call if(!super.equals(obj)) cannot be extracted from method
    2Expression this.axis.equals(that.axis) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    3Type double of variable that.x does not match with type double of variable that.colorBarThicknessPercent
    4Expression that.x cannot be parameterized, because it has dependencies to/from statements that will be extracted
    5Expression that.colorBarThicknessPercent cannot be parameterized, because it has dependencies to/from statements that will be extracted
    6Type double of variable this.y does not match with type int of variable this.colorBarThickness
    7Type double of variable that.y does not match with type int of variable that.colorBarThickness
    8Expression that.y cannot be parameterized, because it has dependencies to/from statements that will be extracted
    9Expression that.colorBarThickness cannot be parameterized, because it has dependencies to/from statements that will be extracted
    10Type double of variable that.y does not match with type int of variable that.colorBarThickness
    11Type double of variable this.width does not match with type int of variable this.colorBarLength
    12Type double of variable that.width does not match with type int of variable that.colorBarLength
    13Expression that.width cannot be parameterized, because it has dependencies to/from statements that will be extracted
    14Expression that.colorBarLength cannot be parameterized, because it has dependencies to/from statements that will be extracted
    15Type double of variable that.width does not match with type int of variable that.colorBarLength
    16Type double of variable this.height does not match with type int of variable this.outerGap
    17Type double of variable that.height does not match with type int of variable that.outerGap
    18Expression that.height cannot be parameterized, because it has dependencies to/from statements that will be extracted
    19Expression that.outerGap cannot be parameterized, because it has dependencies to/from statements that will be extracted
    20Type double of variable that.height does not match with type int of variable that.outerGap
    21Expression ObjectUtilities.equal(this.drawable,that.drawable) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    22Expression this.colorPalette.equals(that.colorPalette) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    23The refactoring of the clones is infeasible, because classes org.jfree.chart.annotations.XYDrawableAnnotation and org.jfree.chart.axis.ColorBar do not have a common superclass