1115-1-2

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

            }

See real code fragment |  | See real code fragment

Summary
Number of common nesting structure subtrees | 1
Number of refactorable cases | 0
Number of non-refactorable cases | 1
Time elapsed for finding largest common nesting structure subtrees (ms) | 0.2
Clones location | Clones are declared in the same class
Number of node comparisons | 18

1. {Non-refactorable}

   Mapping Summary
   Number of mapped statements | 5
   Number of unmapped statements in the first code fragment | 1
   Number of unmapped statements in the second code fragment | 1
   Time elapsed for statement mapping (ms) | 1.0
   Clone type | Type 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
   Expression1 | Expression2 | Difference
   --- | --- | ---
   FIRST_HOUR_IN_DAY | LAST_HOUR_IN_DAY | VARIABLE_NAME_MISMATCH

   2

       if (this.hour != LAST_HOUR_IN_DAY)

   3 | result = new Hour(this.hour + 1, this.day);

   Preondition Violations
   Unmatched statement result=new Hour(this.hour + 1,this.day); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted

   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);

   Preondition Violations
   Unmatched statement result=new Hour(this.hour - 1,this.day); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted

       else

       else

   4

       Day prevDay = (Day)this.day.previous();

   4 | Day prevDay = (Day)this.day.previous();
   4 | Day nextDay = (Day)this.day.next();

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   prevDay | nextDay | VARIABLE_NAME_MISMATCH
   previous | next | METHOD_INVOCATION_NAME_MISMATCH

   4

       Day nextDay = (Day)this.day.next();

   5

       if (prevDay != null)

   5 | if (prevDay != null)
   5 | if (nextDay != null)

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   prevDay | nextDay | VARIABLE_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
   Expression1 | Expression2 | Difference
   --- | --- | ---
   LAST_HOUR_IN_DAY | FIRST_HOUR_IN_DAY | VARIABLE_NAME_MISMATCH
   prevDay | nextDay | VARIABLE_NAME_MISMATCH

   6

       result = new Hour(FIRST_HOUR_IN_DAY, nextDay);

       else

       else

   7

       result = null;

   7

       result = null;

   Precondition Violations (2)
   Row | Violation
   --- | ---
   1 | Unmatched statement result=new Hour(this.hour + 1,this.day); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted
   2 | Unmatched statement result=new Hour(this.hour - 1,this.day); cannot be moved before the extracted code, because it has control dependencies from statements that will be extracted