Package com.io7m.cedarbridge.runtime.api

# Interface CBOptionType<T extends CBSerializableType>

Type Parameters:
  `T` - The type of values

All Superinterfaces:
  `CBSerializableType`, `Formattable`

All Known Implementing Classes:
  `CBNone`, `CBSome`

public sealed interface CBOptionType<T extends CBSerializableType> extends Formattable, CBSerializableType permits CBNone<T>, CBSome<T>
The option type.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `Optional<T>`
  `asOptional()`
  `static <T extends CBSerializableType>
  CBOptionType<T>`
  `deserialize(CBSerializationContextType context, CBDeserializeType<T> fv)`
  Deserialize the given value.
  `static <T extends CBSerializableType>
  CBOptionType<T>`
  `fromOptional(Optional<T> opt)`
  Convert the given Java optional value to an option value.
  `static <T extends CBSerializableType>
  void`
  `serialize(CBSerializationContextType context, CBOptionType<T> x, CBSerializeType<T> ft)`
  Serialize the given value.

  ### Methods inherited from interface java.util.Formattable

  `formatTo`

- ## Method Details

  - ### asOptional

    Optional<T> asOptional()
    Returns:
      This value as a Java Optional

  - ### fromOptional

    static <T extends CBSerializableType> CBOptionType<T> fromOptional(Optional<T> opt)
    Convert the given Java optional value to an option value.
    Type Parameters:
      `T` - The type of contained values
    Parameters:
      `opt` - The Java optional
    Returns:
      The option value

  - ### serialize

    static <T extends CBSerializableType> void serialize(CBSerializationContextType context, CBOptionType<T> x, CBSerializeType<T> ft) throws IOException
    Serialize the given value.
    Type Parameters:
      `T` - The type of optional values
    Parameters:
      `context` - The serialization context
      `x` - The value
      `ft` - A serializer for `T`
    Throws:
      `IOException` - On errors

  - ### deserialize

    static <T extends CBSerializableType> CBOptionType<T> deserialize(CBSerializationContextType context, CBDeserializeType<T> fv) throws IOException
    Deserialize the given value.
    Type Parameters:
      `T` - The type of optional values
    Parameters:
      `context` - The serialization context
      `fv` - A deserializer for `T`
    Returns:
      The deserialized value
    Throws:
      `IOException` - On errors