1 19 20 package org.netbeans.modules.projectimport.j2seimport; 21 import java.util.Collection ; 22 import java.util.Iterator ; 23 import java.util.LinkedHashSet ; 24 import java.util.LinkedList ; 25 import java.util.logging.Logger ; 26 27 31 public final class WarningContainer { 32 public static final WarningContainer EMPTY = new WarningContainer(); 33 private static final Logger logger = 34 LoggerFactory.getDefault().createLogger(WarningContainer.class); 35 36 37 private LinkedHashSet allWarnings = new LinkedHashSet (); 38 39 public boolean add(final String message, final boolean notifyUser) { 40 if (this == EMPTY) { 41 logger.warning("unexpected call on EMPTY WarningSupport "); return false; 43 } 44 return allWarnings.add(new WarningContainer.Warning(message, notifyUser)); 45 } 46 47 public boolean addAll(final WarningContainer toAdd) { 48 if (this == EMPTY) { 49 logger.warning("unexpected call on EMPTY WarningSupport "); return false; 51 } 52 53 return this.allWarnings.addAll(toAdd.allWarnings); 54 } 55 56 public boolean isEmpty() { 57 return allWarnings.isEmpty(); 58 } 59 60 public int size() { 61 return allWarnings.size(); 62 } 63 64 public Collection getAllWarnings() { 65 return new LinkedList (allWarnings); 66 } 67 68 public Iterator getIterator() { 69 return allWarnings.iterator(); 70 } 71 72 73 public static final class Warning { 74 private String message; 75 private boolean userNotification; 76 77 private Warning(final String message, final boolean notifyUser) { 78 this.message = message; 79 this.userNotification = notifyUser; 80 } 81 82 public String getMessage() { 83 return message; 84 } 85 86 public boolean isUserNotification() { 87 return userNotification; 88 } 89 90 91 public String toString() { 92 return getMessage(); 93 } 94 } 95 } 96 97 98 | Popular Tags |