Skip to content

Instantly share code, notes, and snippets.

@azakordonets
Created July 2, 2015 10:15
Show Gist options
  • Select an option

  • Save azakordonets/6f2763725b8392efdae4 to your computer and use it in GitHub Desktop.

Select an option

Save azakordonets/6f2763725b8392efdae4 to your computer and use it in GitHub Desktop.
This allows you easily to get random element from your enum
public enum MimeType {
APPLICATION,
AUDIO,
IMAGE,
MESSAGE,
MODEL,
MULTIPART,
TEXT,
VIDEO;
public static MimeType getRandom() {
return values()[(int) (Math.random() * values().length)];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment