public static <I> I fromId(Class<I> type, Integer id) {

        if (id == null) {
            return null;
        }

        I[] types = type.getEnumConstants();

        for (I t : types) {

            try {
                DBValue dbValue = type.getField(t.toString())
                    .getAnnotation(DBValue.class);

                if (dbValue.value() == id) {
                    return t;
                }

            } catch (Exception e) {
                // Error, so no found value - shit happens, assertion-error will follow
            }
        }

        throw new AssertionError("id-mapping '" + id + "' not found on '" + type + "'");
    }