io.hypertrack.model.HyperTrackModel Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of hypertrack-java Show documentation
Show all versions of hypertrack-java Show documentation
A Java wrapper for the HyperTrack API https://hypertrack.io
The newest version!
package io.hypertrack.model;
import com.google.gson.Gson;
import java.util.Map;
/**
* Abstract class for all HyperTrack models.
* Each model is a map of POJO properties.
*/
public abstract class HyperTrackModel {
/** Properties map. */
private Map properties;
protected HyperTrackModel() {
this(null);
}
protected HyperTrackModel(final Map properties) {
this.properties = properties;
}
/**
* Check if key exists in object properties.
*
* @param key Key to be checked
* @return True if key exists, false otherwise
*/
public Boolean existsProperty(String key) {
return properties.containsKey(key);
}
/**
* Return object properties.
*
* @return Instance properties
*/
public String getProperties() {
Gson gson = new Gson();
return gson.toJson(this.properties);
}
/**
* Get value of specific key.
*
* @param key Key to be returned
* @return Value for key
*/
public Object getProperty(String key) {
return properties.get(key);
}
/**
* Set properties of the instance.
*
* @param params New properties to be saved
*/
public void setProperties(Map params) {
this.properties = params;
}
/**
* Set value to specific key.
*
* @param key Key to be set.
* @param value New value to be set.
*/
public void setProperty(String key, Object value) {
this.properties.put(key, value);
}
/**
* Return id of instance.
*
* @return Id of instance
*/
public String getId() {
return (String)this.getProperty("id");
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy