diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2022-06-09 10:19:14 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-06-09 10:19:14 +0200 |
commit | 3d914760b13b6202d415df657a9166e74fea7f77 (patch) | |
tree | 95eed962389d5f69750d164521f5fb05858eebf3 | |
parent | 62b7b69a0ea24c60150b98149e9e3190d9301d9b (diff) |
Revert "Revert "Avoid Serializable interface and use typed Comparable<T> MERGEOK""
7 files changed, 19 insertions, 34 deletions
diff --git a/document/abi-spec.json b/document/abi-spec.json index e7960298b90..23b802f6b28 100644 --- a/document/abi-spec.json +++ b/document/abi-spec.json @@ -145,9 +145,7 @@ }, "com.yahoo.document.CompressionConfig": { "superClass": "java.lang.Object", - "interfaces": [ - "java.io.Serializable" - ], + "interfaces": [], "attributes": [ "public" ], @@ -168,7 +166,6 @@ "com.yahoo.document.DataType": { "superClass": "com.yahoo.vespa.objects.Identifiable", "interfaces": [ - "java.io.Serializable", "java.lang.Comparable" ], "attributes": [ @@ -231,9 +228,7 @@ }, "com.yahoo.document.DataTypeName": { "superClass": "java.lang.Object", - "interfaces": [ - "java.io.Serializable" - ], + "interfaces": [], "attributes": [ "public", "final" @@ -334,9 +329,7 @@ }, "com.yahoo.document.DocumentId": { "superClass": "com.yahoo.vespa.objects.Identifiable", - "interfaces": [ - "java.io.Serializable" - ], + "interfaces": [], "attributes": [ "public" ], @@ -643,8 +636,7 @@ "superClass": "com.yahoo.vespa.objects.FieldBase", "interfaces": [ "com.yahoo.document.fieldset.FieldSet", - "java.lang.Comparable", - "java.io.Serializable" + "java.lang.Comparable" ], "attributes": [ "public" @@ -655,7 +647,7 @@ "public void <init>(java.lang.String, com.yahoo.document.DataType, com.yahoo.document.DocumentType)", "public void <init>(java.lang.String, com.yahoo.document.DataType)", "public void <init>(java.lang.String, com.yahoo.document.Field)", - "public int compareTo(java.lang.Object)", + "public int compareTo(com.yahoo.document.Field)", "protected int calculateIdV7(com.yahoo.document.DocumentType)", "public void setId(int, com.yahoo.document.DocumentType)", "public final com.yahoo.document.DataType getDataType()", @@ -667,7 +659,8 @@ "public java.lang.String toString()", "public boolean contains(com.yahoo.document.fieldset.FieldSet)", "public com.yahoo.document.fieldset.FieldSet clone()", - "public bridge synthetic java.lang.Object clone()" + "public bridge synthetic java.lang.Object clone()", + "public bridge synthetic int compareTo(java.lang.Object)" ], "fields": [ "protected com.yahoo.document.DataType dataType", diff --git a/document/src/main/java/com/yahoo/document/CompressionConfig.java b/document/src/main/java/com/yahoo/document/CompressionConfig.java index 69769148869..2fa4e40d5b6 100644 --- a/document/src/main/java/com/yahoo/document/CompressionConfig.java +++ b/document/src/main/java/com/yahoo/document/CompressionConfig.java @@ -3,9 +3,8 @@ package com.yahoo.document; import com.yahoo.compress.CompressionType; -import java.io.Serializable; -public class CompressionConfig implements Serializable { +public class CompressionConfig { public CompressionConfig(CompressionType type, int level, diff --git a/document/src/main/java/com/yahoo/document/DataType.java b/document/src/main/java/com/yahoo/document/DataType.java index d5de78cd21d..b185ff53c87 100644 --- a/document/src/main/java/com/yahoo/document/DataType.java +++ b/document/src/main/java/com/yahoo/document/DataType.java @@ -20,7 +20,6 @@ import com.yahoo.vespa.objects.Identifiable; import com.yahoo.vespa.objects.Ids; import com.yahoo.vespa.objects.ObjectVisitor; -import java.io.Serializable; import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; import java.util.LinkedList; @@ -32,7 +31,7 @@ import java.util.List; * * @author bratseth */ -public abstract class DataType extends Identifiable implements Serializable, Comparable<DataType> { +public abstract class DataType extends Identifiable implements Comparable<DataType> { // The global class identifier shared with C++. public static int classId = registerClass(Ids.document + 50, DataType.class); @@ -280,7 +279,7 @@ public abstract class DataType extends Identifiable implements Serializable, Com */ public FieldPath buildFieldPath(String fieldPathString) { if (fieldPathString.length() > 0) { - throw new IllegalArgumentException("Datatype " + toString() + + throw new IllegalArgumentException("Datatype " + this + " does not support further recursive structure: " + fieldPathString); } return new FieldPath(); @@ -318,7 +317,7 @@ public abstract class DataType extends Identifiable implements Serializable, Com @Override public int compareTo(DataType dataType) { - return Integer.valueOf(dataTypeId).compareTo(dataType.dataTypeId); + return Integer.compare(dataTypeId, dataType.dataTypeId); } /** Returns whether this is a multivalue type, i.e either a CollectionDataType or a MapDataType */ diff --git a/document/src/main/java/com/yahoo/document/DataTypeName.java b/document/src/main/java/com/yahoo/document/DataTypeName.java index b8e956e6b96..ef9ddd2b21d 100644 --- a/document/src/main/java/com/yahoo/document/DataTypeName.java +++ b/document/src/main/java/com/yahoo/document/DataTypeName.java @@ -4,14 +4,12 @@ package com.yahoo.document; import com.yahoo.text.Utf8Array; import com.yahoo.text.Utf8String; -import java.io.Serializable; - /** * A full document type name. The name is case sensitive. This is a <i>value object</i>. * * @author bratseth */ -public final class DataTypeName implements Serializable { +public final class DataTypeName { private final Utf8String name; diff --git a/document/src/main/java/com/yahoo/document/DocumentId.java b/document/src/main/java/com/yahoo/document/DocumentId.java index 3512c5cb7b7..81592a5c9ff 100644 --- a/document/src/main/java/com/yahoo/document/DocumentId.java +++ b/document/src/main/java/com/yahoo/document/DocumentId.java @@ -10,13 +10,12 @@ import com.yahoo.vespa.objects.Deserializer; import com.yahoo.vespa.objects.Identifiable; import com.yahoo.vespa.objects.Serializer; -import java.io.Serializable; import java.util.Objects; /** * The id of a document */ -public class DocumentId extends Identifiable implements Serializable { +public class DocumentId extends Identifiable { private IdString id; private GlobalId globalId = null; diff --git a/document/src/main/java/com/yahoo/document/Field.java b/document/src/main/java/com/yahoo/document/Field.java index e2204ada7e5..dfe51f776e4 100644 --- a/document/src/main/java/com/yahoo/document/Field.java +++ b/document/src/main/java/com/yahoo/document/Field.java @@ -7,8 +7,6 @@ import com.yahoo.document.fieldset.FieldSet; import com.yahoo.document.fieldset.NoFields; import com.yahoo.vespa.objects.FieldBase; -import java.io.Serializable; - /** * A name and type. Fields are contained in document types to describe their fields, * but is also used to represent name/type pairs which are not part of document types. @@ -16,7 +14,7 @@ import java.io.Serializable; * @author Thomas Gundersen * @author bratseth */ -public class Field extends FieldBase implements FieldSet, Comparable, Serializable { +public class Field extends FieldBase implements FieldSet, Comparable<Field> { protected DataType dataType; protected int fieldId; @@ -74,8 +72,8 @@ public class Field extends FieldBase implements FieldSet, Comparable, Serializab this(name, field.dataType, null); } - public int compareTo(Object o) { - return fieldId - ((Field) o).fieldId; + public int compareTo(Field o) { + return fieldId - o.fieldId; } /** diff --git a/document/src/main/java/com/yahoo/document/GlobalId.java b/document/src/main/java/com/yahoo/document/GlobalId.java index b9d454dd007..c378f76a9e8 100644 --- a/document/src/main/java/com/yahoo/document/GlobalId.java +++ b/document/src/main/java/com/yahoo/document/GlobalId.java @@ -16,7 +16,7 @@ import java.util.Arrays; * * @author Simon Thoresen Hult */ -public class GlobalId implements Comparable { +public class GlobalId implements Comparable<GlobalId> { /** * The number of bytes in a global id. This must match the C++ constant in "document/base/globalid.h". @@ -119,9 +119,8 @@ public class GlobalId implements Comparable { return Arrays.equals(raw, rhs.raw); } - public int compareTo(Object o) { - GlobalId other = (GlobalId) o; - + @Override + public int compareTo(GlobalId other) { for (int i=0 ; i<LENGTH; i++) { int thisByte = 0xF & (int) raw[i]; int otherByte = 0xF & (int) other.raw[i]; |