diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2022-06-09 08:28:04 +0200 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2022-06-09 09:04:38 +0200 |
commit | 96a614df9b572b7244ab38d525c19ede5806a8b0 (patch) | |
tree | 95eed962389d5f69750d164521f5fb05858eebf3 /document/src/main/java | |
parent | 49ba34e36453b42c8a81fcf525cea043cef6c193 (diff) |
Avoid Serializable interface and use typed Comparable<T>
Diffstat (limited to 'document/src/main/java')
6 files changed, 12 insertions, 20 deletions
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]; |