package biz.plexers.sparrow.core;

import java.util.HashMap;

public class ResourcesManager {

	private HashMap<Resource.Choices, Resource> resources;

	public void changeResourceBy(Resource.Choices resourceType, int offset) {

		Resource tempRes = resources.get(resourceType);

		if (tempRes != null) {
			tempRes.changeQ(offset);
		}
	}

	public void consume(ResourcesManager other) {

		for (Resource.Choices choice : Resource.Choices.values()) {
			Resource thisTempRes = resources.get(choice);
			Resource otherTempRes = resources.get(choice);

			if (thisTempRes != null) {
				thisTempRes.consume(otherTempRes);
			} else {
				resources.put(choice, otherTempRes);
			}
		}
	}

}

@@ -46,23 +46,479 @@
 ava.
-util.HashMap;%0D%0A
+io.IOException;%0D%0Aimport java.util.HashMap;%0D%0Aimport java.util.Map;%0D%0A%0D%0Aimport com.fasterxml.jackson.annotation.JsonCreator;%0D%0Aimport com.fasterxml.jackson.core.JsonGenerator;%0D%0Aimport com.fasterxml.jackson.core.JsonProcessingException;%0D%0Aimport com.fasterxml.jackson.databind.JsonSerializer;%0D%0Aimport com.fasterxml.jackson.databind.SerializerProvider;%0D%0Aimport com.fasterxml.jackson.databind.annotation.JsonSerialize;%0D%0A%0D%0A@JsonSerialize(using = ResourcesManager.Serializer.class)
 %0D%0Apu
@@ -1165,11 +1165,646 @@
 %0D%0A%09%7D%0D%0A%0D%0A
+%09private ResourcesManager(Map%3CString, Object%3E props) %7B%0D%0A%09%09resources = (HashMap%3CResource.Choices, Resource%3E) props%0D%0A%09%09%09%09.get(%22resources%22);%0D%0A%09%7D%0D%0A%0D%0A%09@JsonCreator%0D%0A%09public static ResourcesManager factory(Map%3CString, Object%3E props) %7B%0D%0A%09%09return new ResourcesManager(props);%0D%0A%09%7D%0D%0A%0D%0A%09public class Serializer extends JsonSerializer%3CResourcesManager%3E %7B%0D%0A%0D%0A%09%09@Override%0D%0A%09%09public void serialize(ResourcesManager value, JsonGenerator jgen,%0D%0A%09%09%09%09SerializerProvider provider) throws IOException,%0D%0A%09%09%09%09JsonProcessingException %7B%0D%0A%09%09%09jgen.writeStartObject();%0D%0A%09%09%09jgen.writeObjectField(%22resources%22, resources);%0D%0A%09%09%09jgen.writeEndObject();%0D%0A%0D%0A%09%09%7D%0D%0A%0D%0A%09%7D%0D%0A%0D%0A
 %7D%0D%0A

Make ResourcesManager serializable