Skip to content
This repository has been archived by the owner on Jan 11, 2024. It is now read-only.

Commit

Permalink
Merge remote-tracking branch 'origin/models_to_kotlin' into models_to…
Browse files Browse the repository at this point in the history
…_kotlin

# Conflicts:
#	app/src/main/java/org/apache/fineract/data/remote/NullOnEmptyConverterFactory.java
  • Loading branch information
jawidMuhammadi committed Jun 1, 2020
2 parents 36090c0 + f2cdb0c commit 2d2beeb
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 22 deletions.
Original file line number Diff line number Diff line change
@@ -1,22 +0,0 @@
package org.apache.fineract.data.remote;

import java.lang.annotation.Annotation;
import java.lang.reflect.Type;

import okhttp3.ResponseBody;
import retrofit2.Converter;
import retrofit2.Retrofit;

public class NullOnEmptyConverterFactory extends Converter.Factory {

@Override
public Converter<ResponseBody, ?> responseBodyConverter(Type type, Annotation[] annotations,
Retrofit retrofit) {
final Converter<ResponseBody, ?> delegate = retrofit.nextResponseBodyConverter(this, type,
annotations);
return (Converter<ResponseBody, Object>) body -> {
if (body.contentLength() == 0) return null;
return delegate.convert(body);
};
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package org.apache.fineract.data.remote

import okhttp3.ResponseBody
import retrofit2.Converter
import retrofit2.Retrofit
import java.lang.reflect.Type

/**
* Created by Ahmad Jawid Muhammadi on 1/6/20
*/

class NullOnEmptyConverterFactory : Converter.Factory() {
override fun responseBodyConverter(type: Type?, annotations: Array<Annotation?>?,
retrofit: Retrofit): Converter<ResponseBody, *> {
val delegate: Converter<ResponseBody, *> = retrofit.nextResponseBodyConverter<Any>(this, type,
annotations)
return Converter { body -> if (body.contentLength() == 0L) null else delegate.convert(body) }
}
}

0 comments on commit 2d2beeb

Please sign in to comment.