/** Registers the class using the lowest, next available integer ID and the specified serializer. If the class is already * registered, the existing entry is updated with the new serializer. Registering a primitive also affects the corresponding * primitive wrapper. * <p> * Because the ID assigned is affected by the IDs registered before it, the order classes are registered is important when * using this method. The order must be the same at deserialization as it was for serialization. */ public Registration register (Class type, Serializer serializer) { Registration registration = classResolver.getRegistration(type); if (registration != null) { registration.setSerializer(serializer); return registration; } return classResolver.register(new Registration(type, serializer, getNextRegistrationId())); }
/** Registers the class using the lowest, next available integer ID and the specified serializer. If the class is already * registered, the existing entry is updated with the new serializer. Registering a primitive also affects the corresponding * primitive wrapper. * <p> * Because the ID assigned is affected by the IDs registered before it, the order classes are registered is important when * using this method. The order must be the same at deserialization as it was for serialization. */ public Registration register (Class type, Serializer serializer) { Registration registration = classResolver.getRegistration(type); if (registration != null) { registration.setSerializer(serializer); return registration; } return classResolver.register(new Registration(type, serializer, getNextRegistrationId())); }
/** Registers the class using the lowest, next available integer ID and the specified serializer. If the class is already * registered, the existing entry is updated with the new serializer. Registering a primitive also affects the corresponding * primitive wrapper. * <p> * Because the ID assigned is affected by the IDs registered before it, the order classes are registered is important when * using this method. The order must be the same at deserialization as it was for serialization. */ public Registration register (Class type, Serializer serializer) { Registration registration = classResolver.getRegistration(type); if (registration != null) { registration.setSerializer(serializer); return registration; } return classResolver.register(new Registration(type, serializer, getNextRegistrationId())); }
/** Registers the class using the lowest, next available integer ID and the specified serializer. If the class is already * registered, the existing entry is updated with the new serializer. Registering a primitive also affects the corresponding * primitive wrapper. * <p> * Because the ID assigned is affected by the IDs registered before it, the order classes are registered is important when * using this method. The order must be the same at deserialization as it was for serialization. */ public Registration register (Class type, Serializer serializer) { Registration registration = classResolver.getRegistration(type); if (registration != null) { registration.setSerializer(serializer); return registration; } return classResolver.register(new Registration(type, serializer, getNextRegistrationId())); }
/** Stores the specified registration. If the ID is already in use by the same type, the old entry is overwritten. Registering * a primitive also affects the corresponding primitive wrapper. * <p> * IDs must be the same at deserialization as they were for serialization. * <p> * Registration can be suclassed to efficiently store per type information, accessible in serializers via * {@link Kryo#getRegistration(Class)}. */ public Registration register (Registration registration) { int id = registration.getId(); if (id < 0) throw new IllegalArgumentException("id must be > 0: " + id); Registration existing = getRegistration(registration.getId()); if (DEBUG && existing != null && existing.getType() != registration.getType()) { debug("An existing registration with a different type already uses ID: " + registration.getId() + "\nExisting registration: " + existing + "\nis now overwritten with: " + registration); } return classResolver.register(registration); }
/** Stores the specified registration. If the ID is already in use by the same type, the old entry is overwritten. If the ID is * already in use by a different type, a {@link KryoException} is thrown. Registering a primitive also affects the * corresponding primitive wrapper. * <p> * IDs must be the same at deserialization as they were for serialization. * <p> * Registration can be suclassed to efficiently store per type information, accessible in serializers via * {@link Kryo#getRegistration(Class)}. */ public Registration register (Registration registration) { int id = registration.getId(); if (id < 0) throw new IllegalArgumentException("id must be > 0: " + id); Registration existing = getRegistration(registration.getId()); if (DEBUG && existing != null && existing.getType() != registration.getType()) { debug("An existing registration with a different type already uses ID: " + registration.getId() + "\nExisting registration: " + existing + "\nUnable to set registration: " + registration); } return classResolver.register(registration); }
/** Stores the specified registration. If the ID is already in use by the same type, the old entry is overwritten. Registering * a primitive also affects the corresponding primitive wrapper. * <p> * IDs must be the same at deserialization as they were for serialization. * <p> * Registration can be suclassed to efficiently store per type information, accessible in serializers via * {@link Kryo#getRegistration(Class)}. */ public Registration register (Registration registration) { int id = registration.getId(); if (id < 0) throw new IllegalArgumentException("id must be > 0: " + id); Registration existing = getRegistration(registration.getId()); if (DEBUG && existing != null && existing.getType() != registration.getType()) { debug("An existing registration with a different type already uses ID: " + registration.getId() + "\nExisting registration: " + existing + "\nis now overwritten with: " + registration); } return classResolver.register(registration); }
/** Stores the specified registration. If the ID is already in use by the same type, the old entry is overwritten. If the ID is * already in use by a different type, a {@link KryoException} is thrown. Registering a primitive also affects the * corresponding primitive wrapper. * <p> * IDs must be the same at deserialization as they were for serialization. * <p> * Registration can be suclassed to efficiently store per type information, accessible in serializers via * {@link Kryo#getRegistration(Class)}. */ public Registration register (Registration registration) { int id = registration.getId(); if (id < 0) throw new IllegalArgumentException("id must be > 0: " + id); Registration existing = getRegistration(registration.getId()); if (existing != null && existing.getType() != registration.getType()) { throw new KryoException("An existing registration with a different type already uses ID: " + registration.getId() + "\nExisting registration: " + existing + "\nUnable to set registration: " + registration); } return classResolver.register(registration); }