if (obj == this) { return true; } if (!(obj instanceof PaintMap)) { return false; } PaintMap that = (PaintMap) obj; if (this.store.size() != that.store.size()) { return false; } Set keys = this.store.keySet(); Iterator iterator = keys.iterator(); while (iterator.hasNext()) { Comparable key = (Comparable) iterator.next(); Paint p1 = getPaint(key); Paint p2 = that.getPaint(key); if (!PaintUtilities.equal(p1, p2)) { return false; } } return true;
if (obj == this) { return true; } if (!(obj instanceof StrokeMap)) { return false; } StrokeMap that = (StrokeMap) obj; if (this.store.size() != that.store.size()) { return false; } Set keys = this.store.keySet(); Iterator iterator = keys.iterator(); while (iterator.hasNext()) { Comparable key = (Comparable) iterator.next(); Stroke s1 = getStroke(key); Stroke s2 = that.getStroke(key); if (!ObjectUtilities.equal(s1, s2)) { return false; } } return true;
Clone fragments detected by clone detection tool
File path: /jfreechart-1.0.10/src/org/jfree/chart/PaintMap.java File path: /jfreechart-1.0.10/src/org/jfree/chart/StrokeMap.java
Method name: boolean equals(Object) Method name: boolean equals(Object)
Number of AST nodes: 16 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 PaintMap)) {
4
        if (!(obj instanceof StrokeMap)) {
5
            return false;
5
            return false;
6
        }
6
        }
7
        PaintMap that = (PaintMap) obj;
7
        StrokeMap that = (StrokeMap) obj;
8
        if (this.store.size() != that.store.size()) {
8
        if (this.store.size() != that.store.size()) {
9
            return false;
9
            return false;
10
        }
10
        }
11
        Set keys = this.store.keySet();
11
        Set keys = this.store.keySet();
12
        Iterator iterator = keys.iterator();
12
        Iterator iterator = keys.iterator();
13
        while (iterator.hasNext()) {
13
        while (iterator.hasNext()) {
14
            Comparable key = (Comparable) iterator.next();
14
            Comparable key = (Comparable) iterator.next();
15
            Paint p1 = getPaint(key);
15
            Stroke s1 = getStroke(key);
16
            Paint p2 = that.getPaint(key);
16
            Stroke s2 = that.getStroke(key);
17
            if (!PaintUtilities.equal(p1, p2)) {
17
            if (!ObjectUtilities.equal(s1, s2)) {
18
                return false;
18
                return false;
19
            }
19
            }
20
        }
20
        }
21
        return true;
21
        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)0.7
Clones locationClones are in different classes
Number of node comparisons46
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements13
    Number of unmapped statements in the first code fragment3
    Number of unmapped statements in the second code fragment3
    Time elapsed for statement mapping (ms)22.7
    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 (!(obj instanceof PaintMap))
    3
    if (!(obj instanceof PaintMap))
    3
    if (!(obj instanceof StrokeMap))
    Differences
    Expression1Expression2Difference
    org.jfree.chart.PaintMaporg.jfree.chart.StrokeMapVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type org.jfree.chart.PaintMap does not match with type org.jfree.chart.StrokeMap
    • Make classes org.jfree.chart.PaintMap and org.jfree.chart.StrokeMap extend a common superclass
    3
    if (!(obj instanceof StrokeMap))
    4
    return false;
    4
    return false;
                                                                      
    5
    StrokeMap that = (StrokeMap)obj;
    5
    PaintMap that = (PaintMap)obj;
                                                                  
    6
    if (this.store.size() != that.store.size())
    6
    if (this.store.size() != that.store.size())
    6
    if (this.store.size() != that.store.size())
    Differences
    Expression1Expression2Difference
    org.jfree.chart.PaintMaporg.jfree.chart.StrokeMapVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type java.util.Map of variable that.store does not match with type java.util.Map of variable that.store
    • Make classes org.jfree.chart.PaintMap and org.jfree.chart.StrokeMap extend a common superclass
    6
    if (this.store.size() != that.store.size())
    7
    return false;
    7
    return false;
    8
    Set keys = this.store.keySet();
    8
    Set keys = this.store.keySet();
    9
    Iterator iterator = keys.iterator();
    9
    Iterator iterator = keys.iterator();
    10
    while (iterator.hasNext())
    10
    while (iterator.hasNext())
    11
    Comparable key = (Comparable)iterator.next();
    11
    Comparable key = (Comparable)iterator.next();
                                                              
    12
    Stroke s1 = getStroke(key);
    Preondition Violations
    Unmatched statement Stroke s1=getStroke(key); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    Unmatched statement Stroke s1=getStroke(key); cannot be moved before or after the extracted code, because it throws exception(s) that should be caught by a try block that will be extracted
    12
    Stroke s1 = getStroke(key);
    12
    Paint p1 = getPaint(key);
    12
    Paint p1 = getPaint(key);
    Preondition Violations
    Unmatched statement Paint p1=getPaint(key); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    Unmatched statement Paint p1=getPaint(key); cannot be moved before or after the extracted code, because it throws exception(s) that should be caught by a try block that will be extracted
                                                          
                                                                        
    13
    Stroke s2 = that.getStroke(key);
    Preondition Violations
    Unmatched statement Stroke s2=that.getStroke(key); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    Unmatched statement Stroke s2=that.getStroke(key); cannot be moved before or after the extracted code, because it throws exception(s) that should be caught by a try block that will be extracted
    13
    Stroke s2 = that.getStroke(key);
    13
    Paint p2 = that.getPaint(key);
    13
    Paint p2 = that.getPaint(key);
    Preondition Violations
    Unmatched statement Paint p2=that.getPaint(key); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    Unmatched statement Paint p2=that.getPaint(key); cannot be moved before or after the extracted code, because it throws exception(s) that should be caught by a try block that will be extracted
                                                                    
    14
    if (!PaintUtilities.equal(p1, p2))
    14
    if (!PaintUtilities.equal(p1, p2))
    14
    if (!ObjectUtilities.equal(s1, s2))
    Differences
    Expression1Expression2Difference
    p1s1VARIABLE_NAME_MISMATCH
    java.awt.Paintjava.awt.StrokeVARIABLE_TYPE_MISMATCH
    p2s2VARIABLE_NAME_MISMATCH
    java.awt.Paintjava.awt.StrokeVARIABLE_TYPE_MISMATCH
    org.jfree.util.PaintUtilitiesorg.jfree.util.ObjectUtilitiesVARIABLE_TYPE_MISMATCH
    Preondition Violations
    Type java.awt.Paint of variable p1 does not match with type java.awt.Stroke of variable s1
    • Make classes java.awt.Paint and java.awt.Stroke extend a common superclass
    Type java.awt.Paint of variable p2 does not match with type java.awt.Stroke of variable s2
    • Make classes java.awt.Paint and java.awt.Stroke extend a common superclass
    Type org.jfree.util.PaintUtilities does not match with type org.jfree.util.ObjectUtilities
    • Make classes org.jfree.util.PaintUtilities and org.jfree.util.ObjectUtilities extend a common superclass
    14
    if (!ObjectUtilities.equal(s1, s2))
    15
    return false;
    15
    return false;
    16
    return true;
    16
    return true;
    Precondition Violations (13)
    Row Violation
    1Type org.jfree.chart.PaintMap does not match with type org.jfree.chart.StrokeMap
    2Type java.util.Map of variable that.store does not match with type java.util.Map of variable that.store
    3Unmatched statement Stroke s1=getStroke(key); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    4Unmatched statement Stroke s1=getStroke(key); cannot be moved before or after the extracted code, because it throws exception(s) that should be caught by a try block that will be extracted
    5Unmatched statement Paint p1=getPaint(key); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    6Unmatched statement Paint p1=getPaint(key); cannot be moved before or after the extracted code, because it throws exception(s) that should be caught by a try block that will be extracted
    7Unmatched statement Stroke s2=that.getStroke(key); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    8Unmatched statement Stroke s2=that.getStroke(key); cannot be moved before or after the extracted code, because it throws exception(s) that should be caught by a try block that will be extracted
    9Unmatched statement Paint p2=that.getPaint(key); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    10Unmatched statement Paint p2=that.getPaint(key); cannot be moved before or after the extracted code, because it throws exception(s) that should be caught by a try block that will be extracted
    11Type java.awt.Paint of variable p1 does not match with type java.awt.Stroke of variable s1
    12Type java.awt.Paint of variable p2 does not match with type java.awt.Stroke of variable s2
    13Type org.jfree.util.PaintUtilities does not match with type org.jfree.util.ObjectUtilities