List of utility methods to do EnumSet Usage
T | nextEnum(T ce) next Enum EnumSet valList = EnumSet.allOf(ce.getClass()); int pLoc = ce.ordinal() + 1; if (pLoc >= valList.size()) { pLoc = 0; if (pLoc < 0 || pLoc >= valList.size()) { pLoc = 0; int pos = 0; for (Object g : valList) { if (pos == pLoc) { return (T) g; pos++; return null; |
Iterable | possibilities(Class possibilities EnumSet<ENUM> values = EnumSet.allOf(enumClass); List<String> result = new ArrayList<>(values.size()); for (ENUM value : values) { result.add(value.toString()); return result; |
T | rotateEnum(T ce, boolean backwards, EnumSet ValidOptions) rotate Enum do { if (backwards) { ce = prevEnum(ce); } else { ce = nextEnum(ce); } while (!ValidOptions.contains(ce)); return ce; ... |
EnumSet | setOnly(EnumSet set Only theSet.clear();
theSet.add(flag);
return theSet;
|
T | valueOfIgnoreCase(String text, Class find enum value ignoring case T result = null; for (T item : EnumSet.allOf(cls)) { if (item.name().equalsIgnoreCase(text)) { result = item; break; return result; ... |
T | valueOfOrNull(Class value Of Or Null if (name == null) return null; for (T enumValue : EnumSet.allOf(enumType)) { if (enumValue.toString().equals(name)) return enumValue; return null; |
T | valueOfOrNull(Class value Of Or Null if (name == null) { return null; for (T enumValue : EnumSet.allOf(enumType)) { if (checkCase) { if (enumValue.toString().equals(name)) { return enumValue; } else { if (enumValue.toString().equalsIgnoreCase(name)) { return enumValue; return null; |