196-2-4

Hour result; 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; } } return result;
Minute result; if (this.minute != FIRST_MINUTE_IN_HOUR) { result = new Minute(this.minute - 1, getHour()); } else { Hour h = (Hour) getHour().previous(); if (h != null) { result = new Minute(LAST_MINUTE_IN_HOUR, h); } 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 next()` |  | Method name: `RegularTimePeriod previous()`
Number of AST nodes: 8 |  | Number of AST nodes: 8

1

    Hour result;↵

1

    Minute result;↵

2

            if (this.hour != LAST_HOUR_IN_DAY) {↵

2

            if (this.minute != FIRST_MINUTE_IN_HOUR) {↵

3

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

3

                result = new ↵

4

            }↵

5

            else { // we are at the last hour in the day...↵

6

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

4

    Minute(this.minute - 1, getHour());↵

5

            }↵

6

            else {↵

7

    ();↵

7

                Hour h = (Hour) getHour().previous();↵

8

                if (nextDay != null) {↵

8

                if (h != null) {↵

9

                    result = new Hour(FIRST_HOUR_IN_DAY, nextDay);↵

9

                    result = new Minute(LAST_MINUTE_IN_HOUR, h);↵

10

                }↵

10

                }↵

11

                else {↵

11

                else {↵

12

                    result = null;↵

12

                    result = null;↵

13

                }↵

13

                }↵

14

            }↵

14

            }↵

15

            return result;

15

            return result;

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 in different classes having the same super class
Number of node comparisons | 22

1. {Non-refactorable}

   Mapping Summary
   Number of mapped statements | 7
   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) | 2.8
   Clone type | Type 2

   Mapped Statements
   ID | Statement |  | ID | Statement
   --- | --- | --- | --- | ---

   1

       Hour result;

   1 | Hour result;
   1 | Minute result;

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   org.jfree.data.time.Hour | org.jfree.data.time.Minute | SUBCLASS_TYPE_MISMATCH
   org.jfree.data.time.Hour | org.jfree.data.time.Minute | SUBCLASS_TYPE_MISMATCH

   1

       Minute result;

   2

       if (this.hour != LAST_HOUR_IN_DAY)

   2 | if (this.hour != LAST_HOUR_IN_DAY)
   2 | if (this.minute != FIRST_MINUTE_IN_HOUR)

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   hour | minute | VARIABLE_NAME_MISMATCH
   LAST_HOUR_IN_DAY | FIRST_MINUTE_IN_HOUR | VARIABLE_NAME_MISMATCH

   2

       if (this.minute != FIRST_MINUTE_IN_HOUR)

   3 | result = new Minute(this.minute - 1, getHour());

   Preondition Violations
   Unmatched statement result=new Minute(this.minute - 1,getHour()); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted

   3

       result = new Minute(this.minute - 1, getHour());

   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 or after the extracted code, because it has dependencies to/from statements that will be extracted

       else

       else

   4

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

   4 | Day nextDay = (Day)this.day.next();
   4 | Hour h = (Hour)getHour().previous();

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   org.jfree.data.time.Day | org.jfree.data.time.Hour | SUBCLASS_TYPE_MISMATCH
   nextDay | h | VARIABLE_NAME_MISMATCH
   org.jfree.data.time.Day | org.jfree.data.time.Hour | SUBCLASS_TYPE_MISMATCH
   org.jfree.data.time.Day | org.jfree.data.time.Hour | SUBCLASS_TYPE_MISMATCH
   next | previous | METHOD_INVOCATION_NAME_MISMATCH
   this.day | getHour() | TYPE_COMPATIBLE_REPLACEMENT

   4

       Hour h = (Hour)getHour().previous();

   5

       if (nextDay != null)

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

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   nextDay | h | VARIABLE_NAME_MISMATCH
   org.jfree.data.time.Day | org.jfree.data.time.Hour | SUBCLASS_TYPE_MISMATCH

   5

       if (h != null)

   6

       result = new Hour(FIRST_HOUR_IN_DAY, nextDay);

   6 | result = new Hour(FIRST_HOUR_IN_DAY, nextDay);
   6 | result = new Minute(LAST_MINUTE_IN_HOUR, h);

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   org.jfree.data.time.Hour | org.jfree.data.time.Minute | SUBCLASS_TYPE_MISMATCH
   org.jfree.data.time.Hour | org.jfree.data.time.Minute | SUBCLASS_TYPE_MISMATCH
   FIRST_HOUR_IN_DAY | LAST_MINUTE_IN_HOUR | VARIABLE_NAME_MISMATCH
   nextDay | h | VARIABLE_NAME_MISMATCH
   org.jfree.data.time.Day | org.jfree.data.time.Hour | SUBCLASS_TYPE_MISMATCH

   Preondition Violations
   Expression new Hour(FIRST_HOUR_IN_DAY,nextDay) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   Expression new Minute(LAST_MINUTE_IN_HOUR,h) cannot be parameterized, because it has dependencies to/from statements that will be extracted

   6

       result = new Minute(LAST_MINUTE_IN_HOUR, h);

       else

       else

   7

       result = null;

   7 | result = null;
   7 | result = null;

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   org.jfree.data.time.Hour | org.jfree.data.time.Minute | SUBCLASS_TYPE_MISMATCH

   7

       result = null;

   8

       return result;

   8 | return result;
   8 | return result;

   Differences
   Expression1 | Expression2 | Difference
   --- | --- | ---
   org.jfree.data.time.Hour | org.jfree.data.time.Minute | SUBCLASS_TYPE_MISMATCH

   8

       return result;

   Precondition Violations (5)
   Row | Violation
   --- | ---
   1 | Unmatched statement result=new Minute(this.minute - 1,getHour()); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
   2 | Unmatched statement result=new Hour(this.hour + 1,this.day); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
   3 | Expression new Hour(FIRST_HOUR_IN_DAY,nextDay) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   4 | Expression new Minute(LAST_MINUTE_IN_HOUR,h) cannot be parameterized, because it has dependencies to/from statements that will be extracted
   5 | Clone fragment #1 returns variable result with type org.jfree.data.time.Hour , while Clone fragment #2 returns variable result with type org.jfree.data.time.Minute