/** * Like now(), but throws NotFoundException instead of returning null. * @throws NotFoundException if the loaded value was not found */ public final T safe() throws NotFoundException { T t = now(); if (t == null) throw new NotFoundException(key); else return t; } }
/** * Obtain the entity value, throwing an exception if the entity was not found. * * @return the entity referenced. Never returns null. * @throws NotFoundException if the specified entity was not found */ final public T safe() throws NotFoundException { T t = this.get(); if (t == null) throw new NotFoundException(key()); else return t; }
@Override protected T wrap(T t) throws Exception { if (t != null) return t; else throw new NotFoundException(key); } };