Skip to content

Commit

Permalink
review changes
Browse files Browse the repository at this point in the history
  • Loading branch information
devinrsmith committed Apr 1, 2022
1 parent 158568c commit 66422bd
Showing 1 changed file with 11 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 66422bd

Please sign in to comment.