Package com.ibm.fhir.model.util
Class ModelSupport
- java.lang.Object
 - 
- com.ibm.fhir.model.util.ModelSupport
 
 
- 
public final class ModelSupport extends Object
 
- 
- 
Nested Class Summary
Nested Classes Modifier and Type Class Description static classModelSupport.ElementInfo 
- 
Field Summary
Fields Modifier and Type Field Description static Class<Boolean>FHIR_BOOLEANstatic Class<Date>FHIR_DATEstatic Class<Instant>FHIR_INSTANTstatic Class<Integer>FHIR_INTEGERstatic Class<String>FHIR_STRING 
- 
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Stringdelimit(String identifier)Wraps the passed string identifier for use in FHIRPathstatic ModelSupport.ElementInfogetChoiceElementInfo(Class<?> modelClass, String typeSpecificElementName)static StringgetChoiceElementName(String name, Class<?> type)static Set<Class<?>>getChoiceElementTypes(Class<?> modelClass, String elementName)static List<Class<?>>getClosure(Class<?> modelClass)static Collection<Class<?>>getCodeSubtypes()static Class<?>getConcreteType(Class<?> type)static List<Constraint>getConstraints(Class<?> modelClass)static Class<?>getDataType(String typeName)static Set<Class<? extends Element>>getDataTypes()static Class<?>getElementDeclaringType(Class<?> modelClass, String elementName)Get the model class which declares the elementName found on the passed modelClass.static Collection<ModelSupport.ElementInfo>getElementInfo(Class<?> modelClass)static ModelSupport.ElementInfogetElementInfo(Class<?> modelClass, String elementName)static StringgetElementName(Field field)Get the actual element name from a Java field.static StringgetElementName(String fieldName)Get the actual element name from a Java field name.static Set<String>getElementNames(Class<?> modelClass)static Class<?>getElementType(Class<?> modelClass, String elementName)static Set<Class<?>>getModelClasses()static Set<String>getReferenceTargetTypes(Class<?> modelClass, String elementName)static Class<? extends Resource>getResourceType(String name)static Collection<Class<? extends Resource>>getResourceTypes()static Collection<Class<? extends Resource>>getResourceTypes(boolean includeAbstractTypes)static StringgetSystem(Code code)static StringgetTypeName(Class<?> type)static Set<String>getTypeNames(Class<?> modelClass)static voidinit()Calling this method allows us to load/initialize this class during startup.static booleanisAbstract(Class<?> modelClass)static booleanisBackboneElementType(Class<?> modelClass)static booleanisChoiceElement(Class<?> modelClass, String elementName)static booleanisChoiceElementType(Class<?> type)static booleanisCodeSubtype(Class<?> type)static booleanisCodeSubtype(String name)static booleanisConcreteResourceType(String name)static booleanisElement(Object modelObject)static booleanisElementDeclaredBy(Class<?> modelClass, String elementName, Class<?> type)static booleanisElementType(Class<?> modelClass)static booleanisKeyword(String identifier)static booleanisMetadataType(Class<?> type)static booleanisModelClass(Class<?> type)static booleanisPrimitiveType(Class<?> type)static booleanisProfiledType(Class<?> type)static booleanisRepeatingElement(Class<?> modelClass, String elementName)static booleanisRequiredElement(Class<?> modelClass, String elementName)static booleanisResource(Object modelObject)static booleanisResourceType(Class<?> modelClass)static booleanisResourceType(String name)static booleanisSummaryElement(Class<?> modelClass, String elementName)static LocalTimetruncateTime(LocalTime time, ChronoUnit unit)static TemporalAccessortruncateTime(TemporalAccessor ta, ChronoUnit unit)static ZonedDateTimetruncateTime(ZonedDateTime dateTime, ChronoUnit unit) 
 - 
 
- 
- 
Method Detail
- 
init
public static void init()
Calling this method allows us to load/initialize this class during startup. 
- 
getChoiceElementName
public static String getChoiceElementName(String name, 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 Set<Class<?>> getChoiceElementTypes(Class<?> modelClass, 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 Set<String> getReferenceTargetTypes(Class<?> modelClass, 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 List<Class<?>> getClosure(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 Class<?> getConcreteType(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 List<Constraint> getConstraints(Class<?> modelClass)
- Returns:
 - the list of constraints for the modelClass or empty if there are none
 
 
- 
getElementInfo
public static ModelSupport.ElementInfo getElementInfo(Class<?> modelClass, 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 Collection<ModelSupport.ElementInfo> getElementInfo(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(Class<?> modelClass, 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 String getElementName(Field field)
Get the actual element name from a Java field. 
- 
getElementName
public static String getElementName(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 Set<String> getElementNames(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 Class<?> getElementType(Class<?> modelClass, 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 Class<?> getElementDeclaringType(Class<?> modelClass, 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(Class<?> modelClass, String elementName, 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 Set<Class<?>> getModelClasses()
- Returns:
 - all model classes, including both resources and elements, concrete and abstract
 
 
- 
getResourceType
public static Class<? extends Resource> getResourceType(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 Collection<Class<? extends Resource>> getResourceTypes()
- Returns:
 - a collection of FHIR resource type model classes, including abstract supertypes
 
 
- 
getResourceTypes
public static Collection<Class<? extends Resource>> getResourceTypes(boolean includeAbstractTypes)
- Returns:
 - a collection of FHIR resource type model classes
 
 
- 
getDataTypes
public static Set<Class<? extends Element>> getDataTypes()
- Returns:
 - the set of classes for the FHIR elements
 
 
- 
getTypeName
public static String getTypeName(Class<?> type)
- Returns:
 - the name of the FHIR data type which corresponds to the passed type
 
 
- 
getTypeNames
public static Set<String> getTypeNames(Class<?> modelClass)
- Returns:
 - the set of FHIR data type names for the passed modelClass and its supertypes
 
 
- 
isBackboneElementType
public static boolean isBackboneElementType(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(Class<?> modelClass, 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(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(Class<?> type)
- Parameters:
 type- a model class which represents a FHIR element- Returns:
 - true if 
typeis subclass of com.ibm.fhir.model.type.Code; otherwise false 
 
- 
isElement
public static boolean isElement(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(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(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(Class<?> type)
- Returns:
 - true if 
typeis a model class that represents a FHIR resource or element; otherwise false 
 
- 
isPrimitiveType
public static boolean isPrimitiveType(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(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(Class<?> modelClass, 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(Class<?> modelClass, 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(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(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(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(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(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(Class<?> modelClass, 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 ZonedDateTime truncateTime(ZonedDateTime dateTime, ChronoUnit unit)
- Returns:
 - a copy of the passed ZonedDateTime with the time truncated to 
unit 
 
- 
truncateTime
public static LocalTime truncateTime(LocalTime time, ChronoUnit unit)
- Returns:
 - a copy of the passed LocalTime with the time truncated to 
unit 
 
- 
truncateTime
public static TemporalAccessor truncateTime(TemporalAccessor ta, ChronoUnit unit)
- Returns:
 - a copy of the passed TemporalAccessor with the time truncated to 
unit 
 
- 
isKeyword
public static boolean isKeyword(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 String delimit(String identifier)
Wraps the passed string identifier for use in FHIRPath 
- 
getSystem
public static String getSystem(Code code)
- Returns:
 - the implicit system for 
codeif present, otherwise null 
 
- 
getDataType
public static Class<?> getDataType(String typeName)
- Returns:
 - the data type class associated with 
typeNameparameter if exists, otherwise null 
 
- 
isCodeSubtype
public static boolean isCodeSubtype(String name)
 
- 
getCodeSubtypes
public static Collection<Class<?>> getCodeSubtypes()
 
 - 
 
 -