}
final List<? extends VariableElement> parameters = method.getParameters();
final boolean isStatic = method.getModifiers().contains(Modifier.STATIC);
final Argument input;
if (isStatic) {
input = findInput(parameters);
} else {
input = new Argument(typeElement, "input");
}
final ClosureBuilder builder;
if (method.getReturnType().getKind() == TypeKind.BOOLEAN) {
builder = new ClosureBuilder(input, delegate);
} else {
final Name returnType = new Name(method.getReturnType().toString());
builder = new ClosureBuilder(input, delegate, returnType);
}
builder.withName(name);
builder.withStatic(isStatic);
builder.withNullsafe(annotation.nullsafe());
if (isStatic) {
builder.withDelegate(typeElement.getSimpleName().toString());
for (VariableElement parameter : parameters) {
final boolean isInput = parameter.getAnnotation(Input.class) != null;
final boolean isOnlyParameter = parameters.size() == 1;
builder.withArgument(new Argument(parameter, isInput || isOnlyParameter));
}
} else {
for (VariableElement parameter : parameters) {
builder.withArgument(new Argument(parameter));
}
}
final Closure closure = builder.build();