mirror of
https://github.com/google/nomulus.git
synced 2025-04-30 20:17:51 +02:00
Create key based on the change type (#1147)
* Create key based on the change type
This commit is contained in:
parent
b9e8694792
commit
3dc4cd8e4f
1 changed files with 5 additions and 5 deletions
|
@ -105,20 +105,20 @@ public abstract class MutatingCommand extends ConfirmingCommand implements Comma
|
||||||
*/
|
*/
|
||||||
private EntityChange(ImmutableObject oldEntity, ImmutableObject newEntity, VKey<?> vkey) {
|
private EntityChange(ImmutableObject oldEntity, ImmutableObject newEntity, VKey<?> vkey) {
|
||||||
type = ChangeType.get(oldEntity != null, newEntity != null);
|
type = ChangeType.get(oldEntity != null, newEntity != null);
|
||||||
Key<?> oldKey = Key.create(oldEntity), newKey = Key.create(newEntity);
|
|
||||||
if (type == ChangeType.UPDATE) {
|
if (type == ChangeType.UPDATE) {
|
||||||
checkArgument(
|
checkArgument(
|
||||||
oldKey.equals(newKey), "Both entity versions in an update must have the same Key.");
|
Key.create(oldEntity).equals(Key.create(newEntity)),
|
||||||
|
"Both entity versions in an update must have the same Key.");
|
||||||
checkArgument(
|
checkArgument(
|
||||||
oldKey.equals(vkey.getOfyKey()),
|
Key.create(oldEntity).equals(vkey.getOfyKey()),
|
||||||
"The Key of the entity must be the same as the OfyKey of the vkey");
|
"The Key of the entity must be the same as the OfyKey of the vkey");
|
||||||
} else if (type == ChangeType.CREATE) {
|
} else if (type == ChangeType.CREATE) {
|
||||||
checkArgument(
|
checkArgument(
|
||||||
newKey.equals(vkey.getOfyKey()),
|
Key.create(newEntity).equals(vkey.getOfyKey()),
|
||||||
"Both entity versions in an update must have the same Key.");
|
"Both entity versions in an update must have the same Key.");
|
||||||
} else if (type == ChangeType.DELETE) {
|
} else if (type == ChangeType.DELETE) {
|
||||||
checkArgument(
|
checkArgument(
|
||||||
oldKey.equals(vkey.getOfyKey()),
|
Key.create(oldEntity).equals(vkey.getOfyKey()),
|
||||||
"The Key of the entity must be the same as the OfyKey of the vkey");
|
"The Key of the entity must be the same as the OfyKey of the vkey");
|
||||||
}
|
}
|
||||||
this.oldEntity = oldEntity;
|
this.oldEntity = oldEntity;
|
||||||
|
|
Loading…
Add table
Reference in a new issue