Package buildable.annotation

Examples of buildable.annotation.BuiltWith


                                                Map<TypeElement, List<VariableElement>> buildableToFluentlyMap,
                                                RoundEnvironment roundEnvironment) {
        final List<? extends Element> enclosedElements = enclosingElement.getEnclosedElements();
        for (Element eachEnclosedElement : enclosedElements) {
            if (eachEnclosedElement.getKind().isField()) {
                final BuiltWith annotation = eachEnclosedElement.getAnnotation(BuiltWith.class);
                if (annotation != null) {
                    buildableToFluentlyMap.get(buildable).add((VariableElement) eachEnclosedElement);
                }
            }
        }
View Full Code Here


    }

    private void writeFluentElement(VariableElement field, String builderName, OutputStreamWriter out,
                                    final Set<? extends Element> buildables) throws Exception{

        final BuiltWith annotation = field.getAnnotation(BuiltWith.class);

        // determine the default value


        // write the field declaration
        if (field.asType().getKind().isPrimitive()) {
            // it's primitive, so let's not assign a default value...
            line(format("\tprivate %s %s;",
                    field.asType(),
                    field.getSimpleName().toString()),
                    out);
        } else {
            String defaultValue = determineDefaultValue(field, annotation);
            if (defaultValue.isEmpty()) {
                line(format("\tprivate %s %s;",
                        field.asType(),
                        field.getSimpleName().toString()),
                        out);
            } else {
                line(format("\tprivate %s %s = %s;",
                        field.asType(),
                        field.getSimpleName().toString(),
                        defaultValue),
                        out);
            }
        }

        String methodName = determineFluentMethodName(annotation, field);

        if (BuiltWith.USE_SENSIBLE_DEFAULT.equals(annotation.overrideArgType())){
            // write the fluent built-with method that takes in the instance of the field
            line(format("\tpublic %s %s(%s %s) {",
                    builderName, methodName,
                    field.asType(),
                    field.getSimpleName()),
                    out);
        } else {
            line(format("\tpublic %s %s(%s %s) {",
                    builderName, methodName,
                    annotation.overrideArgType(),
                    field.getSimpleName())
                    ,out);
        }
        if (annotation.overrideMethod() != BuiltWith.OverrideMethod.NULL) {
            switch (annotation.overrideMethod()) {
                case AddToList:
                    line(format("\t\tthis.%s = new %s;", field.getSimpleName(), annotation.overrideClassifer()),
                            out);
                    line(format("\t\tjava.util.Collections.addAll(this.%s, %s);", field.getSimpleName(),
                            field.getSimpleName()),
                            out);
            }
View Full Code Here

TOP

Related Classes of buildable.annotation.BuiltWith

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.