Skip to content

Instantly share code, notes, and snippets.

@PierreBtz
Created June 15, 2015 15:51
Show Gist options
  • Save PierreBtz/b5d813066b899e783acd to your computer and use it in GitHub Desktop.
Save PierreBtz/b5d813066b899e783acd to your computer and use it in GitHub Desktop.
private static <T extends Enum<T>, U extends Enum<U>> T fromTypeEnumToTypeEnum(U originValue, Class<T> destinationEnumClass) {
for(final T t : destinationEnumClass.getEnumConstants()) {
if(t.name().equals(originValue.name())) {
return t;
}
}
throw new UnsupportedOperationException("Translation was not implemented for " + originValue);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment