public static UploadedFileContentType getFileExtension(final String contentType) { for (UploadedFileContentType uploadedFileContentType : UploadedFileContentType.values()) { if (uploadedFileContentType.getContentType().equals(contentType)) { return uploadedFileContentType; } } throw new IllegalStateException("Unknown content type '" + contentType + "'"); }