public FilterChain create ( ) throws FilterConfigurationException { Preconditions . checkState ( filters != null , "list of filters must be set" ) ; Preconditions . checkState ( inputType != null , "inputType must be set" ) ; Preconditions . checkState ( outputType != null , "outputType must be set" ) ; Preconditions . checkState ( filters . size ( ) > 0 , "need at least one filter" ) ; validateFiltersList ( ) ; Iterator < Object > iterator = filters . iterator ( ) ; FilterChainElement firstInstance = getInstanceFromListElement ( iterator . next ( ) ) ; if ( ! firstInstance . getSupportedInputType ( ) . isAssignableFrom ( inputType ) || ! firstInstance . getSupportedOutputType ( ) . isAssignableFrom ( outputType ) ) { throw new FilterConfigurationException ( String . format ( "incompatible Filtertype (%s) should be (%s->%s) - is (%s->%s)" , firstInstance . getClass ( ) , inputType , outputType , firstInstance . getSupportedInputType ( ) , firstInstance . getSupportedOutputType ( ) ) ) ; } FilterChainElement current = firstInstance ; while ( iterator . hasNext ( ) ) { Object next = iterator . next ( ) ; FilterChainElement nextFilterElement = getInstanceFromListElement ( next ) ; if ( nextFilterElement == null ) { current . setNext ( ( FilterAction ) next ) ; break ; } current . setNext ( nextFilterElement ) ; current = nextFilterElement ; } return new FilterChain ( firstInstance ) ; }
The filters - list must be set . If the last - element is not set the last element of the filters - list will be used .