convert middleware to javax.annotations
This commit is contained in:
parent
defaaa19cd
commit
6ebc9b2ad0
3 changed files with 18 additions and 20 deletions
|
@ -4,11 +4,11 @@ package com.nytimes.android.external.store.middleware;
|
|||
import com.google.gson.Gson;
|
||||
import com.nytimes.android.external.store.base.Parser;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.Reader;
|
||||
import java.lang.reflect.Type;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import okio.BufferedSource;
|
||||
|
||||
/**
|
||||
|
@ -22,8 +22,8 @@ public final class GsonParserFactory {
|
|||
* Returns a new Parser which parses from {@link Reader} to the specified type, using
|
||||
* a new default configured {@link Gson} instance.
|
||||
*/
|
||||
@NotNull
|
||||
public static <T> Parser<Reader, T> createReaderParser(@NotNull Type type) {
|
||||
@Nonnull
|
||||
public static <T> Parser<Reader, T> createReaderParser(@Nonnull Type type) {
|
||||
return createReaderParser(new Gson(), type);
|
||||
}
|
||||
|
||||
|
@ -31,8 +31,8 @@ public final class GsonParserFactory {
|
|||
* Returns a new Parser which parses from {@link Reader} to the specified type, using
|
||||
* the provided {@link Gson} instance.
|
||||
*/
|
||||
@NotNull
|
||||
public static <T> Parser<Reader, T> createReaderParser(@NotNull Gson gson, @NotNull Type type) {
|
||||
@Nonnull
|
||||
public static <T> Parser<Reader, T> createReaderParser(@Nonnull Gson gson, @Nonnull Type type) {
|
||||
return new GsonReaderParser<>(gson, type);
|
||||
}
|
||||
|
||||
|
@ -40,8 +40,8 @@ public final class GsonParserFactory {
|
|||
* Returns a new Parser which parses from {@link Reader} to the specified type, using
|
||||
* a new default configured {@link Gson} instance.
|
||||
*/
|
||||
@NotNull
|
||||
public static <T> Parser<BufferedSource, T> createSourceParser(@NotNull Type type) {
|
||||
@Nonnull
|
||||
public static <T> Parser<BufferedSource, T> createSourceParser(@Nonnull Type type) {
|
||||
return createSourceParser(new Gson(), type);
|
||||
}
|
||||
|
||||
|
@ -49,8 +49,8 @@ public final class GsonParserFactory {
|
|||
* Returns a new Parser which parses from {@link BufferedSource} to the specified type, using
|
||||
* the provided {@link Gson} instance.
|
||||
*/
|
||||
@NotNull
|
||||
public static <T> Parser<BufferedSource, T> createSourceParser(@NotNull Gson gson, @NotNull Type type) {
|
||||
@Nonnull
|
||||
public static <T> Parser<BufferedSource, T> createSourceParser(@Nonnull Gson gson, @Nonnull Type type) {
|
||||
return new GsonSourceParser<>(gson, type);
|
||||
}
|
||||
|
||||
|
@ -58,8 +58,8 @@ public final class GsonParserFactory {
|
|||
* Returns a new Parser which parses from a String to the specified type, using
|
||||
* a new default {@link Gson} instance.
|
||||
*/
|
||||
@NotNull
|
||||
public static <T> Parser<String, T> createStringParser(@NotNull Class<T> type) {
|
||||
@Nonnull
|
||||
public static <T> Parser<String, T> createStringParser(@Nonnull Class<T> type) {
|
||||
return createStringParser(new Gson(), type);
|
||||
}
|
||||
|
||||
|
@ -67,8 +67,8 @@ public final class GsonParserFactory {
|
|||
* Returns a new Parser which parses from a String to the specified type, using
|
||||
* the provided {@link Gson} instance.
|
||||
*/
|
||||
@NotNull
|
||||
public static <T> Parser<String, T> createStringParser(@NotNull Gson gson, @NotNull Type type) {
|
||||
@Nonnull
|
||||
public static <T> Parser<String, T> createStringParser(@Nonnull Gson gson, @Nonnull Type type) {
|
||||
return new GsonStringParser<>(gson, type);
|
||||
}
|
||||
|
||||
|
|
|
@ -3,11 +3,10 @@ package com.nytimes.android.external.store.middleware;
|
|||
import com.google.gson.Gson;
|
||||
import com.nytimes.android.external.store.base.Parser;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.Reader;
|
||||
import java.lang.reflect.Type;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.inject.Inject;
|
||||
|
||||
import static com.nytimes.android.external.cache.Preconditions.checkNotNull;
|
||||
|
@ -26,7 +25,7 @@ public class GsonReaderParser<Parsed> implements Parser<Reader, Parsed> {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Parsed call(@NotNull Reader reader) {
|
||||
public Parsed call(@Nonnull Reader reader) {
|
||||
return gson.fromJson(reader, type);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,12 +4,11 @@ package com.nytimes.android.external.store.middleware;
|
|||
import com.google.gson.Gson;
|
||||
import com.nytimes.android.external.store.base.Parser;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.lang.reflect.Type;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.inject.Inject;
|
||||
|
||||
import okio.BufferedSource;
|
||||
|
@ -43,7 +42,7 @@ public class GsonSourceParser<Parsed> implements Parser<BufferedSource, Parsed>
|
|||
}
|
||||
|
||||
@Override
|
||||
public Parsed call(@NotNull BufferedSource source) {
|
||||
public Parsed call(@Nonnull BufferedSource source) {
|
||||
try (InputStreamReader reader = new InputStreamReader(source.inputStream(), UTF_8)) {
|
||||
return gson.fromJson(reader, type);
|
||||
} catch (IOException e) {
|
||||
|
|
Loading…
Reference in a new issue