public int getArgumentCount() { int count = 0; int variable = 1; for (Parameter<?> argument : args) { if (argument.getMinOccurs() != argument.getMaxOccurs()) { variable = -1; // flag for variable arguments } count += argument.getMinOccurs(); } return variable * count; }
if (arg.getMaxOccurs() == 1) { throw new IllegalArgumentException( String.format( } else { if (arg.getMaxOccurs() < 0 || arg.getMaxOccurs() > 1) { List l = new ArrayList(); l.add(o);
&& (lastArgument.getMaxOccurs() > 0 || lastArgument.getMaxOccurs() == -1)) { context = lastArgument.getType(); } else {
void check(Parameter p, String name, Class type, int min, int max) { assertEquals(name, p.getName()); assertEquals(type, p.getType()); assertEquals(min, p.getMinOccurs()); assertEquals(max, p.getMaxOccurs()); } }
/** * Validates the structure of arguments, basically enforcing java conventions for variable * level arguments. */ private void validateArguments() throws IllegalArgumentException { List<Parameter<?>> args = getFunctionName().getArguments(); for (int i = 0; i < args.size(); i++) { Parameter<?> arg = args.get(i); if (arg.getMaxOccurs() == 0) { throw new IllegalArgumentException(String.format("Argument %s has zero max")); } if (arg.getMinOccurs() != 1 || arg.getMaxOccurs() != 1) { //this can only happen for the last argument if (i != args.size()-1) { throw new IllegalArgumentException(String.format("Argument %s(%d,%d) invalid." + " Variable arguments must be the last argument of function.", arg.getName(), arg.getMinOccurs(), arg.getMaxOccurs())); } } } }
if (arg.getMaxOccurs() == 1) { throw new IllegalArgumentException(String.format("Multiple values specified for " + "argument %s but maxOccurs = 1", argName)); if (arg.getMaxOccurs() < 0 || arg.getMaxOccurs() > 1) { List l = new ArrayList(); l.add(o);
+ function.getArguments().get(index).getMinOccurs() + "\t" + function.getArguments().get(index).getMaxOccurs());
value.setMaxOccurences(parameter.getMaxOccurs());