diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2018-09-13 10:51:55 +0200 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2018-09-13 10:51:55 +0200 |
commit | e6c49f90583b8e13bf900be110d4aa4cb99a26cf (patch) | |
tree | 79bf053442cae3b032178db3c9c07cad11ef2eef /document/src/main | |
parent | fb0aa3e2df91dec55dcdcee6dfcfabf88fdedf5d (diff) |
Add deprecation comments and some renaming.
Diffstat (limited to 'document/src/main')
-rw-r--r-- | document/src/main/java/com/yahoo/document/DocumentUpdate.java | 26 | ||||
-rw-r--r-- | document/src/main/java/com/yahoo/document/json/DocumentUpdateJsonSerializer.java | 7 |
2 files changed, 27 insertions, 6 deletions
diff --git a/document/src/main/java/com/yahoo/document/DocumentUpdate.java b/document/src/main/java/com/yahoo/document/DocumentUpdate.java index 4f8e3ef3b82..bbd5cfe75fe 100644 --- a/document/src/main/java/com/yahoo/document/DocumentUpdate.java +++ b/document/src/main/java/com/yahoo/document/DocumentUpdate.java @@ -40,6 +40,8 @@ import java.util.Optional; * @see com.yahoo.document.update.FieldUpdate * @see com.yahoo.document.update.ValueUpdate */ +//TODO Vespa 7 Remove all deprecated methods + public class DocumentUpdate extends DocumentOperation implements Iterable<FieldPathUpdate> { //see src/vespa/document/util/identifiableid.h @@ -169,6 +171,7 @@ public class DocumentUpdate extends DocumentOperation implements Iterable<FieldP * Get an unmodifiable list of all field updates that this document update specifies. * * @return a list of all FieldUpdates in this DocumentUpdate + * @deprecated Use fieldUpdates() instead. */ @Deprecated public List<FieldUpdate> getFieldUpdates() { @@ -178,9 +181,9 @@ public class DocumentUpdate extends DocumentOperation implements Iterable<FieldP /** * Get an unmodifiable collection of all field updates that this document update specifies. * - * @return a list of all FieldUpdates in this DocumentUpdate + * @return a collection of all FieldUpdates in this DocumentUpdate */ - public Collection<FieldUpdate> getFieldUpdatesCollection() { + public Collection<FieldUpdate> fieldUpdates() { return Collections.unmodifiableCollection(id2FieldUpdateMap.values()); } @@ -188,11 +191,22 @@ public class DocumentUpdate extends DocumentOperation implements Iterable<FieldP * Get an unmodifiable list of all field path updates this document update specifies. * * @return Returns a list of all field path updates in this document update. + * @deprecated Use fieldPathUpdates() instead. */ + @Deprecated public List<FieldPathUpdate> getFieldPathUpdates() { return Collections.unmodifiableList(fieldPathUpdates); } + /** + * Get an unmodifiable collection of all field path updates that this document update specifies. + * + * @return a collection of all FieldPathUpdates in this DocumentUpdate + */ + public Collection<FieldPathUpdate> fieldPathUpdates() { + return Collections.unmodifiableCollection(fieldPathUpdates); + } + /** Returns the type of the document this updates * * @return The documentype of the document @@ -215,6 +229,7 @@ public class DocumentUpdate extends DocumentOperation implements Iterable<FieldP * @param index the index of the FieldUpdate to return * @return the FieldUpdate at the specified index * @throws IndexOutOfBoundsException if index is out of range + * @deprecated use getFieldUpdate(Field field) instead. */ @Deprecated public FieldUpdate getFieldUpdate(int index) { @@ -228,6 +243,7 @@ public class DocumentUpdate extends DocumentOperation implements Iterable<FieldP * @param upd the FieldUpdate to be stored at the specified position * @return the FieldUpdate previously at the specified position * @throws IndexOutOfBoundsException if index is out of range + * @deprecated Use removeFieldUpdate/addFieldUpdate instead */ @Deprecated public FieldUpdate setFieldUpdate(int index, FieldUpdate upd) { @@ -274,11 +290,14 @@ public class DocumentUpdate extends DocumentOperation implements Iterable<FieldP * * @param fieldUpdates the new list of updates of this * @throws NullPointerException if the argument passed is null + * @deprecated Iterate and use addFieldUpdate instead */ + @Deprecated public void setFieldUpdates(Collection<FieldUpdate> fieldUpdates) { if (fieldUpdates == null) { throw new NullPointerException("The field updates of a document update can not be null"); } + fieldUpdates.clear(); for (FieldUpdate fieldUpdate : fieldUpdates) { addFieldUpdate(fieldUpdate); } @@ -347,7 +366,7 @@ public class DocumentUpdate extends DocumentOperation implements Iterable<FieldP if (!documentType.equals(update.documentType)) { throw new IllegalArgumentException("Expected " + documentType + ", got " + update.documentType + "."); } - for (FieldUpdate fieldUpd : update.id2FieldUpdateMap.values()) { + for (FieldUpdate fieldUpd : update.fieldUpdates()) { addFieldUpdate(fieldUpd); } for (FieldPathUpdate pathUpd : update.fieldPathUpdates) { @@ -361,6 +380,7 @@ public class DocumentUpdate extends DocumentOperation implements Iterable<FieldP * @param index the index of the FieldUpdate to remove * @return the FieldUpdate previously at the specified position * @throws IndexOutOfBoundsException if index is out of range + * @deprecated use removeFieldUpdate(Field field) instead. */ @Deprecated public FieldUpdate removeFieldUpdate(int index) { diff --git a/document/src/main/java/com/yahoo/document/json/DocumentUpdateJsonSerializer.java b/document/src/main/java/com/yahoo/document/json/DocumentUpdateJsonSerializer.java index 5b1dda0f71c..6adae27cadc 100644 --- a/document/src/main/java/com/yahoo/document/json/DocumentUpdateJsonSerializer.java +++ b/document/src/main/java/com/yahoo/document/json/DocumentUpdateJsonSerializer.java @@ -47,6 +47,7 @@ import java.io.IOException; import java.io.OutputStream; import java.nio.ByteBuffer; import java.util.ArrayList; +import java.util.Collection; import java.util.List; import java.util.Optional; import java.util.regex.Matcher; @@ -105,11 +106,11 @@ public class DocumentUpdateJsonSerializer } generator.writeObjectFieldStart("fields"); - for (FieldUpdate up : update.getFieldUpdatesCollection()) { + for (FieldUpdate up : update.fieldUpdates()) { up.serialize(this); } - update.getFieldPathUpdates().stream() + update.fieldPathUpdates().stream() .collect(Collectors.groupingBy(FieldPathUpdate::getFieldPath)) .forEach((fieldPath, fieldPathUpdates) -> wrapIOException(() -> write(fieldPath, fieldPathUpdates, generator))); @@ -120,7 +121,7 @@ public class DocumentUpdateJsonSerializer }); } - private void write(FieldPath fieldPath, List<FieldPathUpdate> fieldPathUpdates, JsonGenerator generator) throws IOException { + private void write(FieldPath fieldPath, Collection<FieldPathUpdate> fieldPathUpdates, JsonGenerator generator) throws IOException { generator.writeObjectFieldStart(fieldPath.toString()); for (FieldPathUpdate update : fieldPathUpdates) { |