net.percederberg.mibble.type

## Class ChoiceType

- java.lang.Object
- - net.percederberg.mibble.MibType
  - - net.percederberg.mibble.type.ChoiceType

-     public class ChoiceType
      extends MibType

  A choice MIB type. In some other languages this is known as a union.
  Since:
    2.0

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `ChoiceType(java.util.ArrayList<ElementType> elements)` Creates a new choice MIB type.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `MibType` | `createReference()` Creates a type reference to this type.
    `ElementType[]` | `getAllElements()` Returns all the element types.
    `MibType` | `initialize(MibSymbol symbol, MibLoaderLog log)` Initializes the MIB type.
    `boolean` | `isCompatible(MibValue value)` Checks if the specified value is compatible with this type.
    `java.lang.String` | `toString()` Returns a string representation of this object.

    - ### Methods inherited from class net.percederberg.mibble.MibType

      `createReference, createReference, getComment, getName, getReferenceSymbol, getTag, hasReferenceTo, hasReferenceTo, hasTag, hasTag, isPrimitive, setReferenceSymbol, setTag`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### ChoiceType

          public ChoiceType(java.util.ArrayList<ElementType> elements)

      Creates a new choice MIB type.
      Parameters:
        `elements` - the list of element types

  - ### Method Detail

    - #### initialize

          public MibType initialize(MibSymbol symbol,
                           MibLoaderLog log)
                             throws MibException

      Initializes the MIB type. This will remove all levels of indirection present, such as references to types or values. No information is lost by this operation. This method may modify this object as a side-effect, and will return the basic type.

      NOTE: This is an internal method that should only be called by the MIB loader.

      Specified by:
        `initialize` in class `MibType`
      Parameters:
        `symbol` - the MIB symbol containing this type
        `log` - the MIB loader log
      Returns:
        the basic MIB type
      Throws:
        `MibException` - if an error was encountered during the initialization
      Since:
        2.2

    - #### createReference

          public MibType createReference()

      Creates a type reference to this type. The type reference is normally an identical type, but with the primitive flag set to false. Only certain types support being referenced, and the default implementation of this method throws an exception.

      NOTE: This is an internal method that should only be called by the MIB loader.

      Overrides:
        `createReference` in class `MibType`
      Returns:
        the MIB type reference
      Since:
        2.2

    - #### isCompatible

          public boolean isCompatible(MibValue value)

      Checks if the specified value is compatible with this type. A values is considered compatible with this type, if it is compatible with any single type in the union.
      Specified by:
        `isCompatible` in class `MibType`
      Parameters:
        `value` - the value to check
      Returns:
        true if the value is compatible, or false otherwise

    - #### getAllElements

          public ElementType[] getAllElements()

      Returns all the element types. These are the types that the choice type consists of.
      Returns:
        an array of the element types
      Since:
        2.2

    - #### toString

          public java.lang.String toString()

      Returns a string representation of this object.
      Overrides:
        `toString` in class `MibType`
      Returns:
        a string representation of this object