Interface ModelResolver

  • All Known Subinterfaces:
    DataProvider
    All Known Implementing Classes:
    BaseModelResolver, CompositeDataProvider, SystemDataProvider

    public interface ModelResolver
    A ModelResolver provides support for mapping a logical model (e.g. QDM or FHIR) onto a Java implementation of that model. Different implementations of the same model might map to different implementation schemes with the simplest example being classes in different package names, but also possibly with different property naming schemes, etc.
    • Method Summary

      All Methods Instance Methods Abstract Methods Default Methods Deprecated Methods 
      Modifier and Type Method Description
      java.lang.Object as​(java.lang.Object value, java.lang.Class<?> type, boolean isStrict)
      Cast the specified value to the specified type.
      java.lang.Object createInstance​(java.lang.String typeName)
      Create an instance of the model object that corresponds to the specified type.
      java.lang.Object getContextPath​(java.lang.String contextType, java.lang.String targetType)
      Get the path expression that expresses the relationship between the targetType and the given contextType.
      java.lang.String getPackageName()
      Deprecated.
      Use getPackageNames() instead
      default java.util.List<java.lang.String> getPackageNames()
      Return the package names of Java objects supported by this model
      java.lang.Boolean is​(java.lang.Object value, java.lang.Class<?> type)
      Check whether or not a specified value instance is of the specified type.
      java.lang.Boolean objectEqual​(java.lang.Object left, java.lang.Object right)
      Compare two objects for equality
      java.lang.Boolean objectEquivalent​(java.lang.Object left, java.lang.Object right)
      Compare two objects for equivalence
      java.lang.Object resolvePath​(java.lang.Object target, java.lang.String path)
      Resolve the provided path expression for the provided target.
      java.lang.Class<?> resolveType​(java.lang.Object value)
      Resolve the Java class that corresponds to the given model object instance.
      java.lang.Class<?> resolveType​(java.lang.String typeName)
      Resolve the Java class that corresponds to the given model type
      void setPackageName​(java.lang.String packageName)
      Deprecated.
      Use setPackageNames#String instead
      default void setPackageNames​(java.util.List<java.lang.String> packageNames)
      Set the package names of Java objects supported by this model
      void setValue​(java.lang.Object target, java.lang.String path, java.lang.Object value)
      Set the value of a particular property on the given model object.
    • Method Detail

      • getPackageName

        @Deprecated
        java.lang.String getPackageName()
        Deprecated.
        Use getPackageNames() instead
      • setPackageName

        @Deprecated
        void setPackageName​(java.lang.String packageName)
        Deprecated.
        Use setPackageNames#String instead
      • getPackageNames

        default java.util.List<java.lang.String> getPackageNames()
        Return the package names of Java objects supported by this model
        Returns:
        list of Java package names for model objects that support this model.
      • setPackageNames

        default void setPackageNames​(java.util.List<java.lang.String> packageNames)
        Set the package names of Java objects supported by this model
        Parameters:
        packageNames - list of Java package names for model objects that support this model.
      • resolvePath

        java.lang.Object resolvePath​(java.lang.Object target,
                                     java.lang.String path)
        Resolve the provided path expression for the provided target. Paths can be things like simple dotted property notation (e.g. Patient.id) or more complex things like list indexed property expressions (e.g. Patient.name[0].given). The exact details are configued in the model definition and passed to the ELM file during CQL to ELM translation.
        Returns:
        result of the provided expression. Null is expected whenever a path doesn't exist on the target.
      • getContextPath

        java.lang.Object getContextPath​(java.lang.String contextType,
                                        java.lang.String targetType)
        Get the path expression that expresses the relationship between the targetType and the given contextType. For example, in a FHIR model, with context type Patient and targetType Condition, the resulting path is subject because that is the model property on the Condition object that links the Condition to the Patient.
      • resolveType

        java.lang.Class<?> resolveType​(java.lang.String typeName)
        Resolve the Java class that corresponds to the given model type
        Parameters:
        typeName - Model type name. In the ELM, model objects are namespaced (e.g. FHIR.Patient), but the namespace is removed prior to calling this method, so the input would just be Patient.
        Returns:
        Class object that represents the specified model type
      • resolveType

        java.lang.Class<?> resolveType​(java.lang.Object value)
        Resolve the Java class that corresponds to the given model object instance.
        Parameters:
        value - Object instance
        Returns:
        Class object that represents the specified value
      • is

        java.lang.Boolean is​(java.lang.Object value,
                             java.lang.Class<?> type)
        Check whether or not a specified value instance is of the specified type.
        Parameters:
        value -
        type -
        Returns:
        true when the value is of the specified type, otherwise false.
      • as

        java.lang.Object as​(java.lang.Object value,
                            java.lang.Class<?> type,
                            boolean isStrict)
        Cast the specified value to the specified type. When type conversion is not possible, null should be returned unless the isStrict flag is set to true wherein an Exception will be thrown.
        Parameters:
        value - model object instance
        type - type to which the value should be case
        isStrict - flag indicating how to handle invalid type conversion
        Returns:
        the result of the value conversion or null if conversion is not possible.
      • createInstance

        java.lang.Object createInstance​(java.lang.String typeName)
        Create an instance of the model object that corresponds to the specified type.
        Parameters:
        typeName - Model type to create
        Returns:
        new instance of the specified model type
      • setValue

        void setValue​(java.lang.Object target,
                      java.lang.String path,
                      java.lang.Object value)
        Set the value of a particular property on the given model object.
        Parameters:
        target - model object
        path - path to the property that will be set
        value - value to set to the property indicated by the path expression
      • objectEqual

        java.lang.Boolean objectEqual​(java.lang.Object left,
                                      java.lang.Object right)
        Compare two objects for equality
        Parameters:
        left - left hand side of the equality expression
        right - right hand side of the equality expression
        Returns:
        flag indicating whether the objects are equal
      • objectEquivalent

        java.lang.Boolean objectEquivalent​(java.lang.Object left,
                                           java.lang.Object right)
        Compare two objects for equivalence
        Parameters:
        left - left hand side of the equivalence expression
        right - right hand side of the equivalence expression
        Returns:
        flag indicating whether the objects are equal