-
Notifications
You must be signed in to change notification settings - Fork 29
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
Adding an annotation to set default value #56
Comments
So something like?
|
Could be interesting to make automatter support something like this: @AutoMatter
public interface Room {
// default method called if value not set
default String id() {
return "foo";
}
} |
So if I understood correctly.
Automatter can search for default method with annotation for the property? |
@honnix I mean just make the |
See https://immutables.github.io/immutable.html#default-attributes Immutables btw is a great lib that already does all of this. Try it out =) |
That lib looks very capable! Yeah we don’t need a separated method. Having an annotation telling automatter that this is a property default method instead of any other user defined default method would still make sense I think. Otherwise it is implicit and there is an ambiguity. Kind of like @Value.Default |
👍 |
I'm currently working on this: @AutoMatter
interface DefaultValueExample {
// Normally auto-matter ignores default methods, so the @AutoMatter.Field
// annotation instructs it to treat the method as a default value provider.
@AutoMatter.Field
default String foo() {
return "foo";
}
@AutoMatter.Field
default int bar() {
return 17;
}
} |
Would something like this make sense?
The text was updated successfully, but these errors were encountered: