From 6ebc9b2ad056b13bdfd4b38578d9ef38a55b0a13 Mon Sep 17 00:00:00 2001 From: Brian Plummer Date: Mon, 30 Jan 2017 21:05:38 -0500 Subject: [PATCH] convert middleware to javax.annotations --- .../store/middleware/GsonParserFactory.java | 28 +++++++++---------- .../store/middleware/GsonReaderParser.java | 5 ++-- .../store/middleware/GsonSourceParser.java | 5 ++-- 3 files changed, 18 insertions(+), 20 deletions(-) diff --git a/middleware/src/main/java/com/nytimes/android/external/store/middleware/GsonParserFactory.java b/middleware/src/main/java/com/nytimes/android/external/store/middleware/GsonParserFactory.java index e099713..c42441e 100644 --- a/middleware/src/main/java/com/nytimes/android/external/store/middleware/GsonParserFactory.java +++ b/middleware/src/main/java/com/nytimes/android/external/store/middleware/GsonParserFactory.java @@ -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 Parser createReaderParser(@NotNull Type type) { + @Nonnull + public static Parser 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 Parser createReaderParser(@NotNull Gson gson, @NotNull Type type) { + @Nonnull + public static Parser 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 Parser createSourceParser(@NotNull Type type) { + @Nonnull + public static Parser 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 Parser createSourceParser(@NotNull Gson gson, @NotNull Type type) { + @Nonnull + public static Parser 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 Parser createStringParser(@NotNull Class type) { + @Nonnull + public static Parser createStringParser(@Nonnull Class 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 Parser createStringParser(@NotNull Gson gson, @NotNull Type type) { + @Nonnull + public static Parser createStringParser(@Nonnull Gson gson, @Nonnull Type type) { return new GsonStringParser<>(gson, type); } diff --git a/middleware/src/main/java/com/nytimes/android/external/store/middleware/GsonReaderParser.java b/middleware/src/main/java/com/nytimes/android/external/store/middleware/GsonReaderParser.java index bae5a00..22aad93 100644 --- a/middleware/src/main/java/com/nytimes/android/external/store/middleware/GsonReaderParser.java +++ b/middleware/src/main/java/com/nytimes/android/external/store/middleware/GsonReaderParser.java @@ -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 implements Parser { } @Override - public Parsed call(@NotNull Reader reader) { + public Parsed call(@Nonnull Reader reader) { return gson.fromJson(reader, type); } } diff --git a/middleware/src/main/java/com/nytimes/android/external/store/middleware/GsonSourceParser.java b/middleware/src/main/java/com/nytimes/android/external/store/middleware/GsonSourceParser.java index 06950fc..effd9ff 100644 --- a/middleware/src/main/java/com/nytimes/android/external/store/middleware/GsonSourceParser.java +++ b/middleware/src/main/java/com/nytimes/android/external/store/middleware/GsonSourceParser.java @@ -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 implements Parser } @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) {