Program: 23285
Project: 23285
Buggy source:
private boolean displayLeaf(ResourceWrapper res,BaseWrapper ew,ElementDefinition defn,XhtmlNode x,String name,boolean showCodeDetails) throws FHIRException, UnsupportedEncodingException, IOException {
  if (ew == null)   return false;
  Base e=ew.getBase();
  if (e == null)   return false;
  Map<String,String> displayHints=readDisplayHints(defn);
  if (name.endsWith("String_Node_Str"))   name=name.substring(0,name.length() - 3);
  if (!showCodeDetails && e instanceof PrimitiveType && isDefault(displayHints,((PrimitiveType)e)))   return false;
  if (e instanceof StringType) {
    x.addText(name + "String_Node_Str" + ((StringType)e).getValue());
    return true;
  }
 else   if (e instanceof CodeType) {
    x.addText(name + "String_Node_Str" + ((CodeType)e).getValue());
    return true;
  }
 else   if (e instanceof IdType) {
    x.addText(name + "String_Node_Str" + ((IdType)e).getValue());
    return true;
  }
 else   if (e instanceof UriType) {
    x.addText(name + "String_Node_Str" + ((UriType)e).getValue());
    return true;
  }
 else   if (e instanceof DateTimeType) {
    x.addText(name + "String_Node_Str" + ((DateTimeType)e).toHumanDisplay());
    return true;
  }
 else   if (e instanceof InstantType) {
    x.addText(name + "String_Node_Str" + ((InstantType)e).toHumanDisplay());
    return true;
  }
 else   if (e instanceof Extension) {
    return false;
  }
 else   if (e instanceof org.hl7.fhir.dstu3.model.DateType) {
    x.addText(name + "String_Node_Str" + ((org.hl7.fhir.dstu3.model.DateType)e).toHumanDisplay());
    return true;
  }
 else   if (e instanceof Enumeration) {
    x.addText(((Enumeration<?>)e).getValue().toString());
    return true;
  }
 else   if (e instanceof BooleanType) {
    if (((BooleanType)e).getValue()) {
      x.addText(name);
      return true;
    }
  }
 else   if (e instanceof CodeableConcept) {
    renderCodeableConcept((CodeableConcept)e,x,showCodeDetails);
    return true;
  }
 else   if (e instanceof Coding) {
    renderCoding((Coding)e,x,showCodeDetails);
    return true;
  }
 else   if (e instanceof Annotation) {
    renderAnnotation((Annotation)e,x,showCodeDetails);
    return true;
  }
 else   if (e instanceof org.hl7.fhir.dstu3.model.IntegerType) {
    x.addText(Integer.toString(((org.hl7.fhir.dstu3.model.IntegerType)e).getValue()));
    return true;
  }
 else   if (e instanceof org.hl7.fhir.dstu3.model.DecimalType) {
    x.addText(((org.hl7.fhir.dstu3.model.DecimalType)e).getValue().toString());
    return true;
  }
 else   if (e instanceof Identifier) {
    renderIdentifier((Identifier)e,x);
    return true;
  }
 else   if (e instanceof HumanName) {
    renderHumanName((HumanName)e,x);
    return true;
  }
 else   if (e instanceof SampledData) {
    renderSampledData((SampledData)e,x);
    return true;
  }
 else   if (e instanceof Address) {
    renderAddress((Address)e,x);
    return true;
  }
 else   if (e instanceof ContactPoint) {
    renderContactPoint((ContactPoint)e,x);
    return true;
  }
 else   if (e instanceof Timing) {
    renderTiming((Timing)e,x);
    return true;
  }
 else   if (e instanceof Quantity) {
    renderQuantity((Quantity)e,x,showCodeDetails);
    return true;
  }
 else   if (e instanceof Ratio) {
    renderQuantity(((Ratio)e).getNumerator(),x,showCodeDetails);
    x.tx("String_Node_Str");
    renderQuantity(((Ratio)e).getDenominator(),x,showCodeDetails);
    return true;
  }
 else   if (e instanceof Period) {
    Period p=(Period)e;
    x.addText(name + "String_Node_Str");
    x.addText(!p.hasStart() ? "String_Node_Str" : p.getStartElement().toHumanDisplay());
    x.tx("String_Node_Str");
    x.addText(!p.hasEnd() ? "String_Node_Str" : p.getEndElement().toHumanDisplay());
    return true;
  }
 else   if (e instanceof Reference) {
    Reference r=(Reference)e;
    if (r.hasDisplayElement())     x.addText(r.getDisplay());
 else     if (r.hasReferenceElement()) {
      ResourceWithReference tr=resolveReference(res,r.getReference());
      x.addText(tr == null ? r.getReference() : "String_Node_Str");
    }
 else     x.tx("String_Node_Str");
    return true;
  }
 else   if (e instanceof Narrative) {
    return false;
  }
 else   if (e instanceof Resource) {
    return false;
  }
 else   if (e instanceof ContactDetail) {
    return false;
  }
 else   if (e instanceof Range) {
    return false;
  }
 else   if (e instanceof Meta) {
    return false;
  }
 else   if (e instanceof Dosage) {
    return false;
  }
 else   if (e instanceof Signature) {
    return false;
  }
 else   if (!(e instanceof Attachment))   throw new NotImplementedException("String_Node_Str" + e.getClass().getName() + "String_Node_Str");
  return false;
}

Fixed version (ground truth):
private boolean displayLeaf(ResourceWrapper res,BaseWrapper ew,ElementDefinition defn,XhtmlNode x,String name,boolean showCodeDetails) throws FHIRException, UnsupportedEncodingException, IOException {
  if (ew == null)   return false;
  Base e=ew.getBase();
  if (e == null)   return false;
  Map<String,String> displayHints=readDisplayHints(defn);
  if (name.endsWith("String_Node_Str"))   name=name.substring(0,name.length() - 3);
  if (!showCodeDetails && e instanceof PrimitiveType && isDefault(displayHints,((PrimitiveType)e)))   return false;
  if (e instanceof StringType) {
    x.addText(name + "String_Node_Str" + ((StringType)e).getValue());
    return true;
  }
 else   if (e instanceof CodeType) {
    x.addText(name + "String_Node_Str" + ((CodeType)e).getValue());
    return true;
  }
 else   if (e instanceof IdType) {
    x.addText(name + "String_Node_Str" + ((IdType)e).getValue());
    return true;
  }
 else   if (e instanceof UriType) {
    x.addText(name + "String_Node_Str" + ((UriType)e).getValue());
    return true;
  }
 else   if (e instanceof DateTimeType) {
    x.addText(name + "String_Node_Str" + ((DateTimeType)e).toHumanDisplay());
    return true;
  }
 else   if (e instanceof InstantType) {
    x.addText(name + "String_Node_Str" + ((InstantType)e).toHumanDisplay());
    return true;
  }
 else   if (e instanceof Extension) {
    return false;
  }
 else   if (e instanceof org.hl7.fhir.dstu3.model.DateType) {
    x.addText(name + "String_Node_Str" + ((org.hl7.fhir.dstu3.model.DateType)e).toHumanDisplay());
    return true;
  }
 else   if (e instanceof Enumeration) {
    x.addText(((Enumeration<?>)e).getValue().toString());
    return true;
  }
 else   if (e instanceof BooleanType) {
    if (((BooleanType)e).getValue()) {
      x.addText(name);
      return true;
    }
  }
 else   if (e instanceof CodeableConcept) {
    renderCodeableConcept((CodeableConcept)e,x,showCodeDetails);
    return true;
  }
 else   if (e instanceof Coding) {
    renderCoding((Coding)e,x,showCodeDetails);
    return true;
  }
 else   if (e instanceof Annotation) {
    renderAnnotation((Annotation)e,x,showCodeDetails);
    return true;
  }
 else   if (e instanceof org.hl7.fhir.dstu3.model.IntegerType) {
    x.addText(Integer.toString(((org.hl7.fhir.dstu3.model.IntegerType)e).getValue()));
    return true;
  }
 else   if (e instanceof org.hl7.fhir.dstu3.model.DecimalType) {
    x.addText(((org.hl7.fhir.dstu3.model.DecimalType)e).getValue().toString());
    return true;
  }
 else   if (e instanceof Identifier) {
    renderIdentifier((Identifier)e,x);
    return true;
  }
 else   if (e instanceof HumanName) {
    renderHumanName((HumanName)e,x);
    return true;
  }
 else   if (e instanceof SampledData) {
    renderSampledData((SampledData)e,x);
    return true;
  }
 else   if (e instanceof Address) {
    renderAddress((Address)e,x);
    return true;
  }
 else   if (e instanceof ContactPoint) {
    renderContactPoint((ContactPoint)e,x);
    return true;
  }
 else   if (e instanceof Timing) {
    renderTiming((Timing)e,x);
    return true;
  }
 else   if (e instanceof Quantity) {
    renderQuantity((Quantity)e,x,showCodeDetails);
    return true;
  }
 else   if (e instanceof Ratio) {
    renderQuantity(((Ratio)e).getNumerator(),x,showCodeDetails);
    x.tx("String_Node_Str");
    renderQuantity(((Ratio)e).getDenominator(),x,showCodeDetails);
    return true;
  }
 else   if (e instanceof Period) {
    Period p=(Period)e;
    x.addText(name + "String_Node_Str");
    x.addText(!p.hasStart() ? "String_Node_Str" : p.getStartElement().toHumanDisplay());
    x.tx("String_Node_Str");
    x.addText(!p.hasEnd() ? "String_Node_Str" : p.getEndElement().toHumanDisplay());
    return true;
  }
 else   if (e instanceof Reference) {
    Reference r=(Reference)e;
    if (r.hasDisplayElement())     x.addText(r.getDisplay());
 else     if (r.hasReferenceElement()) {
      ResourceWithReference tr=resolveReference(res,r.getReference());
      x.addText(tr == null ? r.getReference() : "String_Node_Str");
    }
 else     x.tx("String_Node_Str");
    return true;
  }
 else   if (e instanceof Narrative) {
    return false;
  }
 else   if (e instanceof Resource) {
    return false;
  }
 else   if (e instanceof ContactDetail) {
    return false;
  }
 else   if (e instanceof Range) {
    return false;
  }
 else   if (e instanceof Meta) {
    return false;
  }
 else   if (e instanceof Dosage) {
    return false;
  }
 else   if (e instanceof Signature) {
    return false;
  }
 else   if (e instanceof UsageContext) {
    return false;
  }
 else   if (e instanceof ElementDefinition) {
    return false;
  }
 else   if (!(e instanceof Attachment))   throw new NotImplementedException("String_Node_Str" + e.getClass().getName() + "String_Node_Str");
  return false;
}