private static <T extends Enum<T>> T toEnum(int value, Class<T> enumType) {
        for (T t : ClickHouseChecker.nonNull(enumType, "enumType").getEnumConstants()) {
            if (t.ordinal() == value) {
                return t;
            }
        }

        throw new IllegalArgumentException(
                ClickHouseUtils.format("Enum [%s] does not contain value [%d]", enumType, value));
    }
Utility class for dealing with binary stream and data.
clickhouse-data/src/main/java/com/clickhouse/data/format/BinaryStreamUtils.java