Stream: hapi
Topic: Enumeration Classes
Bryn Rhodes (Jan 03 2017 at 18:41):
I'm looking at the enumeration classes in HAPI's RI (org.hl7.fhir.dstu3.model) package, and wondering why the enums are defined as enclosed classes? And how you determine what the class name is for the enum? For example, the structure definition for PlanDefinition defines a binding for the precheckBehavior element that references the action-precheck-behavior value set. But the class name for the enumeration in HAPI is PlanDefinition.PlanActionPrecheckBehavior. Where does the HAPI generation get this class name?
Grahame Grieve (Jan 03 2017 at 20:14):
enumerations used in more than one place are not enclosed in a class. I enclosed them to keep the overall number of java files manageable
Grahame Grieve (Jan 03 2017 at 20:14):
The name is generated from the binding name in the spreadsheets, I think
Bryn Rhodes (Jan 03 2017 at 20:16):
Okay, that makes sense, but it makes the type names inconsistent between the Java RI classes and the XML Schema classes. The type name in the XML is PlanActionPrecheckBehavior, but in the Java classes, it's PlanDefinition.PlanActionPrecheckBehavior.
Bryn Rhodes (Jan 03 2017 at 20:16):
Which really only matters because I'm using the XML schema type name to look up the RI class name and it's missing because of that inconsistency.
Bryn Rhodes (Jan 03 2017 at 20:19):
And for that enumeration specifically, it is being used in more than one place, but the binding names are different in the spreadsheets, they just point to the same value set. Are you using the binding name to determine uniqueness there?
Grahame Grieve (Jan 03 2017 at 20:24):
whether they are in terminologies\bindings.xml
Bryn Rhodes (Jan 03 2017 at 20:31):
I see, I'll switch them to use that, there are several that are common there.
Grahame Grieve (Jan 03 2017 at 20:33):
ok
Grahame Grieve (Jan 03 2017 at 20:34):
more generally, there's no magic solution here, the schema does not contain all sorts of interesting information
Bryn Rhodes (Jan 03 2017 at 20:34):
But in this case, the StructureDefinition doesn't have it either.
Bryn Rhodes (Jan 03 2017 at 20:35):
Which I think is fine, I just think that it would make generation easier if the schema and the RI classes used consistent type names.
Bryn Rhodes (Jan 03 2017 at 20:35):
Out of curiosity, what is the .NET type name?
Grahame Grieve (Jan 03 2017 at 20:35):
they are consistent. It's the java layout that's not
Grahame Grieve (Jan 03 2017 at 20:36):
don't know.
Grahame Grieve (Jan 03 2017 at 20:36):
I could add an extension to the StructureDefinitions about this. Not sure quite what it should say though
Bryn Rhodes (Jan 03 2017 at 20:40):
It should have the name of the enumeration class, in this case PlanDefinition.PlanActionPrecheckBehavior. Which I would suggest should be the same name of the type in the XML schema.
Grahame Grieve (Jan 03 2017 at 20:43):
well, you can ask on the implementers stream if anyone cares if the enumeration type names change in the schema
Grahame Grieve (Jan 03 2017 at 20:44):
but strictly, the name of the enumeration class is PlanActionPrecheckBehavior. it's whether it's specific to that resource, or shared, that we are talking about here
Bryn Rhodes (Jan 03 2017 at 20:44):
Conceptually, yes, but the way class lookup works in Java, it's the difference between a direct lookup and scanning all resource classes for sub-classes.
Grahame Grieve (Jan 03 2017 at 20:46):
actually, it's the difference between being enclosed in Enumerations, or in the resource itself
Bryn Rhodes (Jan 03 2017 at 20:48):
Ah, so if an enumeration is used in more than one place, it will be a subclass of Enumerations?
Grahame Grieve (Jan 03 2017 at 20:50):
enclosed by enumerations (not quite the same thing)
Bryn Rhodes (Jan 03 2017 at 20:50):
True, misspoke.
Grahame Grieve (Jan 03 2017 at 20:52):
well, do you want to make a task for me to add an extension for whether the binding is common or not?
Bryn Rhodes (Jan 03 2017 at 20:54):
Well, the StructureDefinition doesn't have the name of the type at all right now, and you're right that's a different thing than whether it is used in multiple places. I think at the very least the StructureDefinition should have the type name, so "binding-name" or something like that, which in this case would be PlanActionPrecheckBehavior.
Bryn Rhodes (Jan 03 2017 at 20:54):
Happy to add a task for that.
Bryn Rhodes (Jan 03 2017 at 20:55):
Not sure about the usefulness of the common information though.
Bryn Rhodes (Jan 03 2017 at 20:55):
What do you do in the XML Schema if you have duplicate binding names?
Grahame Grieve (Jan 03 2017 at 20:56):
ok. I can add a proposed type name for a binding. As for the common information - in both schema and java, it defines where in the content it is generated. (it doesn't in pascal, and I don't know what .Net does)
Bryn Rhodes (Jan 03 2017 at 20:57):
So "is-common-binding" or something like that?
Grahame Grieve (Jan 03 2017 at 20:58):
yes
Bryn Rhodes (Jan 03 2017 at 20:58):
Okay, I'll submit tasks.
Grahame Grieve (Jan 03 2017 at 20:59):
thx
Brian Postlethwaite (Jan 04 2017 at 06:09):
Not sure if the .NET enums are consistent.
We create contained enums where the enumeration is not shared with any other classes, otherwise it is generated in the Hl7.Fhir.Model namespace where it can be shared.
And the name is just the name of the ValueSet bound
pasted-image.png
Last updated: Apr 12 2022 at 19:14 UTC