Skip to content

Instantly share code, notes, and snippets.

@genderquery
Created February 3, 2017 20:04
Show Gist options
  • Save genderquery/470a3267a08b926dc0153a9c5cb03253 to your computer and use it in GitHub Desktop.
Save genderquery/470a3267a08b926dc0153a9c5cb03253 to your computer and use it in GitHub Desktop.
public interface EnumAdapter<EnumType, ReturnType> {
ReturnType getValue(EnumType enumType);
}
public enum ImageFormat {
DEFAULT,
PNG,
PNG8,
PNG24,
PNG32,
JPG,
BMP,
GIF,
TIFF,
EMF,
PS,
PDF,
SVG,
SVGZ,
UNKNOWN;
}
public class ImageFormatEnumAdapter implements EnumAdapter<ImageFormat, String> {
public String getValue(final ImageFormat imageFormat) {
switch (imageFormat) {
case DEFAULT: return "";
case PNG: return "png";
case PNG8: return "png8";
case PNG24: return "png24";
case PNG32: return "png32";
case JPG: return "jpg";
case BMP: return "bmp";
case GIF: return "gif";
case TIFF: return "tiff";
case EMF: return "emf";
case PS: return "ps";
case PDF: return "pdf";
case SVG: return "svg";
case SVGZ: return "svgz";
default: return null;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment