@SuppressWarnings("unchecked")
    @Override
    public <T> T adapt(Class<T> adaptTarget) throws UnableToAdaptException {
        //if this is the top level adaptable container.. allow conversion to an interpreted one..
        if (adaptTarget.equals(InterpretedContainer.class) && isRoot() && getEnclosingContainer() == null) {
            return (T) new InterpretedContainerImpl(delegate, rootOverlay, factoryHolder);
        }
        //built in to adapt to entry..
        if (adaptTarget.equals(Entry.class)) {
            return (T) getEntryInEnclosingContainer();
        }
        // built in to adapt to Notifier
        if (adaptTarget.equals(Notifier.class)) {
            // Only return a new notifier if we're root
            if (this.isRoot()) {
                // Lazily create the notifier
                if (this.notifier == null) {
                    this.notifier = new NotifierImpl(delegate, this);
                }
                return (T) this.notifier;
            } else {
                return (T) this.getRoot().adapt(Notifier.class);
            }
        }
        //all other adapts go to the factory.
        T adapted = factoryHolder.getAdapterFactoryService().adapt(root, rootOverlay, delegate, this, adaptTarget);
        return adapted;
    }
@ SuppressWarnings ( "unchecked" ) @ Override public < T > T adapt ( Class < T > adaptTarget ) throws UnableToAdaptException { if ( adaptTarget . equals ( InterpretedContainer . class ) && isRoot ( ) && getEnclosingContainer ( ) == null ) { return ( T ) new InterpretedContainerImpl ( delegate , rootOverlay , factoryHolder ) ; } if ( adaptTarget . equals ( Entry . class ) ) { return ( T ) getEntryInEnclosingContainer ( ) ; } if ( adaptTarget . equals ( Notifier . class ) ) { if ( this . isRoot ( ) ) { if ( this . notifier == null ) { this . notifier = new NotifierImpl ( delegate , this ) ; } return ( T ) this . notifier ; } else { return ( T ) this . getRoot ( ) . adapt ( Notifier . class ) ; } } T adapted = factoryHolder . getAdapterFactoryService ( ) . adapt ( root , rootOverlay , delegate , this , adaptTarget ) ; return adapted ; }
{@inheritDoc}