Hour result; if (this.hour != FIRST_HOUR_IN_DAY) { result = new Hour(this.hour - 1, this.day); } else { // we are at the first hour in the day... Day prevDay = (Day) this.day.previous(); if (prevDay != null) { result = new Hour(LAST_HOUR_IN_DAY, prevDay); } else { result = null; } } return result;
Minute result; if (this.minute != LAST_MINUTE_IN_HOUR) { result = new Minute(this.minute + 1, getHour()); } else { // we are at the last minute in the hour... Hour nextHour = (Hour) getHour().next(); if (nextHour != null) { result = new Minute(FIRST_MINUTE_IN_HOUR, nextHour); } else { result = null; } } return result;
Clone fragments detected by clone detection tool
File path: /jfreechart-1.0.10/src/org/jfree/data/time/Hour.java File path: /jfreechart-1.0.10/src/org/jfree/data/time/Minute.java
Method name: RegularTimePeriod previous() Method name: RegularTimePeriod next()
Number of AST nodes: 8 Number of AST nodes: 8
1
Hour result;
1
Minute result;
2
        if (this.hour != FIRST_HOUR_IN_DAY) {
2
        if (this.minute != LAST_MINUTE_IN_HOUR) {
3
            result = new Hour(this.hour - 1, this.day);
3
            result = new Minute(this.minute + 1, getHour());
4
        }
4
        }
5
        else { // we are at the first hour in the day...
5
        else { // we are at the last minute in the hour...
6
            Day prevDay = (Day) this.day.previous();
6
            Hour nextHour = (Hour) getHour().next();
7
            if (prevDay != null) {
7
            if (nextHour != null) {
8
                result = new Hour(LAST_HOUR_IN_DAY, prevDay);
8
                result = new Minute(FIRST_MINUTE_IN_HOUR, nextHour);
9
            }
9
            }
10
            else {
10
            else {
11
                result = null;
11
                result = null;
12
            }
12
            }
13
        }
13
        }
14
        return result;
14
        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.4
Clones locationClones are in different classes having the same super class
Number of node comparisons22
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements8
    Number of unmapped statements in the first code fragment0
    Number of unmapped statements in the second code fragment0
    Time elapsed for statement mapping (ms)11.9
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    1
    Hour result;
    1
    Hour result;
    1
    Minute result;
    Differences
    Expression1Expression2Difference
    org.jfree.data.time.Hourorg.jfree.data.time.MinuteSUBCLASS_TYPE_MISMATCH
    org.jfree.data.time.Hourorg.jfree.data.time.MinuteSUBCLASS_TYPE_MISMATCH
    1
    Minute result;
    2
    if (this.hour != FIRST_HOUR_IN_DAY)
    2
    if (this.hour != FIRST_HOUR_IN_DAY)
    2
    if (this.minute != LAST_MINUTE_IN_HOUR)
    Differences
    Expression1Expression2Difference
    hourminuteVARIABLE_NAME_MISMATCH
    FIRST_HOUR_IN_DAYLAST_MINUTE_IN_HOURVARIABLE_NAME_MISMATCH
    2
    if (this.minute != LAST_MINUTE_IN_HOUR)
    3
    result = new Hour(this.hour - 1, this.day);
    3
    result = new Hour(this.hour - 1, this.day);
    3
    result = new Minute(this.minute + 1, getHour());
    Differences
    Expression1Expression2Difference
    org.jfree.data.time.Hourorg.jfree.data.time.MinuteSUBCLASS_TYPE_MISMATCH
    org.jfree.data.time.Hourorg.jfree.data.time.MinuteSUBCLASS_TYPE_MISMATCH
    hourminuteVARIABLE_NAME_MISMATCH
    -+OPERATOR_MISMATCH
    org.jfree.data.time.Dayorg.jfree.data.time.HourSUBCLASS_TYPE_MISMATCH
    this.daygetHour()TYPE_COMPATIBLE_REPLACEMENT
    Preondition Violations
    Expression new Hour(this.hour - 1,this.day) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression new Minute(this.minute + 1,getHour()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression this.hour - 1 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression this.minute + 1 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression getHour() is a method call throwing exception(s) that should be caught by a try block that will be extracted
    3
    result = new Minute(this.minute + 1, getHour());
    else
    else
    4
    Day prevDay = (Day)this.day.previous();
    4
    Day prevDay = (Day)this.day.previous();
    4
    Hour nextHour = (Hour)getHour().next();
    Differences
    Expression1Expression2Difference
    org.jfree.data.time.Dayorg.jfree.data.time.HourSUBCLASS_TYPE_MISMATCH
    prevDaynextHourVARIABLE_NAME_MISMATCH
    org.jfree.data.time.Dayorg.jfree.data.time.HourSUBCLASS_TYPE_MISMATCH
    org.jfree.data.time.Dayorg.jfree.data.time.HourSUBCLASS_TYPE_MISMATCH
    previousnextMETHOD_INVOCATION_NAME_MISMATCH
    org.jfree.data.time.Dayorg.jfree.data.time.HourSUBCLASS_TYPE_MISMATCH
    this.daygetHour()TYPE_COMPATIBLE_REPLACEMENT
    Preondition Violations
    Expression (Hour)getHour().next() is a method call throwing exception(s) that should be caught by a try block that will be extracted
    Expression getHour().next() is a method call throwing exception(s) that should be caught by a try block that will be extracted
    Expression getHour() is a method call throwing exception(s) that should be caught by a try block that will be extracted
    4
    Hour nextHour = (Hour)getHour().next();
    5
    if (prevDay != null)
    5
    if (prevDay != null)
    5
    if (nextHour != null)
    Differences
    Expression1Expression2Difference
    prevDaynextHourVARIABLE_NAME_MISMATCH
    org.jfree.data.time.Dayorg.jfree.data.time.HourSUBCLASS_TYPE_MISMATCH
    5
    if (nextHour != null)
    6
    result = new Hour(LAST_HOUR_IN_DAY, prevDay);
    6
    result = new Hour(LAST_HOUR_IN_DAY, prevDay);
    6
    result = new Minute(FIRST_MINUTE_IN_HOUR, nextHour);
    Differences
    Expression1Expression2Difference
    org.jfree.data.time.Hourorg.jfree.data.time.MinuteSUBCLASS_TYPE_MISMATCH
    org.jfree.data.time.Hourorg.jfree.data.time.MinuteSUBCLASS_TYPE_MISMATCH
    LAST_HOUR_IN_DAYFIRST_MINUTE_IN_HOURVARIABLE_NAME_MISMATCH
    prevDaynextHourVARIABLE_NAME_MISMATCH
    org.jfree.data.time.Dayorg.jfree.data.time.HourSUBCLASS_TYPE_MISMATCH
    Preondition Violations
    Expression new Hour(LAST_HOUR_IN_DAY,prevDay) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    Expression new Minute(FIRST_MINUTE_IN_HOUR,nextHour) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    6
    result = new Minute(FIRST_MINUTE_IN_HOUR, nextHour);
    else
    else
    7
    result = null;
    7
    result = null;
    7
    result = null;
    Differences
    Expression1Expression2Difference
    org.jfree.data.time.Hourorg.jfree.data.time.MinuteSUBCLASS_TYPE_MISMATCH
    7
    result = null;
    8
    return result;
    8
    return result;
    8
    return result;
    Differences
    Expression1Expression2Difference
    org.jfree.data.time.Hourorg.jfree.data.time.MinuteSUBCLASS_TYPE_MISMATCH
    8
    return result;
    Precondition Violations (10)
    Row Violation
    1Expression new Hour(this.hour - 1,this.day) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    2Expression new Minute(this.minute + 1,getHour()) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    3Expression this.hour - 1 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    4Expression this.minute + 1 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    5Expression getHour() is a method call throwing exception(s) that should be caught by a try block that will be extracted
    6Expression (Hour)getHour().next() is a method call throwing exception(s) that should be caught by a try block that will be extracted
    7Expression getHour().next() is a method call throwing exception(s) that should be caught by a try block that will be extracted
    8Expression getHour() is a method call throwing exception(s) that should be caught by a try block that will be extracted
    9Expression new Hour(LAST_HOUR_IN_DAY,prevDay) cannot be parameterized, because it has dependencies to/from statements that will be extracted
    10Expression new Minute(FIRST_MINUTE_IN_HOUR,nextHour) cannot be parameterized, because it has dependencies to/from statements that will be extracted