Class ModelSupport
- java.lang.Object
 - 
- org.linuxforhealth.fhir.model.util.ModelSupport
 
 
- 
public final class ModelSupport extends java.lang.Object 
- 
- 
Nested Class Summary
Nested Classes Modifier and Type Class Description static classModelSupport.ElementInfo 
- 
Field Summary
Fields Modifier and Type Field Description static java.lang.Class<Boolean>FHIR_BOOLEANstatic java.lang.Class<Date>FHIR_DATEstatic java.lang.Class<Instant>FHIR_INSTANTstatic java.lang.Class<Integer>FHIR_INTEGERstatic java.lang.Class<String>FHIR_STRING 
- 
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.Stringdelimit(java.lang.String identifier)Wraps the passed string identifier for use in FHIRPathstatic ModelSupport.ElementInfogetChoiceElementInfo(java.lang.Class<?> modelClass, java.lang.String typeSpecificElementName)static java.lang.StringgetChoiceElementName(java.lang.String name, java.lang.Class<?> type)static java.util.Set<java.lang.Class<?>>getChoiceElementTypes(java.lang.Class<?> modelClass, java.lang.String elementName)static java.util.List<java.lang.Class<?>>getClosure(java.lang.Class<?> modelClass)static java.util.Collection<java.lang.Class<?>>getCodeSubtypes()static java.lang.Class<?>getConcreteType(java.lang.Class<?> type)static java.util.List<Constraint>getConstraints(java.lang.Class<?> modelClass)static java.lang.Class<?>getDataType(java.lang.String typeName)static java.util.Set<java.lang.Class<? extends Element>>getDataTypes()static java.lang.Class<?>getElementDeclaringType(java.lang.Class<?> modelClass, java.lang.String elementName)Get the model class which declares the elementName found on the passed modelClass.static java.util.Collection<ModelSupport.ElementInfo>getElementInfo(java.lang.Class<?> modelClass)static ModelSupport.ElementInfogetElementInfo(java.lang.Class<?> modelClass, java.lang.String elementName)static java.lang.StringgetElementName(java.lang.reflect.Field field)Get the actual element name from a Java field.static java.lang.StringgetElementName(java.lang.String fieldName)Get the actual element name from a Java field name.static java.util.Set<java.lang.String>getElementNames(java.lang.Class<?> modelClass)static java.lang.Class<?>getElementType(java.lang.Class<?> modelClass, java.lang.String elementName)static java.util.Set<java.lang.Class<?>>getModelClasses()static java.util.Set<java.lang.String>getReferenceTargetTypes(java.lang.Class<?> modelClass, java.lang.String elementName)static java.lang.Class<? extends Resource>getResourceType(java.lang.String name)static java.util.Collection<java.lang.Class<? extends Resource>>getResourceTypes()static java.util.Collection<java.lang.Class<? extends Resource>>getResourceTypes(boolean includeAbstractTypes)static java.lang.StringgetSystem(Code code)static java.lang.StringgetTypeName(java.lang.Class<?> type)static java.util.Set<java.lang.String>getTypeNames(java.lang.Class<?> modelClass)static voidinit()Calling this method allows us to load/initialize this class during startup.static booleanisAbstract(java.lang.Class<?> modelClass)static booleanisBackboneElementType(java.lang.Class<?> modelClass)static booleanisChoiceElement(java.lang.Class<?> modelClass, java.lang.String elementName)static booleanisChoiceElementType(java.lang.Class<?> type)static booleanisCodeSubtype(java.lang.Class<?> type)static booleanisCodeSubtype(java.lang.String name)static booleanisConcreteResourceType(java.lang.String name)static booleanisElement(java.lang.Object modelObject)static booleanisElementDeclaredBy(java.lang.Class<?> modelClass, java.lang.String elementName, java.lang.Class<?> type)static booleanisElementType(java.lang.Class<?> modelClass)static booleanisKeyword(java.lang.String identifier)static booleanisMetadataType(java.lang.Class<?> type)static booleanisModelClass(java.lang.Class<?> type)static booleanisPrimitiveType(java.lang.Class<?> type)static booleanisProfiledType(java.lang.Class<?> type)static booleanisRepeatingElement(java.lang.Class<?> modelClass, java.lang.String elementName)static booleanisRequiredElement(java.lang.Class<?> modelClass, java.lang.String elementName)static booleanisResource(java.lang.Object modelObject)static booleanisResourceType(java.lang.Class<?> modelClass)static booleanisResourceType(java.lang.String name)static booleanisSummaryElement(java.lang.Class<?> modelClass, java.lang.String elementName)static java.time.LocalTimetruncateTime(java.time.LocalTime time, java.time.temporal.ChronoUnit unit)static java.time.temporal.TemporalAccessortruncateTime(java.time.temporal.TemporalAccessor ta, java.time.temporal.ChronoUnit unit)static java.time.ZonedDateTimetruncateTime(java.time.ZonedDateTime dateTime, java.time.temporal.ChronoUnit unit) 
 - 
 
- 
- 
Field Detail
- 
FHIR_BOOLEAN
public static final java.lang.Class<Boolean> FHIR_BOOLEAN
 
- 
FHIR_INTEGER
public static final java.lang.Class<Integer> FHIR_INTEGER
 
- 
FHIR_STRING
public static final java.lang.Class<String> FHIR_STRING
 
- 
FHIR_DATE
public static final java.lang.Class<Date> FHIR_DATE
 
- 
FHIR_INSTANT
public static final java.lang.Class<Instant> FHIR_INSTANT
 
 - 
 
- 
Method Detail
- 
init
public static void init()
Calling this method allows us to load/initialize this class during startup. 
- 
getChoiceElementName
public static java.lang.String getChoiceElementName(java.lang.String name, java.lang.Class<?> type)- Parameters:
 name- the name of the choice element without any type suffixtype- the model class which represents the choice value for the choice element- Returns:
 - the serialized name of the choice element 
namewith choice typetype 
 
- 
getChoiceElementTypes
public static java.util.Set<java.lang.Class<?>> getChoiceElementTypes(java.lang.Class<?> modelClass, java.lang.String elementName)- Parameters:
 modelClass- a model class which represents a FHIR resource or elementelementName- the name of the choice element without any type suffix- Returns:
 - the set of model classes for the allowed types of the specified choice element
 
 
- 
getReferenceTargetTypes
public static java.util.Set<java.lang.String> getReferenceTargetTypes(java.lang.Class<?> modelClass, java.lang.String elementName)- Parameters:
 modelClass- a model class which represents a FHIR resource or elementelementName- the name of the reference element- Returns:
 - a set of Strings which represent the the allowed target types for the reference
 
 
- 
getClosure
public static java.util.List<java.lang.Class<?>> getClosure(java.lang.Class<?> modelClass)
- Parameters:
 modelClass- a model class which represents a FHIR resource or element- Returns:
 - A list of superclasses ordered from parent to child, including the modelClass itself
 
 
- 
getConcreteType
public static java.lang.Class<?> getConcreteType(java.lang.Class<?> type)
- Parameters:
 type-- Returns:
 - the class for the concrete type of the passed type if it is a profiled type; otherwise the passed type itself
 
 
- 
getConstraints
public static java.util.List<Constraint> getConstraints(java.lang.Class<?> modelClass)
- Returns:
 - the list of constraints for the modelClass or empty if there are none
 
 
- 
getElementInfo
public static ModelSupport.ElementInfo getElementInfo(java.lang.Class<?> modelClass, java.lang.String elementName)
- Returns:
 - ElementInfo for the element with the passed name on the passed modelClass or null if the modelClass does not contain an element with this name
 
 
- 
getElementInfo
public static java.util.Collection<ModelSupport.ElementInfo> getElementInfo(java.lang.Class<?> modelClass)
- Returns:
 - a collection of ElementInfo for all elements of the passed modelClass or empty if the class is not a FHIR model class
 
 
- 
getChoiceElementInfo
public static ModelSupport.ElementInfo getChoiceElementInfo(java.lang.Class<?> modelClass, java.lang.String typeSpecificElementName)
- Returns:
 - ElementInfo for the choice element with the passed typeSpecificElementName of the passed modelClass or null if the modelClass does not contain a choice element that can have this typeSpecificElementName
 
 
- 
getElementName
public static java.lang.String getElementName(java.lang.reflect.Field field)
Get the actual element name from a Java field. 
- 
getElementName
public static java.lang.String getElementName(java.lang.String fieldName)
Get the actual element name from a Java field name. This method reverses any encoding that was required to represent the FHIR element name in Java, such as converting class to clazz. 
- 
getElementNames
public static java.util.Set<java.lang.String> getElementNames(java.lang.Class<?> modelClass)
- Returns:
 - the set of element names for the passed modelClass or empty if it is not a FHIR model class
 
 
- 
getElementType
public static java.lang.Class<?> getElementType(java.lang.Class<?> modelClass, java.lang.String elementName)- Returns:
 - the model class for the element with name elementName on the passed modelClass or
         null if the passed modelClass does not have an element 
elementName 
 
- 
getElementDeclaringType
public static java.lang.Class<?> getElementDeclaringType(java.lang.Class<?> modelClass, java.lang.String elementName)Get the model class which declares the elementName found on the passed modelClass.- Parameters:
 modelClass- a model class which represents a FHIR resource or elementelementName- the name of the element; choice element names do not include a type suffix- Returns:
 - modelClass or a superclass of modelClass, or null if the element is not found on the passed modelClass
 
 
- 
isElementDeclaredBy
public static boolean isElementDeclaredBy(java.lang.Class<?> modelClass, java.lang.String elementName, java.lang.Class<?> type)- Parameters:
 modelClass- a model class which represents a FHIR resource or elementelementName- the name of the element; choice element names do not include a type suffixtype- the model class to check- Returns:
 - true if the passed modelClass contains an element with name elementName and the passed type is the one that declares it; otherwise false
 
 
- 
getModelClasses
public static java.util.Set<java.lang.Class<?>> getModelClasses()
- Returns:
 - all model classes, including both resources and elements, concrete and abstract
 
 
- 
getResourceType
public static java.lang.Class<? extends Resource> getResourceType(java.lang.String name)
- Parameters:
 name- the resource type name in titlecase to match the corresponding model class name- Returns:
 - the model class that corresponds to the passed resource type name
 
 
- 
getResourceTypes
public static java.util.Collection<java.lang.Class<? extends Resource>> getResourceTypes()
- Returns:
 - a collection of FHIR resource type model classes, including abstract supertypes
 
 
- 
getResourceTypes
public static java.util.Collection<java.lang.Class<? extends Resource>> getResourceTypes(boolean includeAbstractTypes)
- Returns:
 - a collection of FHIR resource type model classes
 
 
- 
getDataTypes
public static java.util.Set<java.lang.Class<? extends Element>> getDataTypes()
- Returns:
 - the set of classes for the FHIR elements
 
 
- 
getTypeName
public static java.lang.String getTypeName(java.lang.Class<?> type)
- Returns:
 - the name of the FHIR data type which corresponds to the passed type
 
 
- 
getTypeNames
public static java.util.Set<java.lang.String> getTypeNames(java.lang.Class<?> modelClass)
- Returns:
 - the set of FHIR data type names for the passed modelClass and its supertypes
 
 
- 
isBackboneElementType
public static boolean isBackboneElementType(java.lang.Class<?> modelClass)
- Parameters:
 modelClass- a model class which represents a FHIR resource or element- Returns:
 - true if and only if 
modelClassis a BackboneElement 
 
- 
isChoiceElement
public static boolean isChoiceElement(java.lang.Class<?> modelClass, java.lang.String elementName)- Parameters:
 modelClass- a model class which represents a FHIR resource or elementelementName- the name of the element; choice element names do not include a type suffix- Returns:
 - true if 
modelClasscontains a choice element with name @{code elementName}; otherwise false 
 
- 
isChoiceElementType
public static boolean isChoiceElementType(java.lang.Class<?> type)
- Parameters:
 type- a model class which represents a FHIR element- Returns:
 - true if 
typeis an allowed choice element type; otherwise false 
 
- 
isCodeSubtype
public static boolean isCodeSubtype(java.lang.Class<?> type)
- Parameters:
 type- a model class which represents a FHIR element- Returns:
 - true if 
typeis subclass of org.linuxforhealth.fhir.model.type.Code; otherwise false 
 
- 
isElement
public static boolean isElement(java.lang.Object modelObject)
- Parameters:
 modelObject- a model object which represents a FHIR resource or element- Returns:
 - true if 
modelObjectis an element; otherwise false 
 
- 
isElementType
public static boolean isElementType(java.lang.Class<?> modelClass)
- Parameters:
 modelClass- a model class which represents a FHIR resource or element- Returns:
 - true if 
modelClassis an element; otherwise false 
 
- 
isMetadataType
public static boolean isMetadataType(java.lang.Class<?> type)
- Parameters:
 type- a model class which represents a FHIR element- Returns:
 - true if 
typeis a metadata type; otherwise false - See Also:
 - https://www.hl7.org/fhir/R4/metadatatypes.html
 
 
- 
isModelClass
public static boolean isModelClass(java.lang.Class<?> type)
- Returns:
 - true if 
typeis a model class that represents a FHIR resource or element; otherwise false 
 
- 
isPrimitiveType
public static boolean isPrimitiveType(java.lang.Class<?> type)
- Parameters:
 type- a model class which represents a FHIR element- Returns:
 - true if 
typeis a model class that represents a FHIR primitive type; otherwise false - See Also:
 - https://www.hl7.org/fhir/R4/datatypes.html#primitive
 
 
- 
isProfiledType
public static boolean isProfiledType(java.lang.Class<?> type)
- Parameters:
 type- a model class which represents a FHIR element- Returns:
 - true if 
typeis a profiled data type; otherwise false 
 
- 
isRepeatingElement
public static boolean isRepeatingElement(java.lang.Class<?> modelClass, java.lang.String elementName)- Parameters:
 modelClass- a model class which represents a FHIR resource or elementelementName- the name of the element; choice element names do not include a type suffix- Returns:
 - true if 
modelClasshas an elementelementNameand it has max cardinality > 1; otherwise false 
 
- 
isRequiredElement
public static boolean isRequiredElement(java.lang.Class<?> modelClass, java.lang.String elementName)- Parameters:
 modelClass- a model class which represents a FHIR resource or elementelementName- the name of the element; choice element names do not include a type suffix- Returns:
 - true if 
modelClasshas an elementelementNameand it has min cardinality > 0; otherwise false 
 
- 
isResource
public static boolean isResource(java.lang.Object modelObject)
- Parameters:
 modelObject- a model object which represents a FHIR resource or element- Returns:
 - true if 
modelObjectrepresents a FHIR resource; otherwise false 
 
- 
isResourceType
public static boolean isResourceType(java.lang.Class<?> modelClass)
- Parameters:
 modelClass- a model class which represents a FHIR resource or element- Returns:
 - true if 
modelClassrepresents a FHIR resource; otherwise false 
 
- 
isAbstract
public static boolean isAbstract(java.lang.Class<?> modelClass)
- Parameters:
 modelClass- a model class which represents a FHIR resource or element- Returns:
 - true if 
modelClassis an abstract FHIR model class; otherwise false 
 
- 
isResourceType
public static boolean isResourceType(java.lang.String name)
- Parameters:
 name- the resource type name in titlecase to match the corresponding model class name- Returns:
 - true if 
nameis a valid FHIR resource name; otherwise false 
 
- 
isConcreteResourceType
public static boolean isConcreteResourceType(java.lang.String name)
- Parameters:
 name- the resource type name in titlecase to match the corresponding model class name- Returns:
 - true if 
nameis a valid FHIR resource name; otherwise false 
 
- 
isSummaryElement
public static boolean isSummaryElement(java.lang.Class<?> modelClass, java.lang.String elementName)- Parameters:
 modelClass- a model class which represents a FHIR resource or elementelementName- the name of the element; choice element names do not include a type suffix- Returns:
 - true if 
modelClasshas an elementelementNameand its marked as a summary element; otherwise false 
 
- 
truncateTime
public static java.time.ZonedDateTime truncateTime(java.time.ZonedDateTime dateTime, java.time.temporal.ChronoUnit unit)- Returns:
 - a copy of the passed ZonedDateTime with the time truncated to 
unit 
 
- 
truncateTime
public static java.time.LocalTime truncateTime(java.time.LocalTime time, java.time.temporal.ChronoUnit unit)- Returns:
 - a copy of the passed LocalTime with the time truncated to 
unit 
 
- 
truncateTime
public static java.time.temporal.TemporalAccessor truncateTime(java.time.temporal.TemporalAccessor ta, java.time.temporal.ChronoUnit unit)- Returns:
 - a copy of the passed TemporalAccessor with the time truncated to 
unit 
 
- 
isKeyword
public static boolean isKeyword(java.lang.String identifier)
- Returns:
 - true if 
identifieris a reserved keyword in FHIRPath version N1 - See Also:
 - http://hl7.org/fhirpath/2018Sep/index.html#keywords
 
 
- 
delimit
public static java.lang.String delimit(java.lang.String identifier)
Wraps the passed string identifier for use in FHIRPath 
- 
getSystem
public static java.lang.String getSystem(Code code)
- Returns:
 - the implicit system for 
codeif present, otherwise null 
 
- 
getDataType
public static java.lang.Class<?> getDataType(java.lang.String typeName)
- Returns:
 - the data type class associated with 
typeNameparameter if exists, otherwise null 
 
- 
isCodeSubtype
public static boolean isCodeSubtype(java.lang.String name)
 
- 
getCodeSubtypes
public static java.util.Collection<java.lang.Class<?>> getCodeSubtypes()
 
 - 
 
 -