Git Product home page Git Product logo

fluentbuilder's People

Contributors

aludwiko avatar athlan avatar

Stargazers

 avatar  avatar

Watchers

 avatar

fluentbuilder's Issues

Unused imports

In some cases builder generates unused imports which does not comply CheckStyle policy:

import info.ludwikowski.fluentbuilder.common.AbstractBuilder;
import java.util.ArrayList;
import java.util.Arrays; <-- unused
import java.util.Date;
import java.util.List; <-- unused

Unused imports appears when one of attribute is ArrayList<T>

Invalid generic import and Primitive import while field is required in constructor.

There is a unexpected import while generic parameter is in constructor:

package com.example.model;

import java.util.List;

import info.ludwikowski.fluentbuilder.annotation.GenerateBuilder;

@GenerateBuilder
public class Foo {

    private String var1;
    private List<Bar> var2;

    public Foo(String var1, List<Bar> var2) {
        this.var1 = var1;
        this.var2 = var2;
    }

    public String getVar1() {
        return var1;
    }

    public List<Bar> getVar2() {
        return var2;
    }
}

And generic class definition:

package com.example.model;

public class Bar {

    private String var1;

    public Bar(String var1) {
        this.var1 = var1;
    }

    public String getVar1() {
        return var1;
    }
}

Invalid builder for Foo is generated:

package com.example.model;

import info.ludwikowski.fluentbuilder.common.AbstractBuilderFactory;
import java.util.List<com.example.model.Bar>;


/**
 * Fluent builder for Foo.
 * Don't hesitate to put your custom methods here.
 */
public abstract class FooBudowniczy extends AbstrakcyjnyFooBudowniczy<FooBudowniczy> {

	public static FooBudowniczy foo(String var1, List<Bar> var2){
		return AbstractBuilderFactory.createImplementation(FooBudowniczy.class, var1, var2);
	}
}

In import section the generic parameter is redundant:
import java.util.List<com.example.model.Bar>;

loggin

private void printBuilderPrinter(ClassMirror classMirror) {

    context.getProcessingEnvironment().getMessager().printMessage(Diagnostic.Kind.NOTE, "test");

    try {

        BuilderPrinter printer = new BuilderPrinter(context, classMirror);


        Filer filer = context.getProcessingEnvironment().getFiler();
        FileObject resource = null;
        try {
            context.getProcessingEnvironment().getMessager().printMessage(Diagnostic.Kind.NOTE, "test1");
            resource = filer.getResource(StandardLocation.SOURCE_OUTPUT,
                    printer.getPackageName(),
                    printer.builderName() + ".java");
            context.getProcessingEnvironment().getMessager().printMessage(Diagnostic.Kind.NOTE, "test2: " + resource.getLastModified());
        }
        catch (Exception e) {

            context.getProcessingEnvironment().getMessager().printMessage(Diagnostic.Kind.ERROR, "Problem with Filer: " + e.getMessage());

        }

        if (resourceNotExists(resource)) {

            context.getProcessingEnvironment().getMessager().printMessage(Diagnostic.Kind.NOTE, "test3");
            FileObject fo = context.getProcessingEnvironment().getFiler()
                    .createSourceFile(printer.getFullClassName());


            OutputStream os = fo.openOutputStream();
            PrintWriter pw = new PrintWriter(os);

            pw.print(printer.printClass());

            pw.flush();
            pw.close();
            context.getProcessingEnvironment().getMessager().printMessage(Diagnostic.Kind.NOTE, "test4");
        }

    } catch (IOException e) {
        context.getProcessingEnvironment().getMessager().printMessage(Diagnostic.Kind.ERROR, "Problem with Filer: " + e.getMessage());
    }
}

private boolean resourceNotExists(FileObject resource) {
    return resource == null || resource.getLastModified() <= 0;
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.