Record Class CompositeMapping

java.lang.Object
java.lang.Record
org.openehealth.ipf.commons.map.CompositeMapping
Record Components:
name - mapping name, unique within a Mappings instance
keySystem - formal identifier of the key code system, may be null
valueSystem - formal identifier of the value code system, may be null
parts - the names of the mappings asked, in order; never empty
override - whether this declaration is meant to replace a mapping of the same name loaded earlier
All Implemented Interfaces:
Mapping

public record CompositeMapping(String name, String keySystem, String valueSystem, List<String> parts, boolean override) extends Record implements Mapping
A mapping that holds no entries of its own but the names of other mappings - its parts - and answers through them. It exists for sources that spread one translation over several tables, the common case being a FHIR ConceptMap whose groups translate one source code system into several target systems. Each group is a SimpleMapping; the composite over them lets a caller ask the ConceptMap as a whole without knowing which groups it has or which one holds a code.

A lookup asks the parts in declaration order, in two rounds:

  1. the first part that declares an entry for the key answers;
  2. only if no part does, the first part whose fallback answers.
So a code declared in the second part is found even if the first part has a fallback that would answer anything - which is how FHIR's $translate reads all groups of a ConceptMap when no target system is given. Reverse lookups work the same way.

Since the parts may translate into different code systems, a plain lookup cannot say which system an answer belongs to; Mappings.translate(String, String) returns it along with the code, taken from the part that answered. The composite's own keySystem() and valueSystem() are whatever its creator declares; the ConceptMap loader sets those that its parts share, and null where they differ.

The parts must be simple mappings registered before the composite, so composites do not nest. No file format declares one - loaders create them - and no MappingWriter writes one: its parts are written instead.

Since:
6.0
  • Constructor Details

    • CompositeMapping

      public CompositeMapping(String name, String keySystem, String valueSystem, List<String> parts, boolean override)
      Creates an instance of a CompositeMapping record class.
      Parameters:
      name - the value for the name record component
      keySystem - the value for the keySystem record component
      valueSystem - the value for the valueSystem record component
      parts - the value for the parts record component
      override - the value for the override record component
  • Method Details

    • entries

      public List<Entry> entries()
      Specified by:
      entries in interface Mapping
      Returns:
      the key/value pairs, in declaration order
    • unmatched

      public Unmatched unmatched()
      Specified by:
      unmatched in interface Mapping
      Returns:
      what to answer when a key has no entry
    • reverseUnmatched

      public Unmatched reverseUnmatched()
      Specified by:
      reverseUnmatched in interface Mapping
      Returns:
      what to answer when a value has no entry
    • reversible

      public boolean reversible()
      Specified by:
      reversible in interface Mapping
      Returns:
      whether a reverse index is built at all
    • builder

      public static CompositeMapping.Builder builder(String name)
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with the compare method from their corresponding wrapper classes.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • name

      public String name()
      Returns the value of the name record component.
      Specified by:
      name in interface Mapping
      Returns:
      the value of the name record component
    • keySystem

      public String keySystem()
      Returns the value of the keySystem record component.
      Specified by:
      keySystem in interface Mapping
      Returns:
      the value of the keySystem record component
    • valueSystem

      public String valueSystem()
      Returns the value of the valueSystem record component.
      Specified by:
      valueSystem in interface Mapping
      Returns:
      the value of the valueSystem record component
    • parts

      public List<String> parts()
      Returns the value of the parts record component.
      Specified by:
      parts in interface Mapping
      Returns:
      the value of the parts record component
    • override

      public boolean override()
      Returns the value of the override record component.
      Specified by:
      override in interface Mapping
      Returns:
      the value of the override record component