Created
February 3, 2017 20:04
-
-
Save genderquery/470a3267a08b926dc0153a9c5cb03253 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public interface EnumAdapter<EnumType, ReturnType> { | |
ReturnType getValue(EnumType enumType); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public enum ImageFormat { | |
DEFAULT, | |
PNG, | |
PNG8, | |
PNG24, | |
PNG32, | |
JPG, | |
BMP, | |
GIF, | |
TIFF, | |
EMF, | |
PS, | |
PDF, | |
SVG, | |
SVGZ, | |
UNKNOWN; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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