package me.proxer.library.util;

import com.squareup.moshi.Json;
import lombok.experimental.UtilityClass;

import javax.annotation.Nullable;
import java.lang.reflect.Field;
import java.util.Iterator;

/**
 * Utility class for internal use.
 *
 * @author Ruben Gees
 */
@UtilityClass
public class ProxerUtils {

    /**
     * Returns the name of the passed enum instance (Using that specified in the {@code @Json} annotation).
     */
    @Nullable
    public final String getApiEnumName(final Enum<?> it) {
        try {
            return it.getDeclaringClass().getField(it.name()).getAnnotation(Json.class).name();
        } catch (NoSuchFieldException ignored) {
            return null;
        }
    }

    /**
     * Converts the passed {@code value} string to an instance of the passed enum {@code type}.
     * <p>
     * If the conversion is not possible, because the passed string was invalid, null is returned.
     * If an invalid enum type is passed (one that is not in this library), an exception is thrown.
     */
    @Nullable
    public final <T extends Enum<T>> T toApiEnum(final Class<T> type, final String value) {
        for (final Field field : type.getFields()) {
            if (field.getAnnotation(Json.class).name().equals(value)) {
                return Enum.valueOf(type, field.getName());
            }
        }

        return null;
    }

    /**
     * Joins an Iterator with a given delimiter to a {@link String} and returns the result.
     * <p>
     * The Iterator can have any type, toString is called on the individual items.
     */
    public final String join(final String delimiter, final Iterable<?> iterable) {
        final Iterator<?> iterator = iterable.iterator();

        if (!iterator.hasNext()) {
            return "";
        }

        final StringBuilder builder = new StringBuilder().append(iterator.next());

        while (iterator.hasNext()) {
            builder.append(delimiter).append(iterator.next());
        }

        return builder.toString();
    }
}

@@ -420,32 +420,114 @@
 ation).%0A     */%0A
+    @SuppressWarnings(%22checkstyle:designforextension%22) // Lombok makes it static.%0A
     @Nullable%0A  
@@ -531,30 +531,24 @@
 %0A    public 
-final 
 String getAp
@@ -1096,24 +1096,106 @@
 wn.%0A     */%0A
+    @SuppressWarnings(%22checkstyle:designforextension%22) // Lombok makes it static.%0A
     @Nullabl
@@ -1207,22 +1207,16 @@
  public 
-final 
 %3CT exten
@@ -1730,20 +1730,96 @@
     
+@SuppressWarnings(%22checkstyle:designforextension%22) // Lombok makes it static.%0A    
 public
- final
  Str

Fix lint warnings