Advertisement
Guest User

Untitled

a guest
Nov 17th, 2019
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.75 KB | None | 0 0
  1. public class ObjectNotFoundException extends RuntimeException {
  2.  
  3.     private static final long serialVersionUID = 1L;
  4.     private final List<String> messages = List.of();
  5.    
  6.     @Getter
  7.     private final String message;
  8.  
  9.     public ObjectNotFoundException(List<String> messages) {
  10.         super();
  11.         this.message = messages.stream().collect(Collectors.joining("\n"));
  12.     }
  13.  
  14.     public ObjectNotFoundException(String message) {
  15.         super();
  16.         this.message = message;
  17.     }
  18.  
  19.     public ObjectNotFoundException() {
  20.         super();
  21.         messages = Collections.emptyList();
  22.     }
  23.  
  24.     public static void notNull(Object o, String message) {
  25.         if (o == null) {
  26.             throw new ObjectNotFoundException(List.of(message));
  27.         }
  28.     }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement