Here you can find the source of nextEnum(T ce)
public static <T extends Enum> T nextEnum(T ce)
//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; } }