type, CDAClient client) {
this.type = type;
@@ -357,7 +357,7 @@ public Query reverseOrderBy(String key) {
* Limits the amount of elements to a given number.
*
* If more then the number given elements are present, you can use {@link #skip(int)} and
- * {@link #limit(int)} for pagination.
+ * {@see #limit(int)} for pagination.
*
* @param limit a non negative number less than 1001 to include elements.
* @return the calling query for chaining.
diff --git a/src/main/java/com/contentful/java/cda/ArrayResource.java b/src/main/java/com/contentful/java/cda/ArrayResource.java
index 75221d26..99901b10 100644
--- a/src/main/java/com/contentful/java/cda/ArrayResource.java
+++ b/src/main/java/com/contentful/java/cda/ArrayResource.java
@@ -8,7 +8,8 @@
*
* @see CDAResource
*/
-abstract class ArrayResource extends CDAResource {
+public abstract class ArrayResource extends CDAResource {
+ private static final long serialVersionUID = -2702554830040250962L;
List items;
Map assets;
diff --git a/src/main/java/com/contentful/java/cda/CDAArray.java b/src/main/java/com/contentful/java/cda/CDAArray.java
index be2b770d..2aad79a9 100644
--- a/src/main/java/com/contentful/java/cda/CDAArray.java
+++ b/src/main/java/com/contentful/java/cda/CDAArray.java
@@ -8,6 +8,7 @@
* Collection of CDA resources.
*/
public class CDAArray extends ArrayResource {
+ private static final long serialVersionUID = 6596224363025698245L;
int total;
int skip;
diff --git a/src/main/java/com/contentful/java/cda/CDAAsset.java b/src/main/java/com/contentful/java/cda/CDAAsset.java
index 592289cc..b304124b 100644
--- a/src/main/java/com/contentful/java/cda/CDAAsset.java
+++ b/src/main/java/com/contentful/java/cda/CDAAsset.java
@@ -10,6 +10,8 @@
*/
public class CDAAsset extends LocalizedResource {
+ private static final long serialVersionUID = -4645571481643616657L;
+
/**
* @return title of this asset.
*/
@@ -53,7 +55,7 @@ public String urlForImageWith(ImageOption... options) {
}
final Map mappedOptions
- = new LinkedHashMap(options.length);
+ = new LinkedHashMap<>(options.length);
for (final ImageOption option : options) {
mappedOptions.put(option.getOperation(), option);
diff --git a/src/main/java/com/contentful/java/cda/CDAClient.java b/src/main/java/com/contentful/java/cda/CDAClient.java
index d7ef80ba..79e35943 100644
--- a/src/main/java/com/contentful/java/cda/CDAClient.java
+++ b/src/main/java/com/contentful/java/cda/CDAClient.java
@@ -31,7 +31,6 @@
import io.reactivex.functions.Function;
import okhttp3.Call;
import okhttp3.OkHttpClient;
-import retrofit2.Response;
import retrofit2.Retrofit;
import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory;
import retrofit2.converter.gson.GsonConverterFactory;
@@ -126,7 +125,7 @@ private static CDAService createService(Builder clientBuilder) {
* @see #fetchSpace()
*/
public FetchQuery fetch(Class type) {
- return new FetchQuery(type, this);
+ return new FetchQuery<>(type, this);
}
/**
@@ -140,7 +139,7 @@ public FetchQuery fetch(Class type) {
* @see #observeSpace()
*/
public ObserveQuery observe(Class type) {
- return new ObserveQuery(type, this);
+ return new ObserveQuery<>(type, this);
}
/**
@@ -223,7 +222,7 @@ public Flowable observeContentTypeCachePopulation(final int limit) {
.all()
.map(
new Function() {
- @Override public CDAArray apply(CDAArray array) throws Exception {
+ @Override public CDAArray apply(CDAArray array) {
if (array.skip() + array.limit() < array.total()) {
return nextPage(array);
} else {
@@ -250,20 +249,18 @@ private CDAArray nextPage(CDAArray array) {
}
)
.map(
- new Function() {
- @Override public Integer apply(CDAArray array) throws Exception {
- for (CDAResource resource : array.items) {
- if (resource instanceof CDAContentType) {
- cache.types().put(resource.id(), (CDAContentType) resource);
- } else {
- throw new IllegalStateException(
- "Requesting a list of content types should not return "
- + "any other type.");
- }
+ array -> {
+ for (CDAResource resource : array.items) {
+ if (resource instanceof CDAContentType) {
+ cache.types().put(resource.id(), (CDAContentType) resource);
+ } else {
+ throw new IllegalStateException(
+ "Requesting a list of content types should not return "
+ + "any other type.");
}
-
- return array.total;
}
+
+ return array.total;
}
);
}
@@ -363,11 +360,7 @@ public > C fetchSpace(C callback) {
* @return an {@link Flowable} that fetches the space for this client.
*/
public Flowable observeSpace() {
- return service.space(spaceId).map(new Function, CDASpace>() {
- @Override public CDASpace apply(Response extends CDASpace> response) throws Exception {
- return fromResponse(response);
- }
- });
+ return service.space(spaceId).map(ResourceFactory::fromResponse);
}
/**
@@ -375,28 +368,18 @@ public Flowable observeSpace() {
*/
Flowable cacheAll(final boolean invalidate) {
return cacheLocales(invalidate)
- .flatMap(new Function, Flowable