transmorph 1.0.0 released : Another Object Conversion Framework

Discussions

News: transmorph 1.0.0 released : Another Object Conversion Framework

  1. Transmorph is a new free java library (Apache 2 License) used to convert a Java object of one type into an object of another type (with another signature, possibly parameterized). Transmorph strong points are : * support conversion for primitives and objects * support conversion to multidimensional arrays * support conversion to parameterized collections and types * jars for JDK 1.4 and JDK 1.5 * no dependencies * easy to add more converters * can convert to a type given either its java type (Class) or signature Once configured, you can do the following conversions, for example : // int[] to a List List listOfInts = (List) converter.convert(new int[] { 0, 1, 2, 3, 4, 5 }, List.class, new Class[] { Integer.class }); // Map<string,string[]> to a Map Map> converted = (Map>) converter.convert(map, "Ljava/util/Map;>;"); // int[] => LinkedList (ArrayToListConverter) LinkedList linkedList = (LinkedList) converter.convert( new int[] { 0, 1, 2, 3, 4, 5 }, LinkedList.class, new Class[] { Integer.class }); // int[][] => String[][] (ArrayToArrayConverter) int[][] arrayOfArrayOfInts = new int[][] { { 11, 12, 13 }, { 21, 22, 23 }, { 31 } }; String[][] arrayOfArrayOfStrings = (String[][]) converter.convert(arrayOfArrayOfInts, (new String[0][0]).getClass()); </string,string[]> See some more samples
  2. So it a Dozer-like tool ?[ Go to top ]

    It sounds to be a dozer challenger. How is it different from Dozer ? What are the pros and cons ?
  3. Re: So it a Dozer-like tool ?[ Go to top ]

    It sounds to be a dozer challenger.

    How is it different from Dozer ?
    What are the pros and cons ?
    Definitely two pros are that it's intuitive and the resulting code is extremely readable. It's also will increase your LOC over the naive solution and therefore your productivity. I can't see any cons to this at all.
  4. Re: So it a Dozer-like tool ?[ Go to top ]

    Transmorph is quite different from dozer. You will use dozer to convert from a bean to another bean (typically to create a data transfer object). If it is what you want to do, Dozer will probably be a better choice than transmorph. Transmorph is more generic and will be used to convert from any object to any other object (if corresponding converters exist and have been configured). Bean To Bean is only one of the many cases. There is not even yet a generic BeanToBean converter in Transmorph (although there will be a BeanToBean converter in next version that will be released soon).
  5. wow looks like fun
  6. Solution looking for a problem[ Go to top ]

    Solution looking for a problem conversion as verbose as explicit conversion does no justify adding dependency to code on such lib