-
Notifications
You must be signed in to change notification settings - Fork 160
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issue #2424 - add support for non-validating builders / parsers #2447
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Signed-off-by: John T.E. Timm <johntimm@us.ibm.com>
Signed-off-by: John T.E. Timm <johntimm@us.ibm.com>
lmsurpre
reviewed
Jun 1, 2021
fhir-benchmark/src/main/java/com/ibm/fhir/benchmark/FHIRParserBenchmark.java
Show resolved
Hide resolved
lmsurpre
reviewed
Jun 1, 2021
fhir-model/src/main/java/com/ibm/fhir/model/builder/AbstractBuilder.java
Show resolved
Hide resolved
lmsurpre
reviewed
Jun 1, 2021
fhir-model/src/main/java/com/ibm/fhir/model/builder/AbstractBuilder.java
Show resolved
Hide resolved
lmsurpre
reviewed
Jun 1, 2021
fhir-model/src/main/java/com/ibm/fhir/model/builder/AbstractBuilder.java
Show resolved
Hide resolved
prb112
approved these changes
Jun 1, 2021
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM - reviewed with John on WebEx
Signed-off-by: John T.E. Timm <johntimm@us.ibm.com>
Signed-off-by: John T.E. Timm <johntimm@us.ibm.com>
Signed-off-by: John T.E. Timm <johntimm@us.ibm.com>
Signed-off-by: John T.E. Timm <johntimm@us.ibm.com>
Signed-off-by: John T.E. Timm <johntimm@us.ibm.com>
Signed-off-by: John T.E. Timm <johntimm@us.ibm.com>
lmsurpre
approved these changes
Jun 1, 2021
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
tbieste
pushed a commit
that referenced
this pull request
Jun 9, 2021
* Issue #2424 - add support for non-validating builders/parsers Signed-off-by: John T.E. Timm <johntimm@us.ibm.com> * Issue #2424 - update copyright header Signed-off-by: John T.E. Timm <johntimm@us.ibm.com> * Issue #2424 - updates per PR feedback Signed-off-by: John T.E. Timm <johntimm@us.ibm.com> * Issue #2424 - updated Javadoc Signed-off-by: John T.E. Timm <johntimm@us.ibm.com> * Issue #2424 - introduce ignoringUnrecognizedElements field Signed-off-by: John T.E. Timm <johntimm@us.ibm.com> * Issue #2424 - updated unit test Signed-off-by: John T.E. Timm <johntimm@us.ibm.com> * Issue #2424 - fixed issue with Builder.validate method Signed-off-by: John T.E. Timm <johntimm@us.ibm.com> * Issue #2424 - updated Javadoc wording Signed-off-by: John T.E. Timm <johntimm@us.ibm.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Changes made:
AbstractBuilder
class to include avalidating
field, asetValidating
method, and anisValidating
methodFHIRAbstractParser
class to include avalidating
field, asetValidating
method, and anisValidating
methodFHIRJsonParser.isPropertySupported
method to returnsuper.isPropertySupported(name)
FHIRParser
interface to exposesetValidating
andisValidating
methodsValidationSupport
utility class outside of the constructor into a new generatedvalidate
method on the respective nested builder class.NOTE: This decision was made after taking another look at Effective Java, the Google Protobuf Java library, the javapoet Java library, and this Stack Overflow:
https://stackoverflow.com/questions/38173274/builder-pattern-validation-effective-java
Specifically the mention of this quote from Effective Java:
Example of the new generated
validate
method:validate
method from thebuild
method (guarded byvalidating
field):validating
field to theAbstractBuilder.setValidating
method immediately after the builder class is instantiated (using thebuilder
static factory method). For example:from
method to generatedCode
subtypes to be consistent with generated model classesFHIRPersistenceJDBCImpl.convertResourceDTO
method to useFHIRParser.setValidating(false)
so that resources read from the database do not use a "validating" parser.FHIRParserBenchmark
to include benchmarks for both validating and non-validating Json and XML parsers.Here are the results after running the updated benchmark with 5 random spec examples:
As you can see, there is a very tangible performance boost when using non-validating parsers for both Json and XML.
Signed-off-by: John T.E. Timm johntimm@us.ibm.com