mirror of
https://github.com/google/nomulus.git
synced 2025-05-15 08:57:12 +02:00
Replace command.applyTo() with inlined builder operations
These are much easier to understand. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=137446273
This commit is contained in:
parent
b84d7f1fb5
commit
1dbc5f6bb0
28 changed files with 489 additions and 426 deletions
|
@ -14,7 +14,6 @@
|
|||
|
||||
package google.registry.model.eppinput;
|
||||
|
||||
import static com.google.common.collect.Sets.intersection;
|
||||
import static google.registry.util.CollectionUtils.nullSafeImmutableCopy;
|
||||
import static google.registry.util.CollectionUtils.nullToEmptyImmutableCopy;
|
||||
|
||||
|
@ -83,9 +82,7 @@ public interface ResourceCommand {
|
|||
}
|
||||
|
||||
/** A create command, or the inner change (as opposed to add or remove) part of an update. */
|
||||
public interface ResourceCreateOrChange<B extends Builder<?>> {
|
||||
public abstract void applyTo(B builder);
|
||||
}
|
||||
public interface ResourceCreateOrChange<B extends Builder<?>> {}
|
||||
|
||||
/**
|
||||
* An update command for an {@link EppResource}.
|
||||
|
@ -133,18 +130,5 @@ public interface ResourceCommand {
|
|||
A remove = getNullableInnerRemove();
|
||||
return remove == null ? new TypeInstantiator<A>(getClass()){}.instantiate() : remove;
|
||||
}
|
||||
|
||||
public void applyTo(B builder) throws AddRemoveSameValueException {
|
||||
getInnerChange().applyTo(builder);
|
||||
if (!intersection(getInnerAdd().getStatusValues(), getInnerRemove().getStatusValues())
|
||||
.isEmpty()) {
|
||||
throw new AddRemoveSameValueException();
|
||||
}
|
||||
builder.addStatusValues(getInnerAdd().getStatusValues());
|
||||
builder.removeStatusValues(getInnerRemove().getStatusValues());
|
||||
}
|
||||
}
|
||||
|
||||
/** Exception for adding and removing the same value in {@link ResourceUpdate#applyTo}. */
|
||||
public static class AddRemoveSameValueException extends Exception {}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue