public Method apply(ExecutableElement executableElement) { MethodBuilder methodBuilder = new MethodBuilder() .withModifiers(TypeUtils.modifiersToInt(executableElement.getModifiers())) .withName(executableElement.getSimpleName().toString()) .withReturnType(MIRROR_TO_TYPEREF.apply(executableElement.getReturnType())); //Populate constructor parameters for (VariableElement variableElement : executableElement.getParameters()) { methodBuilder = methodBuilder.addToArguments(PROPERTY.apply(variableElement)); List<ClassRef> exceptionRefs = new ArrayList<ClassRef>(); for (TypeMirror thrownType : executableElement.getThrownTypes()) { if (thrownType instanceof ClassRef) { exceptionRefs.add((ClassRef) thrownType); } } methodBuilder = methodBuilder.withExceptions(exceptionRefs); } List<ClassRef> annotationRefs = new ArrayList<ClassRef>(); for (AnnotationMirror annotationMirror : executableElement.getAnnotationMirrors()) { methodBuilder.withAnnotations(ANNOTATION_REF.apply(annotationMirror)); } return methodBuilder.build(); } };
.withVarArgPreferred(preferVarArg) .withReturnType(returnType) .withExceptions(exceptions) .withArguments(arguments) .withBlock(BLOCK.apply(methodDeclaration.getBody())) .withExceptions(exceptions) .withArguments(arguments) .withBlock(BLOCK.apply(constructorDeclaration.getBlock()))
public MethodBuilder(Method instance,Boolean validationEnabled){ this.fluent = this; this.withComments(instance.getComments()); this.withAnnotations(instance.getAnnotations()); this.withParameters(instance.getParameters()); this.withName(instance.getName()); this.withReturnType(instance.getReturnType()); this.withArguments(instance.getArguments()); this.withVarArgPreferred(instance.isVarArgPreferred()); this.withExceptions(instance.getExceptions()); this.withBlock(instance.getBlock()); this.withModifiers(instance.getModifiers()); this.withAttributes(instance.getAttributes()); this.validationEnabled = validationEnabled; }