Class DecoratingService<T_I extends Request,​T_O extends Response,​R_I extends Request,​R_O extends Response>

    • Constructor Detail

      • DecoratingService

        protected DecoratingService​(Service<T_I,​T_O> delegate)
        Creates a new instance that decorates the specified Service.
    • Method Detail

      • delegate

        protected final <T extends Service<T_I,​T_O>> T delegate()
        Returns the Service being decorated.
      • as

        public final <T> Optional<T> as​(Class<T> serviceType)
        Description copied from interface: Service
        Undecorates this Service to find the Service which is an instance of the specified serviceType. Use this method instead of an explicit downcast since most Services are decorated via Service.decorate(Function) and thus cannot be downcast. For example:
        
         Service s = new MyService().decorate(LoggingService.newDecorator())
                                    .decorate(AuthService.newDecorator());
         MyService s1 = s.as(MyService.class);
         LoggingService s2 = s.as(LoggingService.class);
         AuthService s3 = s.as(AuthService.class);
         
        Specified by:
        as in interface Service<T_I extends Request,​T_O extends Response>
        Parameters:
        serviceType - the type of the desired Service
        Returns:
        the Service which is an instance of serviceType if this Service decorated such a Service. Optional.empty() otherwise.
      • shouldCachePath

        public boolean shouldCachePath​(String path,
                                       @Nullable
                                       String query,
                                       PathMapping pathMapping)
        Description copied from interface: Service
        Returns whether the given path and query should be cached if the service's result is successful. By default, exact path mappings with no input query are cached.
        Specified by:
        shouldCachePath in interface Service<T_I extends Request,​T_O extends Response>