Package com.codereligion.hammock

Examples of com.codereligion.hammock.Functor


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

        final String defaultName = method.getSimpleName().toString();
        final ClosureName delegate = new ClosureName(defaultName);
        final ClosureName name = new ClosureName(annotation.name().isEmpty() ? defaultName : 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(box(typeElement.asType()), "input");
        }

        final ClosureBuilder builder;

        TypeMirror returnType = method.getReturnType();
       
        if (returnType.getKind() == TypeKind.BOOLEAN) {
            builder = new ClosureBuilder(input, delegate);
        } else {
            builder = new ClosureBuilder(input, delegate, new Name(box(returnType).toString()));
        }

        builder.withName(name);
        builder.withStatic(isStatic);
        builder.withGraceful(annotation.graceful());
        builder.withNullTo(annotation.nullTo());

        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 Functor annotation = method.getAnnotation(Functor.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.withGraceful(annotation.graceful());
        builder.withNullTo(annotation.nullTo());

        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 Functor annotation = method.getAnnotation(Functor.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.withGraceful(annotation.graceful());
        builder.withNullTo(annotation.nullTo());

        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 TypeElement typeElement = (TypeElement) element.getEnclosingElement();
        final Functor annotation = typeElement.getAnnotation(Functor.class);
        parse(element, storage, annotation == null ? null : new Configuration(annotation));
    }
View Full Code Here

    private void parse(Element element, Function<TypeElement, Type> storage, Configuration parent) {
        final ExecutableElement method = (ExecutableElement) element;
        final TypeElement typeElement = (TypeElement) method.getEnclosingElement();

        final Functor annotation = method.getAnnotation(Functor.class);
        final Configuration config = annotation == null ? parent : new Configuration(annotation).merge(parent);

        final String defaultName = method.getSimpleName().toString();
        final ClosureName delegate = new ClosureName(defaultName);
        final ClosureName name = new ClosureName(config.getName().or(defaultName));
View Full Code Here

TOP

Related Classes of com.codereligion.hammock.Functor

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.