Java EnumSet Usage nextEnum(T ce)

Here you can find the source of nextEnum(T ce)

Description

next Enum

License

Open Source License

Declaration

public static <T extends Enum> T nextEnum(T ce) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.util.EnumSet;

public class Main {
    public static <T extends Enum> T nextEnum(T ce) {
        EnumSet valList = EnumSet.allOf(ce.getClass());

        int pLoc = ce.ordinal() + 1;
        if (pLoc >= valList.size()) {
            pLoc = 0;/* w  w w .  java 2  s .  c o  m*/
        }

        if (pLoc < 0 || pLoc >= valList.size()) {
            pLoc = 0;
        }

        int pos = 0;
        for (Object g : valList) {
            if (pos == pLoc) {
                return (T) g;
            }
            pos++;
        }

        return null;
    }
}

Related

  1. findEnumIgnoreCase(Class enumClass, String string, T defValue)
  2. getDataFromEnum(Class enumClass)
  3. getDataInEnumClass(String enumClassName)
  4. getEnumFromString(Class enumClass, String enumValue, boolean compareByValue)
  5. nativeLoadEnumDefaultValues(Class enumType)
  6. possibilities(Class enumClass)
  7. rotateEnum(T ce, boolean backwards, EnumSet ValidOptions)
  8. setOnly(EnumSet theSet, E flag)
  9. valueOfIgnoreCase(String text, Class cls)