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 core library for Active Objects. It is generic and can be embedded in any environment. As such it is generic and won't contain all connection pooling, etc.

The 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 - 2025 Weber Informatics LLC | Privacy Policy