package net.shadowfacts.cacao.util /** * @author shadowfacts */ object EnumHelper { fun > next(value: E): E { val constants = value.declaringClass.enumConstants val index = constants.indexOf(value) + 1 return if (index < constants.size) constants[index] else constants.first() } fun > previous(value: E): E { val constants = value.declaringClass.enumConstants val index = constants.indexOf(value) - 1 return if (index >= 0) constants[index] else constants.last() } }