package stexfires.io.internal;

/**
 * @author Mathias Kalb
 * @since 0.1
 */
enum WritableConsumerState {
    OPEN,
    WRITE_BEFORE,
    WRITE_RECORDS,
    WRITE_AFTER,
    CLOSE;

    public static void validateStates(WritableConsumerState currentState, WritableConsumerState newState) throws IllegalStateException {
        if (currentState.ordinal() + 1 != newState.ordinal()) {
            if (currentState != WRITE_RECORDS || newState != WRITE_RECORDS) {
                throw new IllegalStateException("currentState = " + currentState);
            }
        }
    }

    public void validateNotClosed() throws IllegalStateException {
        if (this == CLOSE) {
            throw new IllegalStateException("CLOSE");
        }
    }

    public WritableConsumerState validate(WritableConsumerState currentState) throws IllegalStateException {
        validateStates(currentState, this);
        return this;
    }

}

@@ -384,32 +384,34 @@
 %0A            if 
+(!
 (currentState !=
@@ -404,25 +404,107 @@
 urrentState 
-!
+== WRITE_BEFORE && newState == WRITE_AFTER)%0A                    && !(currentState =
 = WRITE_RECO
@@ -511,10 +511,10 @@
 RDS 
-%7C%7C
+&&
  new
@@ -519,17 +519,17 @@
 ewState 
-!
+=
 = WRITE_
@@ -536,16 +536,17 @@
 RECORDS)
+)
  %7B%0A     

Fix validateStates