Class FHIRAbstractGenerator
- java.lang.Object
-
- org.linuxforhealth.fhir.model.generator.FHIRAbstractGenerator
-
- All Implemented Interfaces:
FHIRGenerator
- Direct Known Subclasses:
FHIRJsonGenerator
,FHIRXMLGenerator
public abstract class FHIRAbstractGenerator extends java.lang.Object implements FHIRGenerator
-
-
Field Summary
Fields Modifier and Type Field Description protected boolean
prettyPrinting
protected java.util.Map<java.lang.String,java.lang.Object>
properties
-
Fields inherited from interface org.linuxforhealth.fhir.model.generator.FHIRGenerator
PROPERTY_INDENT_AMOUNT
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
FHIRAbstractGenerator(boolean prettyPrinting)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description <T extends FHIRGenerator>
Tas(java.lang.Class<T> generatorClass)
abstract void
generate(Visitable visitable, java.io.OutputStream out)
Writevisitable
to the passed OutputStream.abstract void
generate(Visitable visitable, java.io.Writer writer)
Writevisitable
using the passed Writer.java.lang.Object
getProperty(java.lang.String name)
<T> T
getProperty(java.lang.String name, java.lang.Class<T> type)
java.lang.Object
getPropertyOrDefault(java.lang.String name, java.lang.Object defaultValue)
<T> T
getPropertyOrDefault(java.lang.String name, T defaultValue, java.lang.Class<T> type)
boolean
isPrettyPrinting()
boolean
isPropertySupported(java.lang.String name)
Whether the generator supports the property with the passed namevoid
setProperty(java.lang.String name, java.lang.Object value)
Set the property with the given name to the passed value
-
-
-
Method Detail
-
generate
public abstract void generate(Visitable visitable, java.io.OutputStream out) throws FHIRGeneratorException
Description copied from interface:FHIRGenerator
Writevisitable
to the passed OutputStream. This method does not close the passed OutputStream. Forvisitable
of type Resource, this serializes the resource in accordance with the specification. Forvisitable
of type Element, this serializes the element content using a suitable wrapper for the configured format.- Specified by:
generate
in interfaceFHIRGenerator
- Parameters:
visitable
- The visitable Resource or Element to serialize- Throws:
FHIRGeneratorException
-
generate
public abstract void generate(Visitable visitable, java.io.Writer writer) throws FHIRGeneratorException
Description copied from interface:FHIRGenerator
Writevisitable
using the passed Writer. This method does not close the passed Writer. Forvisitable
of type Resource, this serializes the resource in accordance with the specification. Forvisitable
of type Element, this serializes the element content using a suitable wrapper for the configured format.- Specified by:
generate
in interfaceFHIRGenerator
- Parameters:
visitable
- The visitable Resource or Element to serialize- Throws:
FHIRGeneratorException
-
isPrettyPrinting
public boolean isPrettyPrinting()
- Specified by:
isPrettyPrinting
in interfaceFHIRGenerator
- Returns:
- whether this FHIRGenerator is configured to pretty-print its output
-
setProperty
public void setProperty(java.lang.String name, java.lang.Object value)
Description copied from interface:FHIRGenerator
Set the property with the given name to the passed value- Specified by:
setProperty
in interfaceFHIRGenerator
-
getProperty
public java.lang.Object getProperty(java.lang.String name)
- Specified by:
getProperty
in interfaceFHIRGenerator
- Returns:
- the property value or
null
if the property has no value
-
getProperty
public <T> T getProperty(java.lang.String name, java.lang.Class<T> type)
- Specified by:
getProperty
in interfaceFHIRGenerator
- Returns:
- the property value or
null
if the property has no value
-
getPropertyOrDefault
public java.lang.Object getPropertyOrDefault(java.lang.String name, java.lang.Object defaultValue)
- Specified by:
getPropertyOrDefault
in interfaceFHIRGenerator
- Returns:
- the property value or
defaultValue
if the property has no value
-
getPropertyOrDefault
public <T> T getPropertyOrDefault(java.lang.String name, T defaultValue, java.lang.Class<T> type)
- Specified by:
getPropertyOrDefault
in interfaceFHIRGenerator
- Returns:
- the property value or
defaultValue
if the property has no value
-
isPropertySupported
public boolean isPropertySupported(java.lang.String name)
Description copied from interface:FHIRGenerator
Whether the generator supports the property with the passed name- Specified by:
isPropertySupported
in interfaceFHIRGenerator
-
as
public <T extends FHIRGenerator> T as(java.lang.Class<T> generatorClass)
- Specified by:
as
in interfaceFHIRGenerator
-
-