io.getstream.core.models.Data Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of stream-java Show documentation
Show all versions of stream-java Show documentation
Stream Feeds Java Client for backend and android integrations
package io.getstream.core.models;
import static com.google.common.base.Preconditions.checkNotNull;
import static io.getstream.core.utils.Serialization.convert;
import com.fasterxml.jackson.annotation.JsonAnyGetter;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.google.common.base.MoreObjects;
import com.google.common.collect.Maps;
import io.getstream.core.models.serialization.DataDeserializer;
import java.util.Map;
import java.util.Objects;
@JsonDeserialize(using = DataDeserializer.class)
public final class Data {
private final String id;
private final Map data = Maps.newHashMap();
public Data(String id) {
this.id = checkNotNull(id, "ID required");
}
public Data() {
this("");
}
public static Data buildFrom(T data) {
return convert(data, Data.class);
}
public String getID() {
return id;
}
@JsonAnyGetter
public Map getData() {
return data;
}
public Data set(String key, T value) {
checkNotNull(key, "Key can't be null");
data.put(key, value);
return this;
}
public Data from(T data) {
return from(convert(data, new TypeReference
© 2015 - 2025 Weber Informatics LLC | Privacy Policy