package net.spanbroek.parsing;

public class RemainingInput {

    private String input;
    private int offset;

    public RemainingInput(String input) {
        this(input, 0);
    }

    public RemainingInput(String input, int offset) {
        this.input = input;
        this.offset = offset;
    }

    public boolean startsWith(String prefix) {
        int start = offset;
        int end = start + prefix.length();
        return end <= input.length() &&
                input.substring(start, end).equals(prefix);
    }

    public RemainingInput shift(int amountOfCharacters) {
        return new RemainingInput(input, offset + amountOfCharacters);
    }

    public int length() {
        return input.length() - offset;
    }

    public char firstCharacter() {
        return input.charAt(offset);
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        RemainingInput that = (RemainingInput) o;
        return offset == that.offset && input.equals(that.input);
    }

    @Override
    public int hashCode() {
        return 31 * input.hashCode() + offset;
    }
}

@@ -859,17 +859,20 @@
 (Object 
-o
+that
 ) %7B%0A    
@@ -879,20 +879,23 @@
     
-if (
+return 
 this == 
 o) r
@@ -894,150 +894,81 @@
  == 
-o) return true;%0A        if (o == null %7C%7C getClass() != o.getClass()) return false;%0A%0A        RemainingInput that = (RemainingInput) o;%0A
+that %7C%7C%0A                that instanceof RemainingInput &&%0A       
         
 retu
@@ -963,22 +963,16 @@
         
-return
  offset 
@@ -973,21 +973,40 @@
 ffset ==
+ ((RemainingInput)
  that
+)
 .offset 
@@ -1011,26 +1011,61 @@
 t &&
- input.equals(
+%0A                input.equals(((RemainingInput) 
 that
+)
 .inp

simplify equals()