if (obj == this) { return true; } if (!(obj instanceof LegendItemEntity)) { return false; } LegendItemEntity that = (LegendItemEntity) obj; if (!ObjectUtilities.equal(this.seriesKey, that.seriesKey)) { return false; } if (this.seriesIndex != that.seriesIndex) { return false; } if (!ObjectUtilities.equal(this.dataset, that.dataset)) { return false; } return super.equals(obj);
if (obj == this) { return true; } if (!(obj instanceof AbstractCategoryItemLabelGenerator)) { return false; } AbstractCategoryItemLabelGenerator that = (AbstractCategoryItemLabelGenerator) obj; if (!this.labelFormat.equals(that.labelFormat)) { return false; } if (!ObjectUtilities.equal(this.dateFormat, that.dateFormat)) { return false; } if (!ObjectUtilities.equal(this.numberFormat, that.numberFormat)) { return false; } return true;
Clone fragments detected by clone detection tool
File path: /jfreechart-1.0.10/src/org/jfree/chart/entity/LegendItemEntity.java File path: /jfreechart-1.0.10/src/org/jfree/chart/labels/AbstractCategoryItemLabelGenerator.java
Method name: boolean equals(Object) Method name: boolean equals(Object)
Number of AST nodes: 12 Number of AST nodes: 12
1
if (obj == this) {
1
if (obj == this) {
2
            return true;   
2
            return true;
3
        }
3
        }
4
        if (!(obj instanceof LegendItemEntity)) {
4
        if (!(obj instanceof AbstractCategoryItemLabelGenerator)) {
5
            return false;
5
            return false;
6
        }
6
        }
7
        LegendItemEntity that = (LegendItemEntity
7
        
8
        AbstractCategoryItemLabelGenerator that 
8
) obj;
9
            = (AbstractCategoryItemLabelGenerator) obj;
9
        if (!ObjectUtilities.equal(this.seriesKey, that.seriesKey)) {
10
        if (!this.labelFormat.equals(that.labelFormat)) {
10
            return false;
11
            return false;
11
        }
12
        }
12
        if (this.seriesIndex != that.seriesIndex) {
13
        if (!ObjectUtilities.equal(this.dateFormat, that.dateFormat)) {
13
            return false;   
14
            return false;
14
        }
15
        }
15
        if (!ObjectUtilities.equal(this.dataset, that.dataset)) {
16
        if (!ObjectUtilities.equal(this.numberFormat, that.numberFormat)) {
16
            return false;
17
            return false;
17
        }
18
        }
18
        return super.equals(obj);
19
        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)2.1
Clones locationClones are in different classes
Number of node comparisons47
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements9
    Number of unmapped statements in the first code fragment2
    Number of unmapped statements in the second code fragment0
    Time elapsed for statement mapping (ms)2.8
    Clone typeType 3
    Mapped Statements
    ID Statement ID Statement
    1
    if (obj == this)
    1
    if (obj == this)
    2
    return true;
    2
    return true;
    3
    if (!(obj instanceof LegendItemEntity))
    3
    if (!(obj instanceof LegendItemEntity))
    3
    if (!(obj instanceof AbstractCategoryItemLabelGenerator))
    Differences
    Expression1Expression2Difference
    org.jfree.chart.entity.LegendItemEntityorg.jfree.chart.labels.AbstractCategoryItemLabelGeneratorSUBCLASS_TYPE_MISMATCH
    3
    if (!(obj instanceof AbstractCategoryItemLabelGenerator))
    4
    return false;
    4
    return false;
    5
    LegendItemEntity that = (LegendItemEntity)obj;
    5
    LegendItemEntity that = (LegendItemEntity)obj;
    5
    AbstractCategoryItemLabelGenerator that = (AbstractCategoryItemLabelGenerator)obj;
    Differences
    Expression1Expression2Difference
    org.jfree.chart.entity.LegendItemEntityorg.jfree.chart.labels.AbstractCategoryItemLabelGeneratorSUBCLASS_TYPE_MISMATCH
    org.jfree.chart.entity.LegendItemEntityorg.jfree.chart.labels.AbstractCategoryItemLabelGeneratorSUBCLASS_TYPE_MISMATCH
    org.jfree.chart.entity.LegendItemEntityorg.jfree.chart.labels.AbstractCategoryItemLabelGeneratorSUBCLASS_TYPE_MISMATCH
    5
    AbstractCategoryItemLabelGenerator that = (AbstractCategoryItemLabelGenerator)obj;
    6
    if (!ObjectUtilities.equal(this.seriesKey, that.seriesKey))
    6
    if (!ObjectUtilities.equal(this.seriesKey, that.seriesKey))
    8
    if (!ObjectUtilities.equal(this.dateFormat, that.dateFormat))
    Differences
    Expression1Expression2Difference
    seriesKeydateFormatVARIABLE_NAME_MISMATCH
    java.lang.Comparablejava.text.DateFormatVARIABLE_TYPE_MISMATCH
    org.jfree.chart.entity.LegendItemEntityorg.jfree.chart.labels.AbstractCategoryItemLabelGeneratorSUBCLASS_TYPE_MISMATCH
    seriesKeydateFormatVARIABLE_NAME_MISMATCH
    java.lang.Comparablejava.text.DateFormatVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type java.lang.Comparable of variable this.seriesKey does not match with type java.text.DateFormat of variable this.dateFormat
    • Make classes java.lang.Comparable and java.text.DateFormat extend a common superclass
    Expression that.seriesKey cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression that.dateFormat cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Type java.lang.Comparable of variable that.seriesKey does not match with type java.text.DateFormat of variable that.dateFormat
    • Make classes java.lang.Comparable and java.text.DateFormat extend a common superclass
    8
    if (!ObjectUtilities.equal(this.dateFormat, that.dateFormat))
    7
    return false;
    9
    return false;
    8
    if (this.seriesIndex != that.seriesIndex)
    8
    if (this.seriesIndex != that.seriesIndex)
    Preondition Violations
    Unmatched statement if(this.seriesIndex != that.seriesIndex) cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                                                          
    9
    return false;
    9
    return false;
    Preondition Violations
    Unmatched return false;
                                    
    10
    if (!ObjectUtilities.equal(this.dataset, that.dataset))
    10
    if (!ObjectUtilities.equal(this.dataset, that.dataset))
    6
    if (!this.labelFormat.equals(that.labelFormat))
    Differences
    Expression1Expression2Difference
    ObjectUtilities.equal(this.dataset,that.dataset)this.labelFormat.equals(that.labelFormat)TYPE_COMPATIBLE_REPLACEMENT
    Preondition Violations
    Expression ObjectUtilities.equal(this.dataset,that.dataset) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression this.labelFormat.equals(that.labelFormat) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    6
    if (!this.labelFormat.equals(that.labelFormat))
    11
    return false;
    7
    return false;
    Precondition Violations (11)
    Row Violation
    1Type java.lang.Comparable of variable this.seriesKey does not match with type java.text.DateFormat of variable this.dateFormat
    2Expression that.seriesKey cannot be parameterized, because it has dependencies to/from statements that will be extracted
    3Expression that.dateFormat cannot be parameterized, because it has dependencies to/from statements that will be extracted
    4Type java.lang.Comparable of variable that.seriesKey does not match with type java.text.DateFormat of variable that.dateFormat
    5Unmatched statement if(this.seriesIndex != that.seriesIndex) cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    6Unmatched return false;
    7Expression ObjectUtilities.equal(this.dataset,that.dataset) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    8Expression this.labelFormat.equals(that.labelFormat) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    9Clone fragment #1 returns variable that with type org.jfree.chart.entity.LegendItemEntity , while Clone fragment #2 returns variable that with type org.jfree.chart.labels.AbstractCategoryItemLabelGenerator
    10Not all possible execution flows end in a return statement
    11The refactoring of the clones is infeasible, because classes org.jfree.chart.entity.LegendItemEntity and org.jfree.chart.labels.AbstractCategoryItemLabelGenerator do not have a common superclass