/** * Returns whether this field update contains (at least) one update of the given type * * @param classID the classID of ValueUpdates to check for * @return true if there is at least one value update of the given type in this */ public boolean hasValueUpdate(ValueUpdate.ValueUpdateClassID classID) { for (ValueUpdate vupd : valueUpdates) { if (vupd.getValueUpdateClassID() == classID) { return true; } } return false; }
/** * Get value updates with the specified valueUpdateClassID. The caller gets ownership of the returned list, and * subsequent modifications to the list does not change the state of this object. * * @param classID the classID of ValueUpdates to return * @return a List of ValueUpdates of the specified classID (possibly empty, but not null) */ public List<ValueUpdate> getValueUpdates(ValueUpdate.ValueUpdateClassID classID) { List<ValueUpdate> updateList = new ArrayList<>(); for (ValueUpdate vupd : valueUpdates) { if (vupd.getValueUpdateClassID() == classID) { updateList.add(vupd); } } return updateList; }
@Override public void write(FieldUpdate update) { putInt(null, update.getField().getId(Document.SERIALIZED_VERSION)); putInt(null, update.getValueUpdates().size()); for (ValueUpdate vupd : update.getValueUpdates()) { putInt(null, vupd.getValueUpdateClassID().id); vupd.serialize(this, update.getField().getDataType()); } }
@Override public void write(FieldUpdate update) { putInt(null, update.getField().getId(Document.SERIALIZED_VERSION)); putInt(null, update.getValueUpdates().size()); for (ValueUpdate vupd : update.getValueUpdates()) { putInt(null, vupd.getValueUpdateClassID().id); vupd.serialize(this, update.getField().getDataType()); } }
@Override public void write(MapValueUpdate update, DataType superType) { if (superType instanceof ArrayDataType) { CollectionDataType type = (CollectionDataType) superType; IntegerFieldValue index = (IntegerFieldValue) update.getValue(); index.serialize(this); putInt(null, update.getUpdate().getValueUpdateClassID().id); update.getUpdate().serialize(this, type.getNestedType()); } else if (superType instanceof WeightedSetDataType) { writeValue(this, ((CollectionDataType)superType).getNestedType(), update.getValue()); putInt(null, update.getUpdate().getValueUpdateClassID().id); update.getUpdate().serialize(this, DataType.INT); } else { throw new SerializationException("MapValueUpdate only works for arrays and weighted sets"); } }
@Override public void write(MapValueUpdate update, DataType superType) { if (superType instanceof ArrayDataType) { CollectionDataType type = (CollectionDataType) superType; IntegerFieldValue index = (IntegerFieldValue) update.getValue(); index.serialize(this); putInt(null, update.getUpdate().getValueUpdateClassID().id); update.getUpdate().serialize(this, type.getNestedType()); } else if (superType instanceof WeightedSetDataType) { writeValue(this, ((CollectionDataType)superType).getNestedType(), update.getValue()); putInt(null, update.getUpdate().getValueUpdateClassID().id); update.getUpdate().serialize(this, DataType.INT); } else { throw new SerializationException("MapValueUpdate only works for arrays and weighted sets"); } }