Last modified: 2014-05-07 08:41:12 UTC
Formatters that generate plain text, wikitext, and html are not interchangable in the OOP sense. To fix this, all formatters should get marker interfaces that indicate what format they return, so calling code can require that specific interface to be implemented to make sure the formatter actually generate the kind of output that is expected in a given context.
Note that there is one difficulty here: format-agnostic wrappers would need to have one class per output type. E.g. a ConvertingQuantityFormatter that applies unit conversion and then formats the result using some other formatter would need one implementation for each possible output type, e.g. ConvertingQuantityWikitextFormatter, ConvertingQuantityHtmlFormatter, etc. These could be trivially derived from an (abstract) base class that implements the actual logic, by just adding the respective marker interfaces.