Package org.apache.ignite.plugin.extensions.communication.mappers

## Interface EnumMapper<T extends Enum<T>>

- Type Parameters:
    `T` - The enum type for which this mapper provides encoding/decoding logic.

      public interface EnumMapper<T extends Enum<T>>

  An interface to implement custom serialization and deserialization of enum values used in network communication.

  This interface allows users to define a custom mapping between enum constants and their `byte` representations sent over the wire, instead of relying on the default ordinal-based encoding. It can be used in conjunction with the `org.apache.ignite.internal.CustomMapper` annotation to plug in user-defined mapping logic during generation of serialization code.

  Implementations must ensure that:

  - Each enum constant maps to a unique `byte` value.
  - The `byte` codes are stable and consistent across all nodes in the cluster.
  - The `decode(byte)` method handles invalid or unknown codes appropriately (e.g., throws an exception or returns a default).

  Example implementation:

       public class MyColorMapper implements CustomMapper<Color> {
           public byte encode(Color color) {
               switch (color) {
                   case null:  return -1;
                   case RED:   return 0;
                   case GREEN: return 1;
                   case BLUE:  return 2;
                   default:    throw new IllegalArgumentException("Unknown color: " + color);
               }
           }

           public Color decode(byte code) {
               switch (code) {
                   case -1: return null;
                   case 0: return Color.RED;
                   case 1: return Color.GREEN;
                   case 2: return Color.BLUE;
                   default: throw new IllegalArgumentException("Unknown color code: " + code);
               }
           }
       }

  Note: This interface is used in Ignite's communication layer to enable evolution of enum types between different versions of the software.

  See Also:
    `CustomMapper`, `DefaultEnumMapper`

- - ### Method Summary

    All Methods Instance Methods Abstract Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `T` | `decode​(byte code)` | Decodes a `byte` code received from the network into the corresponding enum constant.
    `byte` | `encode​(T val)` | Encodes given enum value into a `byte` representation to be sent over the network.

- - ### Method Detail

    - #### encode

          byte encode​(T val)

      Encodes given enum value into a `byte` representation to be sent over the network.
      Parameters:
        `val` - The enum value to encode; may be `null` depending on implementation contract.
      Returns:
        The `byte` representation of the enum value.

    - #### decode

          T decode​(byte code)

      Decodes a `byte` code received from the network into the corresponding enum constant.
      Parameters:
        `code` - The `byte` representation of the enum value.
      Returns:
        The decoded enum value.
      Throws:
        `IllegalArgumentException` - if the code does not correspond to any valid enum constant.