io.getstream.cloud.CloudCollectionsClient 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.cloud;
import static io.getstream.core.utils.Serialization.convert;
import io.getstream.core.StreamCollections;
import io.getstream.core.exceptions.StreamException;
import io.getstream.core.http.Token;
import io.getstream.core.models.CollectionData;
import java8.util.concurrent.CompletableFuture;
public final class CloudCollectionsClient {
private final Token token;
private final String userID;
private final StreamCollections collections;
CloudCollectionsClient(Token token, String userID, StreamCollections collections) {
this.token = token;
this.userID = userID;
this.collections = collections;
}
public CompletableFuture addCustom(String collection, T item) throws StreamException {
return addCustom(userID, collection, item);
}
public CompletableFuture addCustom(String userID, String collection, T item)
throws StreamException {
return add(userID, collection, convert(item, CollectionData.class))
.thenApply(data -> convert(data, (Class) item.getClass()));
}
public CompletableFuture add(String collection, CollectionData item)
throws StreamException {
return add(userID, collection, item);
}
public CompletableFuture add(
String userID, String collection, CollectionData item) throws StreamException {
return collections.add(token, userID, collection, item);
}
public CompletableFuture updateCustom(String collection, T item) throws StreamException {
return updateCustom(userID, collection, item);
}
public CompletableFuture updateCustom(String userID, String collection, T item)
throws StreamException {
return update(userID, collection, convert(item, CollectionData.class))
.thenApply(data -> convert(data, (Class) item.getClass()));
}
public CompletableFuture update(String collection, CollectionData item)
throws StreamException {
return update(userID, collection, item);
}
public CompletableFuture update(
String userID, String collection, CollectionData item) throws StreamException {
return collections.update(token, userID, collection, item);
}
public CompletableFuture getCustom(Class type, String collection, String id)
throws StreamException {
return get(collection, id).thenApply(data -> convert(data, type));
}
public CompletableFuture get(String collection, String id)
throws StreamException {
return collections.get(token, collection, id);
}
public CompletableFuture delete(String collection, String id) throws StreamException {
return collections.delete(token, collection, id);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy