2020-06-06 18:45:20 +02:00
|
|
|
package org.mercury_im.messenger.core.data.repository;
|
2019-11-18 00:04:28 +01:00
|
|
|
|
2019-11-18 23:51:27 +01:00
|
|
|
import org.mercury_im.messenger.entity.Account;
|
2020-06-06 18:45:20 +02:00
|
|
|
import org.mercury_im.messenger.core.util.Optional;
|
2019-11-18 00:04:28 +01:00
|
|
|
|
|
|
|
import java.util.List;
|
2019-12-21 16:30:14 +01:00
|
|
|
import java.util.UUID;
|
2019-11-18 00:04:28 +01:00
|
|
|
|
|
|
|
import io.reactivex.Completable;
|
|
|
|
import io.reactivex.Maybe;
|
|
|
|
import io.reactivex.Observable;
|
|
|
|
import io.reactivex.Single;
|
|
|
|
|
|
|
|
public interface AccountRepository {
|
|
|
|
|
|
|
|
Single<Account> insertAccount(Account account);
|
|
|
|
|
2020-01-05 15:50:35 +01:00
|
|
|
default Observable<Optional<Account>> observeAccount(Account account) {
|
|
|
|
return observeAccount(account.getId());
|
|
|
|
}
|
|
|
|
|
2019-12-21 16:30:14 +01:00
|
|
|
Observable<Optional<Account>> observeAccount(UUID accountId);
|
2019-11-18 00:04:28 +01:00
|
|
|
|
2020-01-05 15:50:35 +01:00
|
|
|
default Maybe<Account> getAccount(Account account) {
|
|
|
|
return getAccount(account.getId());
|
|
|
|
}
|
|
|
|
|
2019-12-21 16:30:14 +01:00
|
|
|
Maybe<Account> getAccount(UUID accountId);
|
2019-11-18 00:04:28 +01:00
|
|
|
|
|
|
|
Observable<Optional<Account>> observeAccountByAddress(String address);
|
|
|
|
|
|
|
|
Maybe<Account> getAccountByAddress(String address);
|
|
|
|
|
|
|
|
Observable<List<Account>> observeAllAccounts();
|
|
|
|
|
2019-12-20 10:41:55 +01:00
|
|
|
Observable<Account> observeAccounts();
|
|
|
|
|
2019-11-18 00:04:28 +01:00
|
|
|
Single<Account> updateAccount(Account account);
|
|
|
|
|
|
|
|
Single<Account> upsertAccount(Account account);
|
|
|
|
|
2019-12-22 02:21:19 +01:00
|
|
|
default Completable deleteAccount(Account account) {
|
|
|
|
return deleteAccount(account.getId());
|
|
|
|
}
|
|
|
|
|
|
|
|
Completable deleteAccount(UUID accountId);
|
2019-11-18 00:04:28 +01:00
|
|
|
|
2020-05-31 22:32:33 +02:00
|
|
|
default Completable updateRosterVersion(Account account, String rosterVersion) {
|
|
|
|
return updateRosterVersion(account.getId(), rosterVersion);
|
|
|
|
}
|
|
|
|
|
|
|
|
Completable updateRosterVersion(UUID accountId, String rosterVersion);
|
|
|
|
|
2019-11-18 00:04:28 +01:00
|
|
|
}
|