All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.java.ao.util.EnumUtils Maven / Gradle / Ivy

Go to download

This is the full Active Objects library, if you don't know which one to use, you probably want this one.

There is a newer version: 6.1.1
Show newest version
package net.java.ao.util;

import com.google.common.collect.Iterables;

import java.lang.reflect.InvocationTargetException;

import static com.google.common.collect.Lists.newArrayList;

public final class EnumUtils {
    public static Iterable values(Class type) {
        try {
            return newArrayList((Enum[]) type.getMethod("values").invoke(null));
        } catch (IllegalArgumentException e) {
            throw new IllegalStateException(e);
        } catch (SecurityException e) {
            throw new IllegalStateException(e);
        } catch (IllegalAccessException e) {
            throw new IllegalStateException(e);
        } catch (InvocationTargetException e) {
            throw new IllegalStateException(e);
        } catch (NoSuchMethodException e) {
            throw new IllegalStateException(e);
        }
    }

    public static int size(Class type) {
        return Iterables.size(values(type));
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy