package cz.muni.fi.lasaris.sbms.data.api.response;

import java.util.Map;

import javax.xml.bind.annotation.XmlRootElement;

import com.fasterxml.jackson.annotation.JsonInclude;

import cz.muni.fi.lasaris.sbms.data.entities.Address;
import cz.muni.fi.lasaris.sbms.data.entities.containers.Snapshot;
import cz.muni.fi.lasaris.sbms.data.entities.values.RawValue;

@XmlRootElement
@JsonInclude(JsonInclude.Include.NON_NULL)
public class SnapshotResponse {
	private String error;
	private Snapshot results;
	
	public Map<Address, RawValue> getResults() {
		if(this.results == null) return null;
		
		return this.results.getData();
	}
	
	public static SnapshotResponse getErrorResponse(String error) {
		SnapshotResponse r = new SnapshotResponse();
		r.setError(error);
		return r;
	}
	
	private SnapshotResponse() {
		this.results = null;
	}
	
	public SnapshotResponse(Address a, RawValue v) {
		this.results = new Snapshot();
		this.results.add(a, v);
	}
	
	public SnapshotResponse(Snapshot s) {
		this.results = s;
	}
	
	public String getError() {
		return error;
	}

	public void setError(String error) {
		this.error = error;
	}
}
