@Test public void ignoreCaseForType() { DocumentType documentType = DocumentTypeResolver.documentTypeFromString("PdF"); assertEquals(documentType, DocumentType.PDF); documentType = DocumentTypeResolver.documentTypeFromString("PDF"); assertEquals(documentType, DocumentType.PDF); documentType = DocumentTypeResolver.documentTypeFromString("pdf"); assertEquals(documentType, DocumentType.PDF); }
public static DocumentType documentTypeFromString(String type) { Optional<DocumentType> documentType = stream(DocumentType.class.getEnumConstants()) .filter(dt -> dt.name().equalsIgnoreCase(type)) .findAny(); if (!documentType.isPresent()) { throw new UnsupportedTypeException("type = " + type + " is unsupported"); } return documentType.get(); }
DocumentTypeResolver { public static DocumentType documentTypeFromString(String type) { Optional<DocumentType> documentType = stream(DocumentType.class.getEnumConstants()) .filter(dt -> dt.name().equalsIgnoreCase(type)) .findAny(); if (!documentType.isPresent()) { throw new UnsupportedTypeException("type = " + type + " is unsupported"); } return documentType.get(); } }
DocumentTypeResolver { public static DocumentType documentTypeFromString(String type) { Optional<DocumentType> documentType = stream(DocumentType.class.getEnumConstants()) .filter(dt -> dt.name().equalsIgnoreCase(type)) .findAny(); if (!documentType.isPresent()) { throw new UnsupportedTypeException("type = " + type + " is unsupported"); } return documentType.get(); }  }
DocumentTypeResolver { public static DocumentType documentTypeFromString(String type) { Optional<DocumentType> documentType = stream(DocumentType.class.getEnumConstants()) .filter(dt -> dt.name().equalsIgnoreCase(type)) .findAny(); if (!documentType.isPresent()) { throw new UnsupportedTypeException("type = " + type + " is unsupported"); } return documentType.get(); }  static DocumentType documentTypeFromString(String type); }
DocumentTypeResolver { public static DocumentType documentTypeFromString(String type) { Optional<DocumentType> documentType = stream(DocumentType.class.getEnumConstants()) .filter(dt -> dt.name().equalsIgnoreCase(type)) .findAny(); if (!documentType.isPresent()) { throw new UnsupportedTypeException("type = " + type + " is unsupported"); } return documentType.get(); }  static DocumentType documentTypeFromString(String type);  }