private static List getEnumValues()

in java/clickhouse-client/src/main/java/com/epam/deltix/clickhouse/util/ParseHelper.java [232:280]


    private static List<Enum8DataType.Enum8Value> getEnumValues(Class<?> clazz) {
        List<Enum8DataType.Enum8Value> values = new ArrayList<>();
        Object[] enumConstants = clazz.getEnumConstants();

        try {
            Method getNumberMethod = clazz.getDeclaredMethod(DEFAULT_ENUM_GET_NUMBER_METHOD);

            for (Object enumConstant : enumConstants) {
                byte byteValue;
                try {
                    byteValue = (byte) ((Integer) getNumberMethod.invoke(enumConstant)).intValue();
                } catch (IllegalAccessException | InvocationTargetException e) {
                    LOG.error()
                            .append("Error while access time to the method ")
                            .append(DEFAULT_ENUM_GET_NUMBER_METHOD)
                            .append('.')
                            .append(e)
                            .commit();
                    throw new IllegalStateException();
                }

                Enum8DataType.Enum8Value value = new Enum8DataType.Enum8Value(enumConstant.toString(), byteValue);

                values.add(value);
            }

            return values;
        } catch (NoSuchMethodException e) {
            // log level `debug` instead of `error`,
            // because there is no possibility to use the method "getNumber" in all enum classes now
            LOG.debug()
                    .append("Method ")
                    .append(DEFAULT_ENUM_GET_NUMBER_METHOD)
                    .append(" is not implemented in class ")
                    .append(clazz.getSimpleName())
                    .append('.')
                    .commit();
        }

        for (Object enumConstant : enumConstants) {
            byte byteValue = (byte) ((Enum) enumConstant).ordinal();

            Enum8DataType.Enum8Value value = new Enum8DataType.Enum8Value(enumConstant.toString(), byteValue);

            values.add(value);
        }

        return values;
    }