Skip to content

Commit

Permalink
Replace @ParametersAreNonnullByDefault with @EverythingIsNonNull
Browse files Browse the repository at this point in the history
  • Loading branch information
squarejesse committed Oct 6, 2018
1 parent eb441ed commit 05019fc
Show file tree
Hide file tree
Showing 50 changed files with 168 additions and 142 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import java.lang.annotation.Annotation;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import javax.annotation.Nullable;
import retrofit2.Call;
import retrofit2.CallAdapter;
import retrofit2.Callback;
Expand Down Expand Up @@ -56,8 +57,8 @@ public static GuavaCallAdapterFactory create() {
private GuavaCallAdapterFactory() {
}

@Override
public CallAdapter<?, ?> get(Type returnType, Annotation[] annotations, Retrofit retrofit) {
@Override public @Nullable CallAdapter<?, ?> get(
Type returnType, Annotation[] annotations, Retrofit retrofit) {
if (getRawType(returnType) != ListenableFuture.class) {
return null;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
@ParametersAreNonnullByDefault
@retrofit2.internal.EverythingIsNonNull
package retrofit2.adapter.guava;

import javax.annotation.ParametersAreNonnullByDefault;
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.util.concurrent.CompletableFuture;
import javax.annotation.Nullable;
import retrofit2.Call;
import retrofit2.CallAdapter;
import retrofit2.Callback;
Expand Down Expand Up @@ -59,8 +60,8 @@ public static Java8CallAdapterFactory create() {
private Java8CallAdapterFactory() {
}

@Override
public CallAdapter<?, ?> get(Type returnType, Annotation[] annotations, Retrofit retrofit) {
@Override public @Nullable CallAdapter<?, ?> get(
Type returnType, Annotation[] annotations, Retrofit retrofit) {
if (getRawType(returnType) != CompletableFuture.class) {
return null;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
@ParametersAreNonnullByDefault
@retrofit2.internal.EverythingIsNonNull
package retrofit2.adapter.java8;

import javax.annotation.ParametersAreNonnullByDefault;
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ private RxJavaCallAdapterFactory(@Nullable Scheduler scheduler, boolean isAsync)
this.isAsync = isAsync;
}

@Override
public CallAdapter<?, ?> get(Type returnType, Annotation[] annotations, Retrofit retrofit) {
@Override public @Nullable CallAdapter<?, ?> get(
Type returnType, Annotation[] annotations, Retrofit retrofit) {
Class<?> rawType = getRawType(returnType);
boolean isSingle = rawType == Single.class;
boolean isCompletable = rawType == Completable.class;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
@ParametersAreNonnullByDefault
@retrofit2.internal.EverythingIsNonNull
package retrofit2.adapter.rxjava;

import javax.annotation.ParametersAreNonnullByDefault;
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ private RxJava2CallAdapterFactory(@Nullable Scheduler scheduler, boolean isAsync
this.isAsync = isAsync;
}

@Override
public CallAdapter<?, ?> get(Type returnType, Annotation[] annotations, Retrofit retrofit) {
@Override public @Nullable CallAdapter<?, ?> get(
Type returnType, Annotation[] annotations, Retrofit retrofit) {
Class<?> rawType = getRawType(returnType);

if (rawType == Completable.class) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
@ParametersAreNonnullByDefault
@retrofit2.internal.EverythingIsNonNull
package retrofit2.adapter.rxjava2;

import javax.annotation.ParametersAreNonnullByDefault;
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
package retrofit2.adapter.scala;

import java.lang.reflect.Type;
import javax.annotation.Nonnull;
import retrofit2.Call;
import retrofit2.CallAdapter;
import retrofit2.Callback;
Expand All @@ -36,19 +35,19 @@ final class BodyCallAdapter<T> implements CallAdapter<T, Future<T>> {
return responseType;
}

@Override public Future<T> adapt(@Nonnull Call<T> call) {
@Override public Future<T> adapt(Call<T> call) {
Promise<T> promise = Promise.apply();

call.enqueue(new Callback<T>() {
@Override public void onResponse(@Nonnull Call<T> call, @Nonnull Response<T> response) {
@Override public void onResponse(Call<T> call, Response<T> response) {
if (response.isSuccessful()) {
promise.success(response.body());
} else {
promise.failure(new HttpException(response));
}
}

@Override public void onFailure(@Nonnull Call<T> call, @Nonnull Throwable t) {
@Override public void onFailure(Call<T> call, Throwable t) {
promise.failure(t);
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
package retrofit2.adapter.scala;

import java.lang.reflect.Type;
import javax.annotation.Nonnull;
import retrofit2.Call;
import retrofit2.CallAdapter;
import retrofit2.Callback;
Expand All @@ -35,15 +34,15 @@ final class ResponseCallAdapter<T> implements CallAdapter<T, Future<Response<T>>
return responseType;
}

@Override public Future<Response<T>> adapt(@Nonnull Call<T> call) {
@Override public Future<Response<T>> adapt(Call<T> call) {
Promise<Response<T>> promise = Promise.apply();

call.enqueue(new Callback<T>() {
@Override public void onResponse(@Nonnull Call<T> call, @Nonnull Response<T> response) {
@Override public void onResponse(Call<T> call, Response<T> response) {
promise.success(response);
}

@Override public void onFailure(@Nonnull Call<T> call, @Nonnull Throwable t) {
@Override public void onFailure(Call<T> call, Throwable t) {
promise.failure(t);
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import java.lang.annotation.Annotation;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import retrofit2.CallAdapter;
import retrofit2.Response;
import retrofit2.Retrofit;
Expand Down Expand Up @@ -54,9 +54,8 @@ public static ScalaCallAdapterFactory create() {
private ScalaCallAdapterFactory() {
}

@Override
public CallAdapter<?, ?> get(@Nonnull Type returnType, @Nonnull Annotation[] annotations,
@Nonnull Retrofit retrofit) {
@Override public @Nullable CallAdapter<?, ?> get(
Type returnType, Annotation[] annotations, Retrofit retrofit) {
if (getRawType(returnType) != Future.class) {
return null;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
@retrofit2.internal.EverythingIsNonNull
package retrofit2.adapter.scala;
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
@ParametersAreNonnullByDefault
@retrofit2.internal.EverythingIsNonNull
package retrofit2.converter.gson;

import javax.annotation.ParametersAreNonnullByDefault;
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,8 @@ public static GuavaOptionalConverterFactory create() {
private GuavaOptionalConverterFactory() {
}

@Nullable @Override
public Converter<ResponseBody, ?> responseBodyConverter(Type type, Annotation[] annotations,
Retrofit retrofit) {
@Override public @Nullable Converter<ResponseBody, ?> responseBodyConverter(
Type type, Annotation[] annotations, Retrofit retrofit) {
if (getRawType(type) != Optional.class) {
return null;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
@ParametersAreNonnullByDefault
@retrofit2.internal.EverythingIsNonNull
package retrofit.converter.guava;

import javax.annotation.ParametersAreNonnullByDefault;
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
@ParametersAreNonnullByDefault
@retrofit2.internal.EverythingIsNonNull
package retrofit2.converter.jackson;

import javax.annotation.ParametersAreNonnullByDefault;
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,8 @@ public static Java8OptionalConverterFactory create() {
private Java8OptionalConverterFactory() {
}

@Nullable @Override
public Converter<ResponseBody, ?> responseBodyConverter(Type type, Annotation[] annotations,
Retrofit retrofit) {
@Override public @Nullable Converter<ResponseBody, ?> responseBodyConverter(
Type type, Annotation[] annotations, Retrofit retrofit) {
if (getRawType(type) != Optional.class) {
return null;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
@ParametersAreNonnullByDefault
@retrofit2.internal.EverythingIsNonNull
package retrofit.converter.java8;

import javax.annotation.ParametersAreNonnullByDefault;
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,15 @@ private JaxbConverterFactory(@Nullable JAXBContext context) {
this.context = context;
}

@Override public Converter<?, RequestBody> requestBodyConverter(Type type,
@Override public @Nullable Converter<?, RequestBody> requestBodyConverter(Type type,
Annotation[] parameterAnnotations, Annotation[] methodAnnotations, Retrofit retrofit) {
if (type instanceof Class && ((Class<?>) type).isAnnotationPresent(XmlRootElement.class)) {
return new JaxbRequestConverter<>(contextForType((Class<?>) type), (Class<?>) type);
}
return null;
}

@Override public Converter<ResponseBody, ?> responseBodyConverter(
@Override public @Nullable Converter<ResponseBody, ?> responseBodyConverter(
Type type, Annotation[] annotations, Retrofit retrofit) {
if (type instanceof Class && ((Class<?>) type).isAnnotationPresent(XmlRootElement.class)) {
return new JaxbResponseConverter<>(contextForType((Class<?>) type), (Class<?>) type);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
@ParametersAreNonnullByDefault
@retrofit2.internal.EverythingIsNonNull
package retrofit2.converter.jaxb;

import javax.annotation.ParametersAreNonnullByDefault;
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
@ParametersAreNonnullByDefault
@retrofit2.internal.EverythingIsNonNull
package retrofit2.converter.moshi;

import javax.annotation.ParametersAreNonnullByDefault;
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,8 @@ private ProtoConverterFactory(@Nullable ExtensionRegistryLite registry) {
this.registry = registry;
}

@Override
public Converter<ResponseBody, ?> responseBodyConverter(Type type, Annotation[] annotations,
Retrofit retrofit) {
@Override public @Nullable Converter<ResponseBody, ?> responseBodyConverter(
Type type, Annotation[] annotations, Retrofit retrofit) {
if (!(type instanceof Class<?>)) {
return null;
}
Expand Down Expand Up @@ -84,8 +83,7 @@ private ProtoConverterFactory(@Nullable ExtensionRegistryLite registry) {
return new ProtoResponseBodyConverter<>(parser, registry);
}

@Override
public Converter<?, RequestBody> requestBodyConverter(Type type,
@Override public @Nullable Converter<?, RequestBody> requestBodyConverter(Type type,
Annotation[] parameterAnnotations, Annotation[] methodAnnotations, Retrofit retrofit) {
if (!(type instanceof Class<?>)) {
return null;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
@ParametersAreNonnullByDefault
@retrofit2.internal.EverythingIsNonNull
package retrofit2.converter.protobuf;

import javax.annotation.ParametersAreNonnullByDefault;
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import java.lang.annotation.Annotation;
import java.lang.reflect.Type;
import javax.annotation.Nullable;
import okhttp3.RequestBody;
import okhttp3.ResponseBody;
import retrofit2.Converter;
Expand All @@ -43,7 +44,7 @@ public static ScalarsConverterFactory create() {
private ScalarsConverterFactory() {
}

@Override public Converter<?, RequestBody> requestBodyConverter(Type type,
@Override public @Nullable Converter<?, RequestBody> requestBodyConverter(Type type,
Annotation[] parameterAnnotations, Annotation[] methodAnnotations, Retrofit retrofit) {
if (type == String.class
|| type == boolean.class
Expand All @@ -67,9 +68,8 @@ private ScalarsConverterFactory() {
return null;
}

@Override
public Converter<ResponseBody, ?> responseBodyConverter(Type type, Annotation[] annotations,
Retrofit retrofit) {
@Override public @Nullable Converter<ResponseBody, ?> responseBodyConverter(
Type type, Annotation[] annotations, Retrofit retrofit) {
if (type == String.class) {
return StringResponseBodyConverter.INSTANCE;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
@ParametersAreNonnullByDefault
@retrofit2.internal.EverythingIsNonNull
package retrofit2.converter.scalars;

import javax.annotation.ParametersAreNonnullByDefault;
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import java.lang.annotation.Annotation;
import java.lang.reflect.Type;
import javax.annotation.Nullable;
import okhttp3.RequestBody;
import okhttp3.ResponseBody;
import org.simpleframework.xml.Serializer;
Expand Down Expand Up @@ -78,8 +79,7 @@ public boolean isStrict() {
return new SimpleXmlResponseBodyConverter<>(cls, serializer, strict);
}

@Override
public Converter<?, RequestBody> requestBodyConverter(Type type,
@Override public @Nullable Converter<?, RequestBody> requestBodyConverter(Type type,
Annotation[] parameterAnnotations, Annotation[] methodAnnotations, Retrofit retrofit) {
if (!(type instanceof Class)) {
return null;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
@ParametersAreNonnullByDefault
@retrofit2.internal.EverythingIsNonNull
package retrofit2.converter.simplexml;

import javax.annotation.ParametersAreNonnullByDefault;
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import com.squareup.wire.ProtoAdapter;
import java.lang.annotation.Annotation;
import java.lang.reflect.Type;
import javax.annotation.Nullable;
import okhttp3.RequestBody;
import okhttp3.ResponseBody;
import retrofit2.Converter;
Expand All @@ -37,9 +38,8 @@ public static WireConverterFactory create() {
private WireConverterFactory() {
}

@Override
public Converter<ResponseBody, ?> responseBodyConverter(Type type, Annotation[] annotations,
Retrofit retrofit) {
@Override public @Nullable Converter<ResponseBody, ?> responseBodyConverter(
Type type, Annotation[] annotations, Retrofit retrofit) {
if (!(type instanceof Class<?>)) {
return null;
}
Expand All @@ -52,8 +52,7 @@ private WireConverterFactory() {
return new WireResponseBodyConverter<>(adapter);
}

@Override
public Converter<?, RequestBody> requestBodyConverter(Type type,
@Override public @Nullable Converter<?, RequestBody> requestBodyConverter(Type type,
Annotation[] parameterAnnotations, Annotation[] methodAnnotations, Retrofit retrofit) {
if (!(type instanceof Class<?>)) {
return null;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
@ParametersAreNonnullByDefault
@retrofit2.internal.EverythingIsNonNull
package retrofit2.converter.wire;

import javax.annotation.ParametersAreNonnullByDefault;
4 changes: 1 addition & 3 deletions retrofit-mock/src/main/java/retrofit2/mock/package-info.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
@ParametersAreNonnullByDefault
@retrofit2.internal.EverythingIsNonNull
package retrofit2.mock;

import javax.annotation.ParametersAreNonnullByDefault;
8 changes: 8 additions & 0 deletions retrofit/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,14 @@
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.10.4</version>
<configuration>
<excludePackageNames>retrofit2.internal</excludePackageNames>
</configuration>
</plugin>
</plugins>
</build>
</project>
Loading

0 comments on commit 05019fc

Please sign in to comment.