Skip to content

Commit

Permalink
avoid double negation
Browse files Browse the repository at this point in the history
  • Loading branch information
celinepelletier committed Oct 3, 2024
1 parent e6bdafd commit 1fd0f1b
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -138,13 +138,13 @@ private static ByteBuffer bytesForString(String string) {
return ByteBuffer.wrap(string.getBytes(StandardCharsets.UTF_8));
}

private static Boolean isNotRealValueXField(Base base, String fieldName) {
return base instanceof Device.DevicePropertyComponent && (fieldName.equals("valueQuantity") || fieldName.equals("valueCode"));
private static Boolean isRealValueXField(Base base, String fieldName) {
return !(base instanceof Device.DevicePropertyComponent) || (!fieldName.equals("valueQuantity") && !fieldName.equals("valueCode"));
}

private static Optional<Property> getProperty(Base base, Schema.Field field) {
// Support value[x] notation.
if (Pattern.compile("value[a-zA-Z].*").matcher(field.name()).matches() && !isNotRealValueXField(base, field.name())) {
if (Pattern.compile("value[a-zA-Z].*").matcher(field.name()).matches() && isRealValueXField(base, field.name())) {
Property property = base.getNamedProperty(Constant.VALUE);
if (property != null && property.hasValues()) {
// Try to find the valid corresponding value[x] by comparing the FhirType and the field name.
Expand Down

0 comments on commit 1fd0f1b

Please sign in to comment.