Class DefaultInterceptorChain<OPERATION,RESULT,INTERCEPTOR_TYPE extends Interceptor>

java.lang.Object
dk.cloudcreate.essentials.shared.interceptor.DefaultInterceptorChain<OPERATION,RESULT,INTERCEPTOR_TYPE>
Type Parameters:
OPERATION - the type of operation to intercept, aka. the argument to the interceptor
RESULT - the result of the operation
All Implemented Interfaces:
InterceptorChain<OPERATION,RESULT,INTERCEPTOR_TYPE>

public final class DefaultInterceptorChain<OPERATION,RESULT,INTERCEPTOR_TYPE extends Interceptor> extends Object implements InterceptorChain<OPERATION,RESULT,INTERCEPTOR_TYPE>
Default implementation for the InterceptorChain. It's recommended to use InterceptorChain.newInterceptorChainForOperation(Object, List, BiFunction, Supplier) to create a new chain instance for a given operation
  • Constructor Details

  • Method Details

    • sortInterceptorsByOrder

      public static <INTERCEPTOR_TYPE> List<INTERCEPTOR_TYPE> sortInterceptorsByOrder(List<INTERCEPTOR_TYPE> interceptors)
      Order the interceptors according to the specified InterceptorOrder annotation (if the annotation is left out then the default order is 10)
      Type Parameters:
      INTERCEPTOR_TYPE - the type of interceptor contained in the list
      Parameters:
      interceptors - the list of interceptors that should be ordered (expects a mutable list that can be reordered)
      Returns:
      the interceptors parameter after it has been reordered
    • proceed

      public RESULT proceed()
      Description copied from interface: InterceptorChain
      To continue the processing a Interceptor will call this method, which in turn will call other Interceptor's (if more interceptors are configured) and finally the default implementation will be called.
      If the Interceptor can provide a result without calling the default behaviour then it can just return its (e.g. cached) result and not call InterceptorChain.proceed()
      Specified by:
      proceed in interface InterceptorChain<OPERATION,RESULT,INTERCEPTOR_TYPE extends Interceptor>
      Returns:
      the result of the operation
    • operation

      public OPERATION operation()
      Description copied from interface: InterceptorChain
      The operation details
      Specified by:
      operation in interface InterceptorChain<OPERATION,RESULT,INTERCEPTOR_TYPE extends Interceptor>
      Returns:
      the operation details
    • toString

      public String toString()
      Overrides:
      toString in class Object