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
Generic wrapped object #13
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
processor/src/main/java/com/github/victornoel/eo/apt/GeneratedEnvelopeTypeSpec.java
Outdated
Show resolved
Hide resolved
Self-referencing interface would need a generic envelope
While non-generic will be bounded to |
@andreoss I have not forgotten about this PR :) |
@andreoss I'm not clear about the example you gave me above. Why can't you just write: class Impl implements Self<Impl> {}
class Wrap1<T extends Self<? extends T>> extends SelfEnvelope<T> {
public Wrap1(final Self<T> wrapped) {
super(wrapped);
}
}
class Wrap2<T extends Self<? extends T>> extends SelfEnvelope<T> {
public Wrap2(final Self<T> wrapped) {
super(wrapped);
}
}
final Self<Impl> env4 = new Wrap1(new Wrap2(new Wrap1(new Impl()))); It works perfectly well. By the way, I believe this kind of pattern is more usually wrote like this (without the interface Self<T extends Self<T>> {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@andreoss the main problem I see with this PR is the way we generate the new type parameter. We can't use any one and I find the code you propose a bit complex. I wonder if there are no available tooling in google auto common (that we already use here) or javapoet that can do that for us...
I have created an issue at javapoet asking about it: square/javapoet#793 |
@andreoss could you try using |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@andreoss one small change for good style :) thank a lot, this looks very nice!
processor/src/main/java/com/github/victornoel/eo/apt/GeneratedEnvelopeTypeSpec.java
Outdated
Show resolved
Hide resolved
2596449
to
f6c2a50
Compare
Closes #3