src/edu/kit/informatik/literatur_system/CommandHandler.java
/**
     * Finds the command associated to the input.
     * Throws exception if there is ambiguity
     * @param string the CLI input
     * @return a possible match for the command typed in the CLI
     * @throws IllegalStateException if the given command is ambiguous to other
     */
Finds the command associated to the input.
Throws exception if there is ambiguity
@param string the CLI input
@return a possible match for the command typed in the CLI
@throws IllegalStateException if the given command is ambiguous to other
Finds the command associated to the input . Throws exception if there is ambiguity @param string the CLI input @return a possible match for the command typed in the CLI @throws IllegalStateException if the given command is ambiguous to other
private Optional<ICommand<T>> find(final String string) {
        return commands()
                .filter(cmd -> cmd.pattern().matcher(string).matches())
                .reduce((l, r) -> { 
                    throw new IllegalStateException("ambiguous: '" + string + "'"); 
                });
    }
private Optional < ICommand < T > > find ( final String string ) { return commands ( ) . filter ( cmd -> cmd . pattern ( ) . matcher ( string ) . matches ( ) ) . reduce ( ( l , r ) -> { throw new IllegalStateException ( "ambiguous: '" + string + "'" ) ; } ) ; }
Finds the command associated to the input.
Finds the command associated to the input .
// FIXME re factor into a single() extension method.  // The reduce API wasn't created for the used purpose