private CharSequence generateEnumLookupMethod(final List<Token> tokens, final String enumName, final String nullVal)
    {
        final StringBuilder sb = new StringBuilder();
        final PrimitiveType primitiveType = tokens.get(0).encoding().primitiveType();

        sb.append("\n")
            .append("    /**\n")
            .append("     * Lookup the enum value representing the value.\n")
            .append("     *\n")
            .append("     * @param value encoded to be looked up.\n")
            .append("     * @return the enum value representing the value.\n")
            .append("     */\n")
            .append("    public static ").append(enumName)
            .append(" get(final ").append(javaTypeName(primitiveType)).append(" value)\n").append("    {\n")
            .append("        switch (value)\n").append("        {\n");

        for (final Token token : tokens)
        {
            final String constStr = token.encoding().constValue().toString();
            final String name = formatForJavaKeyword(token.name());
            sb.append("            case ").append(constStr).append(": return ").append(name).append(";\n");
        }

        sb.append("            case ").append(nullVal).append(": return NULL_VAL").append(";\n");

        final String handleUnknownLogic = shouldDecodeUnknownEnumValues ?
            INDENT + INDENT + "return SBE_UNKNOWN;\n" :
            INDENT + INDENT + "throw new IllegalArgumentException(\"Unknown value: \" + value);\n";

        sb.append("        }\n\n")
            .append(handleUnknownLogic)
            .append("    }\n");

        return sb;
    }
\n" +
            "     * The raw encoded value in the Java type representation.\n" +
            "     *\n" +
            "     * @return the raw value encoded.\n" +
            "
sbe-tool/src/main/java/uk/co/real_logic/sbe/generation/java/JavaGenerator.java