io.getstream.core.models.Content 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.checkArgument;
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.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.type.TypeReference;
import com.google.common.base.MoreObjects;
import com.google.common.collect.Maps;
import java.util.Map;
import java.util.Objects;
public final class Content {
private final String foreignID;
private final Map data = Maps.newHashMap();
@JsonCreator
public Content(@JsonProperty("foreign_id") String foreignID) {
this.foreignID = checkNotNull(foreignID, "ID required");
}
public static Content buildFrom(T data) {
return convert(data, Content.class);
}
@JsonProperty("foreign_id")
public String getForeignID() {
return foreignID;
}
@JsonAnyGetter
public Map getData() {
return data;
}
@JsonAnySetter
public Content set(String key, T value) {
checkArgument(!"foreignID".equals(key), "Key can't be named 'foreignID'");
checkNotNull(key, "Key can't be null");
data.put(key, value);
return this;
}
public Content from(T data) {
checkNotNull(data, "Can't extract data from null");
Map map = convert(data, new TypeReference
© 2015 - 2025 Weber Informatics LLC | Privacy Policy