Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- for (Document document : List<Document> documents) {
- if (!fileIsPresent(document)) {
- doSomethingWithThisResult("File is not present");
- continue;
- }
- if (!isSomethingInTheDocumentPresent(document)) {
- doSomethingWithThisResult("Something is not in the document");
- continue;
- }
- doSomethingWithTheSucces();
- }
- for (Document document : List<Document> documents) {
- try {
- fileIsPresent(document);
- isSomethingInTheDocumentPresent(document);
- doSomethingWithTheSucces();
- } catch (ProcessingException e) {
- doSomethingWithTheExceptionalCase(e.getMessage());
- }
- }
- public boolean fileIsPresent(Document document) throws ProcessingException {
- ... throw new ProcessingException("File is not present");
- }
- public boolean isSomethingInTheDocumentPresent(Document document) throws ProcessingException {
- ... throw new ProcessingException("Something is not in the document");
- }
- for (Document document : List<Document> documents) {
- if(checkDocument(document)) {
- doSomethingWithTheSucces();
- } else {
- doSomethingWithTheError();
- }
- }
- // Later:
- public boolean checkDocument(Document doc) { ... }
- for (Document document : List<Document> documents) {
- try {
- checkDocument(document);
- doSomethingWithTheSucces();
- } catch(CheckDocumentException ex) {
- doSomethingWithTheError(ex);
- }
- }
- // Later:
- public void checkDocument(Document doc) throws CheckDocumentException { ... }
Add Comment
Please, Sign In to add comment