christian-schlichtherle
released this
30 Mar 00:04
·
4 commits
to main
since this release
This release adds code generation for dependency setters. This can be used in test code to inject mocks etc. The declared method for the resolution of the dependency in the module has to be annotated with @Cache
and a matching setter method must be declared, too. For example:
import bali.Module;
import java.util.Date;
@Module
interface MyModule {
@Cache(setter = "setDate")
Date getDate();
void setDate(Date value);
}
This will generate code to implement the getDate()
and setDate(Date)
methods in the companion interface MyModule$
and the companion class MyModule$$
.
If you omit the setter
attribute of the @Cache
annotation, then the setter method has the same name as the getter method:
import bali.Module;
import java.util.Date;
@Module
interface MyModule {
@Cache
Date date();
void date(Date value);
}