What Design Pattern is separating transform converters

Posted by RevMoon on Programmers See other posts from Programmers or by RevMoon
Published on 2012-09-25T15:09:20Z Indexed on 2012/09/25 21:49 UTC
Read the original article Hit count: 193

Filed under:

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.

© Programmers or respective owner

Related posts about design-patterns