public final Deserializer deserializeWithId(Deserializer buf) {
        int id = buf.getInt(null);
        if (id != getClassId()) {
            Class<?> spec = registry.get(id);
            if (spec != null) {
                throw new IllegalArgumentException(
                        "Can not deserialize class '" + getClass().getName() + "' (id " + getClassId() + ") from " +
                        "buffer containing class '" + spec.getName() + "' (id " + id + ").");
            } else {
                throw new IllegalArgumentException(
                        "Can not deserialize class '" + getClass().getName() + "' (id " + getClassId() + ") from " +
                        "buffer containing unknown class id " + id + ".");
            }
        }
        return deserialize(buf);
    }
Deserializes the content of this class from the given byte buffer. This method deserialize a class identifier
first, and asserts that this identifier matches the identifier of this class. This is usable if you have an
instance of a class whose content you wish to retrieve from a buffer.

@param buf The buffer to deserialize from.
@return The buffer argument, to allow chaining.
@throws IllegalArgumentException Thrown if the deserialized class identifier does not match this class.
vespajlib/src/main/java/com/yahoo/vespa/objects/Identifiable.java