@Override
    public void writeI32(int i32) throws TException {
        writeCurrentContext();

        if (!useNamedEnums) {
            writeNameOrValue(TypedParser.INTEGER, i32);
            return;
        }

        final Class<?> fieldClass = getCurrentFieldClassIfIs(TEnum.class);
        if (fieldClass == null) {
            writeNameOrValue(TypedParser.INTEGER, i32);
            return;
        }

        try {
            final Method method = fieldClass.getMethod("findByValue", int.class);
            final String str = method.invoke(null, i32).toString();
            writeNameOrValue(TypedParser.STRING, str);
        } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
            throw new TTransportException("invalid value for enum field " +
                                          fieldClass.getSimpleName() + ':' + i32);
        }
    }
Helper shared by write{List/Set}End.
thrift/thrift0.13/src/main/java/com/linecorp/armeria/common/thrift/text/TTextProtocol.java