What Design Pattern is separating transform converters
- by RevMoon
For converting a Java object model into XML I am using the following design:
For different types of objects (e.g. primitive types, collections, null, etc.) I define each its own converter, which acts appropriate with respect to the given type. This way it can easily extended without adding code to a huge if-else-then construct.
The converters are chosen by a method which tests whether the object is convertable at all and by using a priority ordering. The priority ordering is important so let's say a List is not converted by the POJO converter, even though it is convertable as such it would be more appropriate to use the collection converter.
What design pattern is that?
I can only think of a similarity to the command pattern.