Interface ComponentEncoder<I extends Component,​R>

  • Type Parameters:
    I - the input component type
    R - the serialized type
    All Known Subinterfaces:
    ComponentSerializer<I,​O,​R>

    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 Detail

      • serialize

        @NotNull
        R serialize​(@NotNull
                    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)
        @Nullable
        default 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)
        @Nullable
        default 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