Package net.sf.saxon.type

## Interface UnionType

- All Superinterfaces:
    `CastingTarget`, `ItemType`
  All Known Implementing Classes:
    `ErrorType`, `LocalUnionType`, `NumericType`, `UserUnionType`

      public interface UnionType
      extends ItemType, CastingTarget

  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.

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from interface net.sf.saxon.type.ItemType

      `ItemType.WithSequenceTypeCache`

  - ### Method Summary

    All Methods Instance Methods Abstract Methods Default Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `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.
    `boolean` | `containsListType()` | Ask whether the union contains a list type among its member types
    `default java.util.Optional<java.lang.String>` | `explainMismatch​(Item item, TypeHierarchy th)` | Get extra diagnostic information about why a supplied item does not conform to this item type, if available.
    `default java.lang.String` | `getDescription()` |
    `java.lang.Iterable<? extends PlainType>` | `getPlainMemberTypes()` | Get the "plain" types in the transitive membership.
    `SequenceType` | `getResultTypeOfCast()` | Get the result type of a cast operation to this union type, as a sequence type.
    `default StructuredQName` | `getStructuredQName()` |
    `AtomicSequence` | `getTypedValue​(java.lang.CharSequence value, NamespaceResolver resolver, ConversionRules rules)` | Get the typed value corresponding to a given string value, assuming it is valid against this type
    `StructuredQName` | `getTypeName()` | Get the name of the type.

    - ### Methods inherited from interface net.sf.saxon.type.ItemType

      `getAtomizedItemType, getBasicAlphaCode, getDefaultPriority, getFullAlphaCode, getGenre, getNormalizedDefaultPriority, getPrimitiveItemType, getPrimitiveType, getUType, isAtomicType, isAtomizable, isPlainType, isTrueItemType, matches, toExportString, toString`

- - ### Method Detail

    - #### getTypeName

          StructuredQName getTypeName()

      Get the name of the type. If the type is unnamed, return an invented type in the `NamespaceConstant.ANONYMOUS` namespace
      Returns:
        the type name

    - #### getStructuredQName

          default StructuredQName getStructuredQName()

    - #### 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

          java.lang.Iterable<? extends 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.

    - #### getTypedValue

          AtomicSequence getTypedValue​(java.lang.CharSequence value,
                                       NamespaceResolver resolver,
                                       ConversionRules rules)
                                throws ValidationException

      Get the typed value corresponding to a given string value, assuming it is valid against this type
      Parameters:
        `value` - the string value
        `resolver` - a namespace resolver used to resolve any namespace prefixes appearing in the content of values. Can supply null, in which case any namespace-sensitive content will be rejected.
        `rules` - the conversion rules from the configuration
      Returns:
        the atomic sequence comprising the typed value. The objects returned by this SequenceIterator will all be of type `AtomicValue`,
      Throws:
        `ValidationException` - if the supplied value is not in the lexical space of the data 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 java.util.Optional<java.lang.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

    - #### getDescription

          default java.lang.String getDescription()