com.dooapp.gaedo.prevalence.space.commands.UpdateInCollection Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of gaedo-prevalence Show documentation
Show all versions of gaedo-prevalence Show documentation
A gaedo-inspired prevalence layer and the associated service, for making the most gaedo-efficient use of that layer
package com.dooapp.gaedo.prevalence.space.commands;
import java.io.Serializable;
import java.util.Collection;
import com.dooapp.gaedo.prevalence.space.Command;
import com.dooapp.gaedo.prevalence.space.StorageSpace;
public class UpdateInCollection implements Command, Serializable {
private Key key;
private DataType value;
public UpdateInCollection(Key storageName, DataType toUpdate) {
this.key = storageName;
this.value = toUpdate;
}
@Override
public DataType execute(StorageSpace storage) {
// Object associated to key must be a collection.
// This is not checked, to ensure fail-fast of this layer
Collection content = (Collection) storage.get(key);
content.remove(value);
content.add(value);
return value;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy