RegularTimePeriod result = null; if (this.millisecond != LAST_MILLISECOND_IN_SECOND) { result = new Millisecond(this.millisecond + 1, getSecond()); } else { Second next = (Second) getSecond().next(); if (next != null) { result = new Millisecond(FIRST_MILLISECOND_IN_SECOND, next); } } return result;
Second result = null; if (this.second != FIRST_SECOND_IN_MINUTE) { result = new Second(this.second - 1, getMinute()); } else { Minute previous = (Minute) getMinute().previous(); if (previous != null) { result = new Second(LAST_SECOND_IN_MINUTE, previous); } } return result;
Clone fragments detected by clone detection tool
File path: /jfreechart-1.0.10/src/org/jfree/data/time/Millisecond.java File path: /jfreechart-1.0.10/src/org/jfree/data/time/Second.java
Method name: RegularTimePeriod next() Method name: RegularTimePeriod previous()
Number of AST nodes: 7 Number of AST nodes: 7
1
RegularTimePeriod result = null;
1
Second result = null;
2
        if (this.millisecond != LAST_MILLISECOND_IN_SECOND) {
2
        if (this.second != FIRST_SECOND_IN_MINUTE) {
3
            result = new Millisecond(this.millisecond + 1, getSecond());
3
            result = new Second(this.second - 1, getMinute());
4
        }
4
        }
5
        else {
5
        else {
6
            Second next = (Second) getSecond().next();
6
            Minute previous = (Minute) getMinute().previous();
7
            if (next != null) {
7
            if (previous != null) {
8
                result = new Millisecond(FIRST_MILLISECOND_IN_SECOND, next);
8
                result = new Second(LAST_SECOND_IN_MINUTE, previous);
9
            }
9
            }
10
        }
10
        }
11
        return result;
11
        return result;
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.6
Clones locationClones are in different classes having the same super class
Number of node comparisons17
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements6
    Number of unmapped statements in the first code fragment1
    Number of unmapped statements in the second code fragment1
    Time elapsed for statement mapping (ms)17.1
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    1
    RegularTimePeriod result = null;
    1
    RegularTimePeriod result = null;
    1
    Second result = null;
    Differences
    Expression1Expression2Difference
    org.jfree.data.time.RegularTimePeriodorg.jfree.data.time.SecondSUBCLASS_TYPE_MISMATCH
    org.jfree.data.time.RegularTimePeriodorg.jfree.data.time.SecondSUBCLASS_TYPE_MISMATCH
    1
    Second result = null;
    2
    if (this.millisecond != LAST_MILLISECOND_IN_SECOND)
    2
    if (this.millisecond != LAST_MILLISECOND_IN_SECOND)
    2
    if (this.second != FIRST_SECOND_IN_MINUTE)
    Differences
    Expression1Expression2Difference
    millisecondsecondVARIABLE_NAME_MISMATCH
    intbyteVARIABLE_TYPE_MISMATCH
    LAST_MILLISECOND_IN_SECONDFIRST_SECOND_IN_MINUTEVARIABLE_NAME_MISMATCH
    Preondition Violations
    Type int of variable this.millisecond does not match with type byte of variable this.second
    2
    if (this.second != FIRST_SECOND_IN_MINUTE)
                                                                                                        
    3
    result = new Second(this.second - 1, getMinute());
    Preondition Violations
    Unmatched statement result=new Second(this.second - 1,getMinute()); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    Unmatched statement result=new Second(this.second - 1,getMinute()); 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
    3
    result = new Second(this.second - 1, getMinute());
    3
    result = new Millisecond(this.millisecond + 1, getSecond());
    3
    result = new Millisecond(this.millisecond + 1, getSecond());
    Preondition Violations
    Unmatched statement result=new Millisecond(this.millisecond + 1,getSecond()); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    Unmatched statement result=new Millisecond(this.millisecond + 1,getSecond()); 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
                                                                                                                            
    else
    else
    4
    Second next = (Second)getSecond().next();
    4
    Second next = (Second)getSecond().next();
    4
    Minute previous = (Minute)getMinute().previous();
    Differences
    Expression1Expression2Difference
    org.jfree.data.time.Secondorg.jfree.data.time.MinuteSUBCLASS_TYPE_MISMATCH
    nextpreviousVARIABLE_NAME_MISMATCH
    org.jfree.data.time.Secondorg.jfree.data.time.MinuteSUBCLASS_TYPE_MISMATCH
    org.jfree.data.time.Secondorg.jfree.data.time.MinuteSUBCLASS_TYPE_MISMATCH
    nextpreviousMETHOD_INVOCATION_NAME_MISMATCH
    getSecondgetMinuteMETHOD_INVOCATION_NAME_MISMATCH
    4
    Minute previous = (Minute)getMinute().previous();
    5
    if (next != null)
    5
    if (next != null)
    5
    if (previous != null)
    Differences
    Expression1Expression2Difference
    nextpreviousVARIABLE_NAME_MISMATCH
    org.jfree.data.time.Secondorg.jfree.data.time.MinuteSUBCLASS_TYPE_MISMATCH
    5
    if (previous != null)
    6
    result = new Millisecond(FIRST_MILLISECOND_IN_SECOND, next);
    6
    result = new Millisecond(FIRST_MILLISECOND_IN_SECOND, next);
    6
    result = new Second(LAST_SECOND_IN_MINUTE, previous);
    Differences
    Expression1Expression2Difference
    org.jfree.data.time.RegularTimePeriodorg.jfree.data.time.SecondSUBCLASS_TYPE_MISMATCH
    org.jfree.data.time.Millisecondorg.jfree.data.time.SecondSUBCLASS_TYPE_MISMATCH
    FIRST_MILLISECOND_IN_SECONDLAST_SECOND_IN_MINUTEVARIABLE_NAME_MISMATCH
    nextpreviousVARIABLE_NAME_MISMATCH
    org.jfree.data.time.Secondorg.jfree.data.time.MinuteSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression new Millisecond(FIRST_MILLISECOND_IN_SECOND,next) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression new Second(LAST_SECOND_IN_MINUTE,previous) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    6
    result = new Second(LAST_SECOND_IN_MINUTE, previous);
    7
    return result;
    7
    return result;
    7
    return result;
    Differences
    Expression1Expression2Difference
    org.jfree.data.time.RegularTimePeriodorg.jfree.data.time.SecondSUBCLASS_TYPE_MISMATCH
    7
    return result;
    Precondition Violations (8)
    Row Violation
    1Type int of variable this.millisecond does not match with type byte of variable this.second
    2Unmatched statement result=new Second(this.second - 1,getMinute()); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    3Unmatched statement result=new Second(this.second - 1,getMinute()); 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
    4Unmatched statement result=new Millisecond(this.millisecond + 1,getSecond()); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    5Unmatched statement result=new Millisecond(this.millisecond + 1,getSecond()); 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
    6Expression new Millisecond(FIRST_MILLISECOND_IN_SECOND,next) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    7Expression new Second(LAST_SECOND_IN_MINUTE,previous) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    8Clone fragment #1 returns variable result with type org.jfree.data.time.RegularTimePeriod , while Clone fragment #2 returns variable result with type org.jfree.data.time.Second