protected final String [ ] selectPermutations ( @ Nonnull final String baseUrl , @ Nonnull final String moduleName , @ Nonnull final List < BindingProperty > computedBindings ) throws ServletException { try { final List < SelectionDescriptor > descriptors = new ArrayList <> ( ) ; descriptors . addAll ( getPermutationDescriptors ( baseUrl , moduleName ) ) ; final List < BindingProperty > bindings = new ArrayList <> ( ) ; bindings . addAll ( computedBindings ) ; reduceToMatchingDescriptors ( bindings , descriptors ) ; if ( 0 == bindings . size ( ) ) { if ( 1 == descriptors . size ( ) ) { return new String [ ] { descriptors . get ( 0 ) . getPermutationName ( ) } ; } else { final ArrayList < String > permutations = new ArrayList <> ( ) ; for ( final SelectionDescriptor descriptor : descriptors ) { if ( descriptor . getBindingProperties ( ) . size ( ) == computedBindings . size ( ) ) { permutations . add ( descriptor . getPermutationName ( ) ) ; } else { for ( final BindingProperty property : descriptor . getBindingProperties ( ) ) { // This is one of the bindings that we could not reduce on if ( null == findMatchingBindingProperty ( computedBindings , property ) ) { if ( canMergeManifestForSelectionProperty ( property . getName ( ) ) ) { permutations . add ( descriptor . getPermutationName ( ) ) ; } } } } } if ( 0 == permutations . size ( ) ) { return null ; } else { return permutations . toArray ( new String [ permutations . size ( ) ] ) ; } } } return null ; } catch ( final Exception e ) { throw new ServletException ( "can not read permutation information" , e ) ; } }
Return an array of permutation names that are selected based on supplied properties .