for (int i = 0; i < methodArgs.length; i++) {
boolean isLastArg = i == (methodArgs.length - 1);
final Class<?> cls = methodArgs[i];
AnnotationMap annotations = new AnnotationMap(argsAnnotations[i]);
boolean isLuaArg = false;
Arg tmp = annotations.get(Arg.class);
if (tmp != null) {
isOptional = checkOptional(isOptional, annotations);
ArgumentBuilder builder = new ArgumentBuilder();
builder.setVararg(isLastArg && isVarArg);
builder.setOptional(isOptional);
builder.setNullable(tmp.isNullable());
luaArgs.add(createLuaArg(builder, annotations, cls, i));
isLuaArg = true;
isInLuaArgs = true;
}
Preconditions.checkState(!isInLuaArgs || isLuaArg, "Argument %s in method %s look like Java arg, but is in Lua part (perhaps missing Arg annotation?)", i, method);
Named named = annotations.get(Named.class);
if (named != null) {
Preconditions.checkState(!isInLuaArgs, "Argument %s in method %s is Lua arg, but has Named annotation", i, method);
namedArgs.put(named.value(), i);
}
Preconditions.checkState(isInLuaArgs || annotations.get(Optionals.class) == null, "@Optionals does not work for java arguments (method %s)", method);
if (!isLuaArg) javaArgs.add(cls);
}
this.luaArgs = luaArgs.build();