Here you can find the source of shiftEnum(E current, E[] values, int delta)
public static <E extends Enum> E shiftEnum(E current, E[] values, int delta)
//package com.java2s; //License from project: LGPL public class Main { public static <E extends Enum> E shiftEnum(E current, E[] values, int delta) { int next = current.ordinal() + delta; if (next < 0) { return values[(values.length - 1)]; }/*from w w w. j ava 2 s . co m*/ if (next >= values.length) { return values[0]; } return values[next]; } }