*/
private static final int DEFAULT_BUFFER_SIZE = 4096;
- /**
- * ID to use if this KryoNamespace does not define registration id.
- */
- private static final int FLOATING_ID = -1;
-
/**
* Smallest ID free to use for user defined registrations.
*/
*/
private static final class Builder implements JournalSerdes.Builder {
private final int blockHeadId = INITIAL_ID;
- private final List<Entry<Class<?>[], Serializer<?>>> types = new ArrayList<>();
+ private final List<Entry<Class<?>[], EntrySerializer<?>>> types = new ArrayList<>();
private final List<RegistrationBlock> blocks = new ArrayList<>();
private ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
@Override
- public Builder register(final Serializer<?> serializer, final Class<?>... classes) {
- types.add(Map.entry(classes, serializer));
+ public Builder register(final EntrySerdes<?> serdes, final Class<?>... classes) {
+ types.add(Map.entry(classes, new EntrySerializer<>(serdes)));
return this;
}
for (RegistrationBlock block : registeredBlocks) {
int id = block.begin();
- if (id == FLOATING_ID) {
- id = kryo.getNextRegistrationId();
- }
- for (Entry<Class<?>[], Serializer<?>> entry : block.types()) {
+ for (Entry<Class<?>[], EntrySerializer<?>> entry : block.types()) {
register(kryo, entry.getKey(), entry.getValue(), id++);
}
}
static final class RegistrationBlock {
private final int begin;
- private final ImmutableList<Entry<Class<?>[], Serializer<?>>> types;
+ private final ImmutableList<Entry<Class<?>[], EntrySerializer<?>>> types;
- RegistrationBlock(final int begin, final List<Entry<Class<?>[], Serializer<?>>> types) {
+ RegistrationBlock(final int begin, final List<Entry<Class<?>[], EntrySerializer<?>>> types) {
this.begin = begin;
this.types = ImmutableList.copyOf(types);
}
return begin;
}
- public ImmutableList<Entry<Class<?>[], Serializer<?>>> types() {
+ public ImmutableList<Entry<Class<?>[], EntrySerializer<?>>> types() {
return types;
}