Interface ComponentSerializer<I extends Component, O extends Component, R>

Type Parameters:
I - the input component type
O - the output component type
R - the serialized type
All Superinterfaces:
ComponentDecoder<R,O>, ComponentEncoder<I,R>
All Known Subinterfaces:
ConfigurateComponentSerializer, GsonComponentSerializer, JSONComponentSerializer, LegacyComponentSerializer, MiniMessage, PlainTextComponentSerializer

public interface ComponentSerializer<I extends Component, O extends Component, R> extends ComponentEncoder<I,R>, ComponentDecoder<R,O>
A Component serializer and deserializer.
Since:
4.0.0
  • Method Summary

    Modifier and Type
    Method
    Description
    deserialize(R input)
    Deserialize a component from input of type R.
    default @Nullable O
    deserializeOr(@Nullable R input, @Nullable O fallback)
    Deserialize a component from input of type R.
    default @Nullable O
    deserializeOrNull(@Nullable R input)
    Deserialize a component from input of type R.
    serialize(I component)
    Serializes a component into an output of type R.
    default @Nullable R
    serializeOr(@Nullable I component, @Nullable R fallback)
    Serializes a component into an output of type R.
    default @Nullable R
    serializeOrNull(@Nullable I component)
    Serializes a component into an output of type R.
  • Method Details

    • deserialize

      O deserialize(R input)
      Deserialize a component from input of type R.
      Specified by:
      deserialize in interface ComponentDecoder<I extends Component, O extends Component>
      Parameters:
      input - the input
      Returns:
      the component
      Since:
      4.0.0
    • deserializeOrNull

      @Contract(value="!null -> !null; null -> null", pure=true) default @Nullable O deserializeOrNull(@Nullable R input)
      Deserialize a component from input of type R.

      If input is null, then null will be returned.

      Specified by:
      deserializeOrNull in interface ComponentDecoder<I extends Component, O extends Component>
      Parameters:
      input - the input
      Returns:
      the component if input is non-null, otherwise null
      Since:
      4.8.0
    • deserializeOr

      @Contract(value="!null, _ -> !null; null, _ -> param2", pure=true) default @Nullable O deserializeOr(@Nullable R input, @Nullable O fallback)
      Deserialize a component from input of type R.

      If input is null, then fallback will be returned.

      Specified by:
      deserializeOr in interface ComponentDecoder<I extends Component, O extends Component>
      Parameters:
      input - the input
      fallback - the fallback value
      Returns:
      the component if input is non-null, otherwise fallback
      Since:
      4.7.0
    • serialize

      R serialize(I component)
      Serializes a component into an output of type R.
      Specified by:
      serialize in interface ComponentEncoder<I extends Component, O extends Component>
      Parameters:
      component - the component
      Returns:
      the output
      Since:
      4.0.0
    • serializeOrNull

      @Contract(value="!null -> !null; null -> null", pure=true) default @Nullable R serializeOrNull(@Nullable I component)
      Serializes a component into an output of type R.

      If component is null, then null will be returned.

      Specified by:
      serializeOrNull in interface ComponentEncoder<I extends Component, O extends Component>
      Parameters:
      component - the component
      Returns:
      the output if component is non-null, otherwise null
      Since:
      4.7.0
    • serializeOr

      @Contract(value="!null, _ -> !null; null, _ -> param2", pure=true) default @Nullable R serializeOr(@Nullable I component, @Nullable R fallback)
      Serializes a component into an output of type R.

      If component is null, then fallback will be returned.

      Specified by:
      serializeOr in interface ComponentEncoder<I extends Component, O extends Component>
      Parameters:
      component - the component
      fallback - the fallback value
      Returns:
      the output if component is non-null, otherwise fallback
      Since:
      4.7.0