Interface UnionType

All Superinterfaces:
ItemType, SchemaComponent, SchemaType, SimpleType
All Known Implementing Classes:
ErrorType, NumericType

public interface UnionType extends SimpleType, ItemType
Interface representing a union type. This may be either a built-in union type (of which there are currently two, namely ErrorType and NumericType), or a user-defined union type.
  • Method Details

    • containsListType

      boolean containsListType() throws MissingComponentException
      Ask whether the union contains a list type among its member types
      Returns:
      true of one of the member types is a list type
      Throws:
      MissingComponentException
    • getPlainMemberTypes

      Iterable<PlainType> getPlainMemberTypes() throws MissingComponentException
      Get the "plain" types in the transitive membership. Plain types are atomic types and union types that are defined directly in terms of other plain types, without adding any restriction facets.
      Returns:
      the atomic types and plain union types in the transitive membership of the union type.
      Throws:
      MissingComponentException
    • getResultTypeOfCast

      SequenceType getResultTypeOfCast()
      Get the result type of a cast operation to this union type, as a sequence type.
      Returns:
      the result type of casting, as precisely as possible. For example, if all the member types of the union are derived from the same primitive type, this will return that primitive type.
    • checkAgainstFacets

      ValidationFailure checkAgainstFacets(AtomicValue value, ConversionRules rules)
      Validate an atomic value, which is known to be an instance of one of the member types of the union, against any facets (pattern facets or enumeration facets) defined at the level of the union itself.
      Parameters:
      value - the Atomic Value to be checked. This must be an instance of a member type of the union
      rules - the ConversionRules for the Configuration
      Returns:
      a ValidationFailure if the value is not valid; null if it is valid.
    • explainMismatch

      default Optional<String> explainMismatch(Item item, TypeHierarchy th)
      Get extra diagnostic information about why a supplied item does not conform to this item type, if available. If extra information is returned, it should be in the form of a complete sentence, minus the closing full stop. No information should be returned for obvious cases.
      Specified by:
      explainMismatch in interface ItemType
      Parameters:
      item - the item that doesn't match this type
      th - the type hierarchy cache
      Returns:
      optionally, a message explaining why the item does not match the type