public synchronized SerializerRegistry register(Class<?> type, int id, TypeSerializerFactory factory) {
    if (type == null)
      throw new NullPointerException("type cannot be null");

    // If the type ID has already been registered, throw an exception.
    if (types.containsKey(id) && types.get(id) != type) {
      throw new RegistrationException("serializable type ID already registered: " + id);
    }

    // If the type has already been registered, throw an exception if the IDs don't match.
    if (ids.containsKey(type)) {
      if (ids.get(type) != id) {
        throw new RegistrationException("type registered with a different ID: " + type);
      }
      return this;
    }

    factories.put(type, factory);
    types.put(id, type);
    ids.put(type, id);

    return this;
  }
public synchronized SerializerRegistry register ( Class < ? > type , int id , TypeSerializerFactory factory ) { if ( type == null ) throw new NullPointerException ( "type cannot be null" ) ; if ( types . containsKey ( id ) && types . get ( id ) != type ) { throw new RegistrationException ( "serializable type ID already registered: " + id ) ; } if ( ids . containsKey ( type ) ) { if ( ids . get ( type ) != id ) { throw new RegistrationException ( "type registered with a different ID: " + type ) ; } return this ; } factories . put ( type , factory ) ; types . put ( id , type ) ; ids . put ( type , id ) ; return this ; }
Registers the given class for serialization.

@param type The serializable class.
@param factory The serializer factory.
@param id The serializable type ID.
@return The serializer registry.
@throws RegistrationException If the given {@code type} or {@code id} is already registered