Refactor Tag classes to avoid code duplication
tipsy opened this issue · comments
Currently ContainerTag and EmptyTag share the same 40 convenience methods, but they're manually included in each class. Attempts at refactoring this have been unsuccessful, as I can't seem to find a way to keep the type-information intact (this is important for the fluent-api chaining).
For example, if I move them to Tag (the abstract class they both extend), and do
div().withClass("class").withText()
, I run into problems, because withText()
should be available for ContainerTag objects, but not EmptyTag objects.
I'm sure there's a way though... any thoughts?
Hi!
I think I could refactor this situation using generics.
This weekend I'll work on this and I'll send you a PR to discuss.
Cool, looking forward to it!
Take a look on this commit and please tell me what do you think about it.
I'm glad to help you!