public Object getArray() { final Object array = makeArray(); int indexIntoTheArray = 0; final Collection<Integer> orderedIndexes = new TreeSet<Integer>(parametersByIndex.indexes()); for (final int indexOfTheParameters : orderedIndexes) { final Parameters parameters = parametersByIndex.at(indexOfTheParameters); Array.set(array, indexIntoTheArray++, instantiateArrayElement(parameters)); } return array; }
private Object makeArray() { final int arrayLength = parametersByIndex.count(); return Array.newInstance(arrayTarget.arrayElementType(), arrayLength); }