Question

I'm currently working with Java to write a program that does an EAI between two applications. One application comes with HL7, which I parse with HAPI. So I get a Java object structure. I want to transform this structure to my own structure that I want to use to generate XML files with JAXB after doing some other work.

In my opinion my current solution is not very nice, because the source code gets very complex:

public NaturalPerson convertPID(PID pid) {
    NaturalPerson person = new NaturalPerson();
    NameNaturalPerson personsname = new NameNaturalPerson();
    name.setFamilyName(pid.getPatientName().getFamilyName().getValue());
    ...
}

Which language is an appropiate Language to do such type mappings? (http://en.wikipedia.org/wiki/List_of_JVM_languages) I think Java is not the best language for doing that. I don't have much time for learning, so I need a language that is easy to learn and which has a low begin-of-learning-peek. I already have some experience in the functional languages Haskell and F#. First I thought Groovy would be a good language, but then I found other opinions that suggest Scala.

Which language would you suggest for doing such type mappings?

Was it helpful?

Solution

Did you look at Dozer? It is a Java library that recursively copies data from one Java object to another. There are several ways to configure the mapping:

  • XML
  • Java API providing a DSL
  • Java annotations

OTHER TIPS

Data in forms of Maps and Vectors handling are superbly handled on the JVM using Clojure

See all the core functions available and this SO Question on which tutorials are good to learn Clojure.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top