Here you can find the source of findAllArgumentPermutations(Object[][] allArguments)
Parameter | Description |
---|---|
caller | a parameter |
method | a parameter |
allArguments | a parameter |
offset | a parameter |
arguments | a parameter |
public static List<Object[]> findAllArgumentPermutations(Object[][] allArguments)
//package com.java2s; /******************************************************************************* * Copyright Searchbox - http://www.searchbox.com * /*from w ww . j av a2s.co m*/ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. ******************************************************************************/ import java.util.ArrayList; import java.util.List; public class Main { /** * Permute all possible parameters * * @param caller * @param method * @param allArguments * @param offset * @param arguments */ public static List<Object[]> findAllArgumentPermutations(Object[][] allArguments) { return findAllArgumentPermutations(allArguments, 0, 0, new Object[allArguments.length], new ArrayList<Object[]>()); } public static List<Object[]> findAllArgumentPermutations(Object[][] allArguments, int depth, int offset, Object[] arguments, List<Object[]> results) { if (depth < allArguments.length) { for (int i = offset; i < allArguments[depth].length; i++) { arguments[depth] = allArguments[depth][i]; // we got a bag here... if ((depth + 1) == arguments.length) { results.add(arguments.clone()); } findAllArgumentPermutations(allArguments, depth + 1, offset, arguments, results); } } return results; } }