package me.proxer.library.api;

import me.proxer.library.util.ProxerUtils;
import retrofit2.Converter;
import retrofit2.Retrofit;

import java.lang.annotation.Annotation;
import java.lang.reflect.Type;

/**
 * @author Ruben Gees
 */
final class EnumRetrofitConverterFactory extends Converter.Factory {

    @Override
    public Converter<?, String> stringConverter(final Type type, final Annotation[] annotations,
                                                final Retrofit retrofit) {
        if (((Class<?>) type).isEnum()) {
            return (Converter<Enum<?>, String>) value -> ProxerUtils.getApiEnumName(value);
        }

        return null;
    }
}

package me.proxer.library.api;

import me.proxer.library.util.ProxerUtils;
import retrofit2.Converter;
import retrofit2.Retrofit;

import java.lang.annotation.Annotation;
import java.lang.reflect.Type;

/**
 * @author Ruben Gees
 */
final class EnumRetrofitConverterFactory extends Converter.Factory {

    @Override
    public Converter<?, String> stringConverter(final Type type, final Annotation[] annotations,
                                                final Retrofit retrofit) {
        if (((Class<?>) type).isEnum()) {
            return (Converter<Enum<?>, String>) ProxerUtils::getApiEnumName;
        }

        return null;
    }
}

Revert "Try a lambda instead of a method reference for java 8 support"