Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MLIBZ-3120: Data Requests Kotlin migration #264

Merged
merged 3 commits into from Sep 5, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion java-api-core/src/com/kinvey/java/cache/ICache.kt
Expand Up @@ -133,5 +133,5 @@ interface ICache<T : GenericJson> {
* @param q query to filter results
* @return the array of groups containing the result of the reduce function
*/
fun group(aggregateType: AggregateType, fields: ArrayList<String>, reduceField: String, q: Query): Array<Aggregation.Result>
fun group(aggregateType: AggregateType, fields: ArrayList<String>, reduceField: String?, q: Query): Array<Aggregation.Result>
}
4 changes: 2 additions & 2 deletions java-api-core/src/com/kinvey/java/model/Aggregation.kt
Expand Up @@ -26,9 +26,9 @@ import com.google.api.client.util.Key
*
* @author edwardf
*/
class Aggregation(var res: List<Result>?) {
class Aggregation(var res: List<out Result>?) {

var results: List<Result> = res ?: mutableListOf()
var results: List<out Result> = res ?: mutableListOf()

/**
* Return a list of result values from the aggregation
Expand Down
10 changes: 5 additions & 5 deletions java-api-core/src/com/kinvey/java/store/BaseDataStore.kt
Expand Up @@ -235,7 +235,7 @@ open class BaseDataStore<T : GenericJson> @JvmOverloads protected constructor(
* @return items count in collection
*/
@Throws(IOException::class)
fun count(cachedCallback: KinveyCachedClientCallback<Int>?): Int {
fun count(cachedCallback: KinveyCachedClientCallback<Int>?): Int? {
Preconditions.checkNotNull(client, "client must not be null.")
Preconditions.checkArgument(client.isInitialize, "client must be initialized.")
Preconditions.checkArgument(cachedCallback == null || storeType == StoreType.CACHE, "KinveyCachedClientCallback can only be used with StoreType.CACHE")
Expand All @@ -252,7 +252,7 @@ open class BaseDataStore<T : GenericJson> @JvmOverloads protected constructor(
* @return count of queried items in collection
*/
@Throws(IOException::class)
fun count(cachedCallback: KinveyCachedClientCallback<Int>?, query: Query): Int {
fun count(cachedCallback: KinveyCachedClientCallback<Int>?, query: Query): Int? {
Preconditions.checkNotNull(client, "client must not be null.")
Preconditions.checkArgument(client.isInitialize, "client must be initialized.")
Preconditions.checkArgument(cachedCallback == null || storeType == StoreType.CACHE, "KinveyCachedClientCallback can only be used with StoreType.CACHE")
Expand All @@ -268,7 +268,7 @@ open class BaseDataStore<T : GenericJson> @JvmOverloads protected constructor(
* @return items count in collection on the server
*/
@Throws(IOException::class)
fun countNetwork(): Int {
fun countNetwork(): Int? {
Preconditions.checkNotNull(client, "client must not be null.")
Preconditions.checkArgument(client.isInitialize, "client must be initialized.")
return ReadCountRequest(cache, networkManager, ReadPolicy.FORCE_NETWORK, null, client.syncManager).execute()?.count ?: 0
Expand Down Expand Up @@ -377,7 +377,7 @@ open class BaseDataStore<T : GenericJson> @JvmOverloads protected constructor(
* @throws IOException
*/
@Throws(IOException::class)
fun delete(query: Query): Int {
fun delete(query: Query): Int? {
Preconditions.checkNotNull(client, "client must not be null.")
Preconditions.checkArgument(client.isInitialize, "client must be initialized.")
Preconditions.checkNotNull(query, "query must not be null.")
Expand All @@ -391,7 +391,7 @@ open class BaseDataStore<T : GenericJson> @JvmOverloads protected constructor(
* @throws IOException
*/
@Throws(IOException::class)
fun delete(ids: Iterable<String>): Int {
fun delete(ids: Iterable<String>): Int? {
Preconditions.checkNotNull(client, "client must not be null.")
Preconditions.checkArgument(client.isInitialize, "client must be initialized.")
Preconditions.checkNotNull(ids, "ids must not be null.")
Expand Down
36 changes: 0 additions & 36 deletions java-api-core/src/com/kinvey/java/store/LinkedBaseDataStore.java

This file was deleted.

32 changes: 32 additions & 0 deletions java-api-core/src/com/kinvey/java/store/LinkedBaseDataStore.kt
@@ -0,0 +1,32 @@
/*
* Copyright (c) 2016, Kinvey, Inc. All rights reserved.
*
* This software is licensed to you under the Kinvey terms of service located at
* http://www.kinvey.com/terms-of-use. By downloading, accessing and/or using this
* software, you hereby accept such terms of service (and any agreement referenced
* therein) and agree that you have read, understand and agree to be bound by such
* terms of service and are of legal age to agree to such terms with Kinvey.
*
* This software contains valuable confidential and proprietary information of
* KINVEY, INC and is subject to applicable licensing agreements.
* Unauthorized reproduction, transmission or distribution of this file and its
* contents is a violation of applicable laws.
*
*/

package com.kinvey.java.store

import com.kinvey.java.AbstractClient
import com.kinvey.java.LinkedResources.LinkedGenericJson
import com.kinvey.java.network.LinkedNetworkManager

class LinkedBaseDataStore<T : LinkedGenericJson>
/**
* Constructor for creating LinkedBaseDataStore for given collection that will be mapped to itemType class
*
* @param client Kinvey client instance to work with
* @param collection collection name
* @param itemType class that data should be mapped to
* @param storeType type of storage that client want to use
*/
(client: AbstractClient<*>, collection: String, itemType: Class<T>, storeType: StoreType) : BaseDataStore<T>(client, collection, itemType, storeType, LinkedNetworkManager<T>(collection, itemType, client))
Expand Up @@ -48,7 +48,7 @@ class SaveListRequest<T : GenericJson>(private val cache: ICache<T>?, private va

@Throws(IOException::class)
override fun execute(): List<T>? {
var ret: List<T>? = ArrayList()
var ret: List<T>? = mutableListOf()
when (writePolicy) {
WritePolicy.FORCE_LOCAL -> {
ret = cache?.save(objects)
Expand Down