
org.moskito.central.Snapshot Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of moskito-central-core Show documentation
Show all versions of moskito-central-core Show documentation
shared stuff between all projects.
package org.moskito.central;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlSeeAlso;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
/**
* Represents a single snapshot.
*
* @author lrosenberg
* @since 15.03.13 23:15
*/
@XmlRootElement(name = "snsh")
@XmlAccessorType(XmlAccessType.FIELD)
@XmlSeeAlso({ HashMap.class })
public class Snapshot implements Serializable {
/**
* Serialversion uid.
*/
private static final long serialVersionUID = -1452811059878773956L;
/**
* The metadata. The metadata contains data about the snapshot like
* producerId or timestamp.
*/
@XmlElement(name = "snshmd")
private SnapshotMetaData metaData;
/**
* Stat values.
*/
@XmlJavaTypeAdapter(MapAdapter.class)
private HashMap> stats = new HashMap>();
/**
* Default constructor.
*/
public Snapshot() {
}
public SnapshotMetaData getMetaData() {
return metaData;
}
public void setMetaData(SnapshotMetaData metaData) {
this.metaData = metaData;
}
/**
* Adds snapshot data to the stats map.
*
* @param name
* @param values
*/
public void addSnapshotData(String name, HashMap values) {
stats.put(name, values);
}
@Override
public String toString() {
return "Snapshot [metaData=" + metaData + ", stats=" + stats + "]";
}
/**
* Gets statistics by specified {@link String} key.
*
* @param stat
* @return {@link Map}
*/
public Map getStatistics(String stat) {
return stats.get(stat);
}
public Set>> getEntrySet() {
return stats.entrySet();
}
public Set getKeySet() {
return stats.keySet();
}
/**
* Gets all statistics.
*
* @return {@link HashMap>}
*/
public HashMap> getStats() {
if (stats == null) {
stats = new HashMap>();
}
return stats;
}
public void setStats(HashMap> stats) {
this.stats = stats;
}
/**
* XmlAdapter for String, HashMap.
*
* @author dagafonov
*
*/
public static class MapAdapter extends HashMapAdapter> {
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy