-
Notifications
You must be signed in to change notification settings - Fork 101
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
Custom getters inside builder #464
Comments
This is not currently supported. FWIW, I don't think this is the right ownership for this behaviour. The |
Ah right, I see. And I have a List with a getter and a getter with a class parameter (generics) to get the parts with that class. Sadly I can't create getters with a parameter. How can I do that? |
That's also not supported I'm afraid! I'm not sure how that would work tbh. How would the value depend on the type? Wouldn't it be the other way around? Perhaps you could paste a code snippet of how you would implement it by hand. |
abstract class Part {}
class Wheel extends Part {}
class Seat extends Part {} And then: class Vehicle {
List<Part> parts;
public <V> V getPart(@NotNull Class<V> partClass) {
return parts.stream().filter(partClass::isInstance).map(partClass::cast).findFirst().orElse(null);
}
} |
That's very bespoke, I can't imagine this being used enough to put into a code generator. It might be a use-case for issue #14 if that ever gets implemented. |
I have a class like this:
How can I get the getType() function inside the generated builder too? I won't like to define it twice.
The text was updated successfully, but these errors were encountered: