/******************************************************************************************************************* * * {@inheritDoc} * ******************************************************************************************************************/ @Override @Nonnull public final <T> T as (final @Nonnull Class<T> type) { return as(type, As.Defaults.throwAsException(type)); }
/******************************************************************************************************************* * * Creates a {@code GenericDecoratorNode} given the delegate node, a {@link Lookup} and (optional) extra arguments * (meaningful if your subclasses need them). The extra arguments are passed as they are to constructor of children nodes. * * @param delegate the delegate node * @param lookup the {@code Lookup} * @param extraArgs the optional extra arguments * ******************************************************************************************************************/ protected GenericDecoratorNode (final @Nonnull Node delegate, final @Nonnull Lookup lookup, final @Nonnull Object ... extraArgs) { super(delegate, createChildren(delegate, lookup, extraArgs), lookup); }
/******************************************************************************************************************* * * {@inheritDoc} * ******************************************************************************************************************/ @Override @Nonnull public <T> T as (final @Nonnull Class<T> type, final @Nonnull NotFoundBehaviour<T> notFoundBehaviour) { final T result = getLookup().lookup(type); return (result != null) ? result : notFoundBehaviour.run(new NotFoundException(type.getName())); }