NodeType implements Serializable { public Class<?>[] getParameterTypes(int length) { Class<?>[] inputs = getInputs(); if (inputs == null || inputs.length == 0) { return new Class[0]; } int paramCount = 0; if(inputs[paramCount].isAssignableFrom(Parameters.class)){ paramCount++; } if(inputs[paramCount].isAssignableFrom(NodeParameters.class)){ paramCount++; } if(paramCount > 0){ Class[] newInputs = new Class[inputs.length - paramCount]; System.arraycopy(inputs, paramCount, newInputs, 0, newInputs.length); inputs = newInputs; } if (inputs[inputs.length - 1].isArray()) { if (length < inputs.length - 1) { return null; } else { Class[] result = new Class[length]; for (int i = 0; i < inputs.length - 1; ++i) { result[i] = inputs[i]; } for (int i = inputs.length - 1; i < result.length; ++i) { result[i] = inputs[inputs.length - 1].getComponentType(); } return result; } } else { if (length != inputs.length) { return null; } else { return inputs; } } } NodeType(Class<? extends BaseIterator> nodeClass); Class<? extends BaseIterator> getIteratorClass(); Class<?>[] getInputs(); Class<?>[] getParameterTypes(int length); boolean isIteratorOrArray(Class c); String toString();  }
@Test public void testGetParameterTypes() throws Exception { NodeType n = new NodeType(FakeIterator.class); Class[] input = n.getParameterTypes(4); assertEquals(4, input.length); assertEquals(ExtentIterator.class, input[0]); assertEquals(ScoreIterator.class, input[1]); assertEquals(ScoreIterator.class, input[2]); assertEquals(ScoreIterator.class, input[3]); }