summaryrefslogtreecommitdiffstats
path: root/document
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2018-07-20 14:05:26 +0200
committerHenning Baldersheim <balder@yahoo-inc.com>2018-07-20 14:05:26 +0200
commite4eeaf0806416d5e15cfe0e9300f246e6b3093e7 (patch)
tree96803ba916b29c4556fc8e3aaca2de0b4f8ed9e0 /document
parent127b0d5c0eaa2701bfe3d2e8899251a6270314ee (diff)
Update javadoc.
Improve error message and produce it in one place.
Diffstat (limited to 'document')
-rw-r--r--document/src/main/java/com/yahoo/document/DocumentUpdate.java20
1 files changed, 10 insertions, 10 deletions
diff --git a/document/src/main/java/com/yahoo/document/DocumentUpdate.java b/document/src/main/java/com/yahoo/document/DocumentUpdate.java
index ef5fdc290c7..91e4a7091b8 100644
--- a/document/src/main/java/com/yahoo/document/DocumentUpdate.java
+++ b/document/src/main/java/com/yahoo/document/DocumentUpdate.java
@@ -97,6 +97,12 @@ public class DocumentUpdate extends DocumentOperation implements Iterable<FieldP
docId = id;
}
+ 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);
+ }
+ }
/**
* Applies this document update.
*
@@ -105,10 +111,7 @@ public class DocumentUpdate extends DocumentOperation implements Iterable<FieldP
* @throws IllegalArgumentException if the document does not have the same document type as this update
*/
public DocumentUpdate applyTo(Document doc) {
- if (!documentType.equals(doc.getDataType())) {
- throw new IllegalArgumentException(
- "Document " + doc + " must have same type as update, which is type " + documentType);
- }
+ verifyType(doc);
for (FieldUpdate fieldUpdate : fieldUpdates) {
fieldUpdate.applyTo(doc);
@@ -120,18 +123,15 @@ public class DocumentUpdate extends DocumentOperation implements Iterable<FieldP
}
/**
- * Will prune away any field update that will not modify any field in the document.
- * @param doc
+ * Prune away any field update that will not modify any field in the document.
+ * @param doc document to check against
* @return a reference to itself
* @throws IllegalArgumentException if the document does not have the same document type as this update
*/
public DocumentUpdate prune(Document doc) {
if ( ! fieldPathUpdates.isEmpty()) return this;
- if (!documentType.equals(doc.getDataType())) {
- throw new IllegalArgumentException(
- "Document " + doc + " must have same type as update, which is type " + documentType);
- }
+ verifyType(doc);
for (Iterator<FieldUpdate> iter = fieldUpdates.iterator(); iter.hasNext();) {
FieldUpdate update = iter.next();