From 66422bd1c592638fab50373394fbc94a1693bd54 Mon Sep 17 00:00:00 2001 From: Devin Smith Date: Fri, 1 Apr 2022 10:25:00 -0700 Subject: [PATCH] review changes --- .../appmode/ApplicationServiceGrpcImpl.java | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/server/src/main/java/io/deephaven/server/appmode/ApplicationServiceGrpcImpl.java b/server/src/main/java/io/deephaven/server/appmode/ApplicationServiceGrpcImpl.java index 76696ef9b6e..94e4066345c 100644 --- a/server/src/main/java/io/deephaven/server/appmode/ApplicationServiceGrpcImpl.java +++ b/server/src/main/java/io/deephaven/server/appmode/ApplicationServiceGrpcImpl.java @@ -252,18 +252,18 @@ private void notifyObserverAborted() { } private void create(AppFieldId id, String description, String type) { - computeIfAbsent(id).create(description, type); + accumulated(id).create(description, type); } private void update(AppFieldId id, String description, String type) { - computeIfAbsent(id).update(description, type); + accumulated(id).update(description, type); } private void remove(AppFieldId id) { - computeIfAbsent(id).remove(); + accumulated(id).remove(); } - private State computeIfAbsent(AppFieldId id) { + private State accumulated(AppFieldId id) { return accumulated.computeIfAbsent(id, this::newState); } @@ -332,18 +332,18 @@ public void remove() { this.type = null; } - public void append(Updater builder) { + public void append(Updater updater) { switch (out) { case NOOP: break; case CREATED: - builder.onCreated(id, fieldInfo()); + updater.onCreated(id, fieldInfo()); break; case UPDATED: - builder.onUpdated(id, fieldInfo()); + updater.onUpdated(id, fieldInfo()); break; case REMOVED: - builder.onRemoved(id, Objects.requireNonNull(existing)); + updater.onRemoved(id, Objects.requireNonNull(existing)); break; default: throw new IllegalStateException("Unexpected state " + out); @@ -375,7 +375,9 @@ private FieldInfo fieldInfo() { } } - // An "updater" as opposed to a "builder" - modifies state and is builder. + /** + * Modifies {@code known} state while also building {@link FieldsChangeUpdate}. + */ private class Updater { private final FieldsChangeUpdate.Builder builder = FieldsChangeUpdate.newBuilder(); private boolean isEmpty = true;