/** * Returns the specified item if that item is not null; otherwise throws * not found exception. * * @param item item to check * @param message not found message * @param <T> item type * @return item if not null * @throws org.onlab.util.ItemNotFoundException if item is null */ public static <T> T nullIsNotFound(T item, String message) { if (item == null) { throw new ItemNotFoundException(message); } return item; }
/** * Returns the specified set if the set is not null and not empty; * otherwise throws a not found exception. * * @param item set to check * @param message not found message * @param <T> Set item type * @return item if not null and not empty * @throws org.onlab.util.ItemNotFoundException if set is null or empty */ public static <T> Set<T> emptyIsNotFound(Set<T> item, String message) { if (item == null || item.isEmpty()) { throw new ItemNotFoundException(message); } return item; }
@Override public Alarm updateBookkeepingFields(AlarmId id, boolean isAcknowledged, String assignedUser) { Alarm found = store.getAlarm(id); if (found == null) { throw new ItemNotFoundException("Alarm with id " + id + " found"); } Alarm updated = new DefaultAlarm.Builder(found) .withId(found.id()) .withAcknowledged(isAcknowledged) .withAssignedUser(assignedUser).build(); store.setAlarm(updated); return updated; }
log.info("onPortChainDeleted"); if (!nshSpiPortChainMap.containsKey(portChain.portChainId())) { throw new ItemNotFoundException("Unable to find NSH SPI");