You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When making use of interfaces one might wish to add hooks to it that should be invoked by the subclasses.
An example is when setting default (initializeHook) and validating the builder (finalizeHook).
Currently one has to manually add the builders to the subclasses.
Is this a feature you are interested in?
@BuiltValue(instantiable:false)
abstractinterfaceclassTestInterface {
Stringget value;
@BuiltValueHook(initializeBuilder:true)
staticvoid_defaults(TestInterfaceBuilder b) {
b.value ='123';
}
@BuiltValueHook(finalizeBuilder:true)
staticvoid_validate(TestInterfaceBuilder b) {
if (b.value!.isEmpty) {
throwError();
}
}
}
abstractclassTestimplementsTestInterface, Built<Test, TestBuilder> {
factoryTest([voidFunction(TestBuilder)? b]) =_$SuperObject;
constTest._();
staticSerializer<Test> get serializer => _$superObjectSerializer;
@BuiltValueHook(initializeBuilder:true)
staticvoid_defaults(TestBuilder b) {
TestInterface._defaults(b);
}
@BuiltValueHook(finalizeBuilder:true)
staticvoid_validate(TestBuilder b) {
TestInterface._validate(b);
}
}
The text was updated successfully, but these errors were encountered:
Thanks for filing! Sorry for the slow response, I've been on vacation.
That does seem like it makes sense, unfortunately I suspect it's only landable as a breaking change or via extra configuring (inheritBuilders: true), neither of which is ideal.
I'll put it in the pile of possible changes for a closer look at some point, but I don't have a lot of bandwidth for built_value improvements so I suspect it will be a while before I get to it.
When making use of interfaces one might wish to add hooks to it that should be invoked by the subclasses.
An example is when setting default (initializeHook) and validating the builder (finalizeHook).
Currently one has to manually add the builders to the subclasses.
Is this a feature you are interested in?
The text was updated successfully, but these errors were encountered: