All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.dooapp.gaedo.prevalence.space.commands.UpdateInCollection Maven / Gradle / Ivy

Go to download

A gaedo-inspired prevalence layer and the associated service, for making the most gaedo-efficient use of that layer

There is a newer version: 1.0.16
Show newest version
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