java.lang.Object
org.gcube.informationsystem.resourceregistry.persistence.C3Linearization

public final class C3Linearization extends Object
Implements the C3 linearization (Method Resolution Order) merge step used to deterministically order a Type's ancestors under multiple inheritance.
Author:
Luca Frosini (ISTI - CNR)
  • Method Details

    • merge

      public static List<String> merge(String typeName, List<List<String>> sequences) throws org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaException
      Merges the given sequences following the C3 algorithm: repeatedly takes the head of the first sequence that does not appear in the tail of any other sequence, until all sequences are consumed.
      Parameters:
      typeName - the name of the type being linearized, used only for the error message
      sequences - each direct parent's own linearization (parent first), plus the local precedence list of direct parents in declaration order, last
      Returns:
      the merged, linearized list of ancestor names
      Throws:
      org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaException - if no consistent linearization exists (multiple-inheritance conflict)