@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; FieldPathUpdate that = (FieldPathUpdate) o; if (docType != null ? !docType.equals(that.docType) : that.docType != null) return false; if (originalFieldPath != null ? !originalFieldPath.equals(that.originalFieldPath) : that.originalFieldPath != null) return false; if (whereClause != null ? !whereClause.equals(that.whereClause) : that.whereClause != null) return false; return true; }
/** * Return whether this document type inherits the given document type. * * @param superType The documenttype to check if it inherits. * @return true if it inherits the superType, false if not */ public boolean inherits(DocumentType superType) { if (equals(superType)) return true; for (DocumentType type : inherits) { if (type.inherits(superType)) return true; } return false; }
@Override public boolean equals(Object o) { if (this == o) return true; if (!(o instanceof DocumentUpdate)) return false; DocumentUpdate that = (DocumentUpdate) o; if (docId != null ? !docId.equals(that.docId) : that.docId != null) return false; if (documentType != null ? !documentType.equals(that.documentType) : that.documentType != null) return false; if (!fieldPathUpdates.equals(that.fieldPathUpdates)) return false; if (!id2FieldUpdates.equals(that.id2FieldUpdates)) return false; if (this.getCreateIfNonExistent() != ((DocumentUpdate) o).getCreateIfNonExistent()) return false; return true; }
private void verifyType(Document doc) { if (!documentType.equals(doc.getDataType())) { throw new IllegalArgumentException( "Document " + doc.getId() + " with type " + doc.getDataType() + " must have same type as update, which is type " + documentType); } } /**
/** * Adds all the field- and field path updates of the given document update to this. If the given update refers to a * different document or document type than this, this method throws an exception. * * @param update The update whose content to add to this. * @throws IllegalArgumentException If the {@link DocumentId} or {@link DocumentType} of the given DocumentUpdate * does not match the content of this. */ public void addAll(DocumentUpdate update) { if (update == null) { return; } if (!docId.equals(update.docId)) { throw new IllegalArgumentException("Expected " + docId + ", got " + update.docId + "."); } if (!documentType.equals(update.documentType)) { throw new IllegalArgumentException("Expected " + documentType + ", got " + update.documentType + "."); } addFieldUpdates(update.fieldUpdates()); for (FieldPathUpdate pathUpd : update.fieldPathUpdates) { addFieldPathUpdate(pathUpd); } }