
package org.openspaces.memcached.protocol;

import java.util.Arrays;

/**
 */
public enum Op {
    GET, GETS, APPEND, PREPEND, DELETE, DECR,
    INCR, REPLACE, ADD, SET, CAS, STATS, VERSION,
    QUIT, FLUSH_ALL, VERBOSITY;

    private static byte[][] ops = new byte[Op.values().length][];

    static {
        for (int x = 0 ; x < Op.values().length; x++)
            ops[x] = Op.values()[x].toString().toLowerCase().getBytes();
    }

    public static Op findOp(byte[] cmd) {
        for (int x = 0 ; x < ops.length; x++) {
            if (Arrays.equals(cmd, ops[x])) return Op.values()[x];
        }
        return null;
    }
}