aludwiko / fluentbuilder Goto Github PK
View Code? Open in Web Editor NEWLicense: Other
License: Other
builders should be able to initialize inherited fields
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>
with flag disabling this functionality, for backward compatibility
otherwise processor is not working properly
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>;
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;
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.