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

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

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

    • deserialize

      @NonNull O deserialize​(@NonNull R input)
      Deserialize a component from input of type R.
      Parameters:
      input - the input
      Returns:
      the component
      Since:
      4.0.0
    • deseializeOrNull

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

      If input is null, then null will be returned.

      Parameters:
      input - the input
      Returns:
      the component if input is non-null, otherwise null
      Since:
      4.7.0
    • deserializeOr

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

      If input is null, then fallback will be returned.

      Parameters:
      input - the input
      fallback - the fallback value
      Returns:
      the component if input is non-null, otherwise fallback
      Since:
      4.7.0
    • serialize

      @NonNull R serialize​(@NonNull I component)
      Serializes a component into an output of type R.
      Parameters:
      component - the component
      Returns:
      the output
      Since:
      4.0.0
    • serializeOrNull

      @Contract(value="!null -> !null; null -> null", pure=true) default @PolyNull R serializeOrNull​(@PolyNull 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.7.0
    • serializeOr

      @Contract(value="!null, _ -> !null; null, _ -> param2", pure=true) default @PolyNull R serializeOr​(@Nullable I component, @PolyNull 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.7.0