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; } }
if (this.hour != LAST_HOUR_IN_DAY) { result = new Hour(this.hour + 1, this.day); } else { // we are at the last hour in the day... Day nextDay = (Day) this.day.next(); if (nextDay != null) { result = new Hour(FIRST_HOUR_IN_DAY, nextDay); } else { result = null; } }
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/Hour.java
Method name: RegularTimePeriod previous() Method name: RegularTimePeriod next()
Number of AST nodes: 6 Number of AST nodes: 6
1
if (this.hour != FIRST_HOUR_IN_DAY) {
1
if (this.hour != LAST_HOUR_IN_DAY) {
2
            result = new Hour(this.hour - 1, this.day);
2
            result = new Hour(this.hour + 1, this.day);
3
        }
3
        }
4
        else { // we are at the first hour in the day...
4
        else { // we are at the last hour in the day...
5
            Day prevDay = (Day) this.day.previous();
5
            Day nextDay = (Day) this.day.next();
6
            if (prevDay != null) {
6
            if (nextDay != null) {
7
                result = new Hour(LAST_HOUR_IN_DAY, prevDay);
7
                result = new Hour(FIRST_HOUR_IN_DAY, nextDay);
8
            }
8
            }
9
            else {
9
            else {
10
                result = null;
10
                result = null;
11
            }
11
            }
12
        }
12
        }
Summary
Number of common nesting structure subtrees1
Number of refactorable cases1
Number of non-refactorable cases0
Time elapsed for finding largest common nesting structure subtrees (ms)0.2
Clones locationClones are declared in the same class
Number of node comparisons18
  1. {Refactorable}
    Mapping Summary
    Number of mapped statements6
    Number of unmapped statements in the first code fragment0
    Number of unmapped statements in the second code fragment0
    Time elapsed for statement mapping (ms)6.5
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    2
    if (this.hour != FIRST_HOUR_IN_DAY)
    2
    if (this.hour != FIRST_HOUR_IN_DAY)
    2
    if (this.hour != LAST_HOUR_IN_DAY)
    Differences
    Expression1Expression2Difference
    FIRST_HOUR_IN_DAYLAST_HOUR_IN_DAYVARIABLE_NAME_MISMATCH
    2
    if (this.hour != LAST_HOUR_IN_DAY)
    3
    result = new Hour(this.hour - 1, this.day);
    3
    result = new Hour(this.hour - 1, this.day);
    3
    result = new Hour(this.hour + 1, this.day);
    Differences
    Expression1Expression2Difference
    -+OPERATOR_MISMATCH
    Preondition Violations
    Expression this.hour - 1 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
    3
    result = new Hour(this.hour + 1, this.day);
    else
    else
    4
    Day prevDay = (Day)this.day.previous();
    4
    Day prevDay = (Day)this.day.previous();
    4
    Day nextDay = (Day)this.day.next();
    Differences
    Expression1Expression2Difference
    prevDaynextDayVARIABLE_NAME_MISMATCH
    previousnextMETHOD_INVOCATION_NAME_MISMATCH
    4
    Day nextDay = (Day)this.day.next();
    5
    if (prevDay != null)
    5
    if (prevDay != null)
    5
    if (nextDay != null)
    Differences
    Expression1Expression2Difference
    prevDaynextDayVARIABLE_NAME_MISMATCH
    5
    if (nextDay != null)
    6
    result = new Hour(LAST_HOUR_IN_DAY, prevDay);
    6
    result = new Hour(LAST_HOUR_IN_DAY, prevDay);
    6
    result = new Hour(FIRST_HOUR_IN_DAY, nextDay);
    Differences
    Expression1Expression2Difference
    LAST_HOUR_IN_DAYFIRST_HOUR_IN_DAYVARIABLE_NAME_MISMATCH
    prevDaynextDayVARIABLE_NAME_MISMATCH
    6
    result = new Hour(FIRST_HOUR_IN_DAY, nextDay);
    else
    else
    7
    result = null;
    7
    result = null;
    Precondition Violations (2)
    Row Violation
    1Expression this.hour - 1 cannot be parameterized, because it has dependencies to/from statements that will be extracted
    2Expression this.hour + 1 cannot be parameterized, because it has dependencies to/from statements that will be extracted