aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/collect
diff options
context:
space:
mode:
authorGravatar shahan <shahan@google.com>2018-02-20 13:20:30 -0800
committerGravatar Copybara-Service <copybara-piper@google.com>2018-02-20 13:22:33 -0800
commit80a0633bbeef3f84ab6eb6513a5d36936cd1bdbb (patch)
treea4ce5b4d8422a6103d0c93fb6ed8db3ccd1f1c22 /src/main/java/com/google/devtools/build/lib/collect
parentdd090a6e8825093e7e5364ed49f16ba68f0fe54c (diff)
Adds ObjectCodecRegistry to {Des|S}erializationContext.
* AutoCodec now delegates to the registry. * Adds getSuperclass logic for resolving a codec. * Small cleanups for classes that break the registry. TODO after this change: * Explicit CODEC definitions are no longer needed and existing ones should be cleaned up. * POLYMORPHIC is no longer be needed and should be cleaned up. PiperOrigin-RevId: 186351845
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/collect')
-rw-r--r--src/main/java/com/google/devtools/build/lib/collect/nestedset/NestedSetCodec.java15
1 files changed, 5 insertions, 10 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/collect/nestedset/NestedSetCodec.java b/src/main/java/com/google/devtools/build/lib/collect/nestedset/NestedSetCodec.java
index ec61883b2a..255456139a 100644
--- a/src/main/java/com/google/devtools/build/lib/collect/nestedset/NestedSetCodec.java
+++ b/src/main/java/com/google/devtools/build/lib/collect/nestedset/NestedSetCodec.java
@@ -42,11 +42,6 @@ import java.util.Map;
public class NestedSetCodec<T> implements ObjectCodec<NestedSet<T>> {
private static final EnumCodec<Order> orderCodec = new EnumCodec<>(Order.class);
- private final ObjectCodec<T> objectCodec;
-
- public NestedSetCodec(ObjectCodec<T> objectCodec) {
- this.objectCodec = objectCodec;
- }
@SuppressWarnings("unchecked")
@Override
@@ -76,7 +71,7 @@ public class NestedSetCodec<T> implements ObjectCodec<NestedSet<T>> {
int nestedSetCount = codedIn.readInt32();
Preconditions.checkState(
nestedSetCount >= 1,
- "Should have at least serialized one nested set, got: %d",
+ "Should have at least serialized one nested set, got: %s",
nestedSetCount);
Order order = orderCodec.deserialize(context, codedIn);
Object children = null;
@@ -131,7 +126,7 @@ public class NestedSetCodec<T> implements ObjectCodec<NestedSet<T>> {
childCodedOut.writeByteArrayNoTag(digest);
} else {
childCodedOut.writeBoolNoTag(false);
- objectCodec.serialize(context, cast(child), childCodedOut);
+ context.serialize(cast(child), childCodedOut);
}
}
}
@@ -141,7 +136,7 @@ public class NestedSetCodec<T> implements ObjectCodec<NestedSet<T>> {
throws IOException, SerializationException {
childCodedOut.writeInt32NoTag(1);
T singleChild = cast(children);
- objectCodec.serialize(context, singleChild, childCodedOut);
+ context.serialize(singleChild, childCodedOut);
}
private Object deserializeOneNestedSet(
@@ -157,7 +152,7 @@ public class NestedSetCodec<T> implements ObjectCodec<NestedSet<T>> {
if (childCount > 1) {
result = deserializeMultipleItemChildArray(context, digestToChild, childCodedIn, childCount);
} else if (childCount == 1) {
- result = objectCodec.deserialize(context, childCodedIn);
+ result = context.deserialize(childCodedIn);
} else {
result = NestedSet.EMPTY_CHILDREN;
}
@@ -179,7 +174,7 @@ public class NestedSetCodec<T> implements ObjectCodec<NestedSet<T>> {
children[i] =
Preconditions.checkNotNull(digestToChild.get(digest), "Transitive nested set missing");
} else {
- children[i] = objectCodec.deserialize(context, childCodedIn);
+ children[i] = context.deserialize(childCodedIn);
}
}
return children;