@@ -15,22 +15,7 @@ public static enum ChangeType {
1515 }
1616
1717 private ChangeType type ;
18- public final ChangeType getType () {
19- if (type == null ) {
20- if (insertedLength () == 0 ) {
21- if (removedLength () == 0 ) {
22- throw new IllegalStateException ("Cannot get the type of a change that neither inserts nor deletes anything." );
23- } else {
24- type = ChangeType .DELETION ;
25- }
26- } else if (removedLength () == 0 ) {
27- type = ChangeType .INSERTION ;
28- } else {
29- type = ChangeType .REPLACEMENT ;
30- }
31- }
32- return type ;
33- }
18+ public final ChangeType getType () { return type ; }
3419
3520 protected final int position ;
3621 protected final S removed ;
@@ -40,6 +25,18 @@ public TextChange(int position, S removed, S inserted) {
4025 this .position = position ;
4126 this .removed = removed ;
4227 this .inserted = inserted ;
28+
29+ if (insertedLength () == 0 ) {
30+ if (removedLength () == 0 ) {
31+ throw new IllegalStateException ("Cannot get the type of a change that neither inserts nor deletes anything." );
32+ } else {
33+ type = ChangeType .DELETION ;
34+ }
35+ } else if (removedLength () == 0 ) {
36+ type = ChangeType .INSERTION ;
37+ } else {
38+ type = ChangeType .REPLACEMENT ;
39+ }
4340 }
4441
4542 public int getPosition () { return position ; };
@@ -97,7 +94,7 @@ public final String toString() {
9794 return
9895 this .getClass ().getSimpleName () + "{\n " +
9996 "\t position: " + position + "\n " +
100- "\t type: " + getType () + "\n " +
97+ "\t type: " + type + "\n " +
10198 "\t removed: " + removed + "\n " +
10299 "\t inserted: " + inserted + "\n " +
103100 "}" ;
0 commit comments