public interface Toolkit
For example, to compile a Project, ideally we would want to write:
Project p = new Project(); p.compile();But if
Project
does not already define a compile()
method and if it is not
sub-classable or has a blackbox implementation, this would not be possible. Even if Project
did include a compile()
method, downstream extensions may want to change the how
'compile' works, but this is not possible without sub-classing Project
or having
it expose integration hooks.
Instead a Compilable
toolkit can be defined as:
public interface Compilable extends Toolkit { void compile(); }Now given a
Project
, a Compilable
can be 'built' for it.
Context context = new Context(project); Compilable compilabe = ToolkitRegistry.getToolkit(context, Compilable.class); compilable.compile();Extensions can plug in a
ToolkitProvider
and change how Compilable
works for Projects
.