So, I have many XSD files defining a health-related specifications. They come from here. https://www.hl7.org/fhir/downloads.html
I generate some Java POJO using JAXB, in eclipse but it would be the same from the command line with the xic command.
The problem I have got is that it created 700+ classes including some for the very basic java type.
Instead of linking with the java.lang.String
class, it would create a new org.hl7.fhir.String
class instead.
that class would have a "value" field with a normal String
in it.
so when I want to use my object, I would end up with that sort of convoluted code. my object.getCode().getValue()
.
It seems to do that for String
and also for Boolean
.
It's not only inconvenient, it means that when i try to marshall/unmarshall corresponding json object, they have to comply to that extra nested level.
Using something horrible like this
{
"id": {"value":"example-search"},
"event": {
"type": {
"system": {"value":"http://hl7.org/fhir/audit-event-type"},
"code": {"value":"rest"},
"display": {"value":"Restful Operation"}
},...
instead of the much cleaner.
{
"id": "example-search",
"event": {
"type": {
"system": "http://hl7.org/fhir/audit-event-type",
"code": "rest",
"display": "Restful Operation"
},...
any idea? Many Thanks
From the same downloads page, you can also grab the Java reference implementation. The reference implementations are tuned to make interacting with simple types more natural, to use language conventions for getters, setters, etc. As a bonus, they'll support parsing and serializing the JSON as well. We designed the FHIR schemas so that you can generate code from the schemas, but the reference implementations will give you a much better experience.