8000 Invalid generic import and Primitive import while field is required in constructor. · Issue #22 · aludwiko/fluentbuilder · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
< 8000 /div>

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
athlan opened this issue Jul 17, 2017 · 1 comment

Comments

@athlan
Copy link
Contributor
athlan commented Jul 17, 2017

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>;

@athlan
Copy link
Contributor Author
athlan commented Jul 19, 2017

In addition, if in constructor there is an argument which is a primitive type, it is also added to imports.

Issue occurs only while running code generation via Processor, on tests all seems to be ok. While running generator via Processor there is another entry point for creating Constructor Mirror.

I will prepare a patch.

@athlan athlan changed the title Invalid generic import while field is required in constructor Invalid generic import and Primitive import while field is required in constructor. Aug 3, 2017
aludwiko pushed a commit that referenced this issue Aug 9, 2017
…required in constructor. (#23)

* bump version to 1.1.0.patch-generic-constructor-SNAPSHOT

* Support for generic types in constrcutor. Support for primitive types in constrcutor.

* CR suggestions for PR #23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant
0