@CanIgnoreReturnValue
    public <KeyT extends Key, SerializationT extends Serialization> Builder registerKeySerializer(
        KeySerializer<KeyT, SerializationT> serializer) throws GeneralSecurityException {
      SerializerIndex index =
          new SerializerIndex(serializer.getKeyClass(), serializer.getSerializationClass());
      if (keySerializerMap.containsKey(index)) {
        KeySerializer<?, ?> existingSerializer = keySerializerMap.get(index);
        if (!existingSerializer.equals(serializer) || !serializer.equals(existingSerializer)) {
          throw new GeneralSecurityException(
              "Attempt to register non-equal serializer for already existing object of type: "
                  + index);
        }
      } else {
        keySerializerMap.put(index, serializer);
      }
      return this;
    }
Registers a key serializer for later use in {@link #serializeKey}.

<p>This registers a key serializer which can later be used to serialize a key by calling
{@link #serializeKey}. If a serializer for the pair {@code (KeyT, SerializationT)} has
already been registered, this checks if they are the same. If they are, the call is ignored,
otherwise an exception is thrown.
java_src/src/main/java/com/google/crypto/tink/internal/SerializationRegistry.java