Interface ComponentEncoder<I extends Component, R>

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

public interface ComponentEncoder<I extends Component, R>
A Component encoder, which provides serialization, but without deserialization.

For both serialization and deserialization, use ComponentSerializer

Since:
4.14.0
  • Method Summary

    Modifier and Type
    Method
    Description
    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

    • serialize

      R serialize(I component)
      Serializes a component into an output of type R.
      Parameters:
      component - the component
      Returns:
      the output
      Since:
      4.14.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.

      Parameters:
      component - the component
      Returns:
      the output if component is non-null, otherwise null
      Since:
      4.14.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.

      Parameters:
      component - the component
      fallback - the fallback value
      Returns:
      the output if component is non-null, otherwise fallback
      Since:
      4.14.0