Package com.codereligion.hammock

Examples of com.codereligion.hammock.FirstClass


    @Override
    public void parse(Element element, Function<TypeElement, Type> storage) {
        final ExecutableElement method = (ExecutableElement) element;
        final TypeElement typeElement = (TypeElement) method.getEnclosingElement();
        final FirstClass annotation = method.getAnnotation(FirstClass.class);
        final ClosureName delegate = new ClosureName(method.getSimpleName().toString());;

        final ClosureName name;
       
        if (annotation.value().isEmpty()) {
            name = delegate;
        } else {
            name = new ClosureName(annotation.value());
        }
       
        final boolean isStatic = method.getModifiers().contains(Modifier.STATIC);

        final Name parameterType;

        if (isStatic) {
            final VariableElement firstParameter = method.getParameters().get(0);
            parameterType = new Name(firstParameter.asType().toString());
        } else {
            parameterType = new Name(typeElement.getQualifiedName().toString());
        }

        final Closure closure;

        if (method.getReturnType().getKind() == TypeKind.BOOLEAN) {
            closure = new Closure(name, delegate, parameterType, isStatic, annotation.nullsafe());
        } else {
            final Name returnType = new Name(method.getReturnType().toString());
            closure = new Closure(name, delegate, parameterType, returnType, isStatic, annotation.nullsafe());
        }

        final Type type = storage.apply(typeElement);
        Preconditions.checkNotNull(type, "No type found for %s", typeElement);
        type.getClosures().add(closure);
View Full Code Here


    @Override
    public void parse(Element element, Function<TypeElement, Type> storage) {
        final ExecutableElement method = (ExecutableElement) element;
        final TypeElement typeElement = (TypeElement) method.getEnclosingElement();
        final FirstClass annotation = method.getAnnotation(FirstClass.class);
        final ClosureName delegate = new ClosureName(method.getSimpleName().toString());;

        final ClosureName name;
       
        if (annotation.name().isEmpty()) {
            name = delegate;
        } else {
            name = new ClosureName(annotation.name());
        }

        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) {
View Full Code Here

    @Override
    public void parse(Element element, Function<TypeElement, Type> storage) {
        final ExecutableElement method = (ExecutableElement) element;
        final TypeElement typeElement = (TypeElement) method.getEnclosingElement();
        final FirstClass annotation = method.getAnnotation(FirstClass.class);
        final ClosureName delegate = new ClosureName(method.getSimpleName().toString());;

        final ClosureName name;
       
        if (annotation.name().isEmpty()) {
            name = delegate;
        } else {
            name = new ClosureName(annotation.name());
        }
       
        final boolean isStatic = method.getModifiers().contains(Modifier.STATIC);

        final Name parameterType;

        if (isStatic) {
            final VariableElement firstParameter = method.getParameters().get(0);
            parameterType = new Name(firstParameter.asType().toString());
        } else {
            parameterType = new Name(typeElement.getQualifiedName().toString());
        }

        final Closure closure;

        if (method.getReturnType().getKind() == TypeKind.BOOLEAN) {
            closure = new Closure(name, delegate, parameterType, isStatic, annotation.nullsafe());
        } else {
            final Name returnType = new Name(method.getReturnType().toString());
            closure = new Closure(name, delegate, parameterType, returnType, isStatic, annotation.nullsafe());
        }

        final Type type = storage.apply(typeElement);
        Preconditions.checkNotNull(type, "No type found for %s", typeElement);
        type.getClosures().add(closure);
View Full Code Here

TOP

Related Classes of com.codereligion.hammock.FirstClass

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.