Skip to content

Commit 9f1b4d5

Browse files
author
liujingxing
committed
新增Nullable、NonNull两个注解,替换目前所用到的地方
1 parent 23c66c4 commit 9f1b4d5

31 files changed

Lines changed: 138 additions & 56 deletions

rxhttp/src/main/java/rxhttp/HttpSender.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@
88

99
import io.reactivex.Observable;
1010
import io.reactivex.Scheduler;
11-
import io.reactivex.annotations.NonNull;
1211
import io.reactivex.functions.Consumer;
1312
import io.reactivex.plugins.RxJavaPlugins;
1413
import okhttp3.Call;
1514
import okhttp3.OkHttpClient;
1615
import okhttp3.Request;
1716
import okhttp3.Response;
17+
import rxhttp.wrapper.annotations.NonNull;
1818
import rxhttp.wrapper.callback.ProgressCallback;
1919
import rxhttp.wrapper.entity.Progress;
2020
import rxhttp.wrapper.param.FormParam;

rxhttp/src/main/java/rxhttp/ObservableDownload.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
import io.reactivex.Observable;
2020
import io.reactivex.ObservableEmitter;
2121
import io.reactivex.Observer;
22-
import io.reactivex.annotations.NonNull;
2322
import io.reactivex.disposables.Disposable;
2423
import io.reactivex.exceptions.Exceptions;
2524
import io.reactivex.functions.Cancellable;
@@ -32,6 +31,7 @@
3231
import okhttp3.Call;
3332
import okhttp3.Request;
3433
import okhttp3.Response;
34+
import rxhttp.wrapper.annotations.NonNull;
3535
import rxhttp.wrapper.callback.ProgressCallback;
3636
import rxhttp.wrapper.entity.Progress;
3737
import rxhttp.wrapper.entity.ProgressT;

rxhttp/src/main/java/rxhttp/ObservableHttp.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,15 @@
1919

2020
import io.reactivex.Observable;
2121
import io.reactivex.Observer;
22-
import io.reactivex.annotations.NonNull;
23-
import io.reactivex.annotations.Nullable;
2422
import io.reactivex.exceptions.Exceptions;
2523
import io.reactivex.internal.functions.ObjectHelper;
2624
import io.reactivex.internal.observers.DeferredScalarDisposable;
2725
import io.reactivex.plugins.RxJavaPlugins;
2826
import okhttp3.Call;
2927
import okhttp3.Request;
3028
import okhttp3.Response;
29+
import rxhttp.wrapper.annotations.NonNull;
30+
import rxhttp.wrapper.annotations.Nullable;
3131
import rxhttp.wrapper.cahce.CacheMode;
3232
import rxhttp.wrapper.cahce.InternalCache;
3333
import rxhttp.wrapper.exception.CacheReadFailedException;

rxhttp/src/main/java/rxhttp/RxHttpPlugins.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
import java.util.Collections;
66
import java.util.List;
77

8-
import io.reactivex.annotations.NonNull;
9-
import io.reactivex.annotations.Nullable;
108
import io.reactivex.functions.Function;
119
import io.reactivex.internal.util.ExceptionHelper;
10+
import rxhttp.wrapper.annotations.NonNull;
11+
import rxhttp.wrapper.annotations.Nullable;
1212
import rxhttp.wrapper.cahce.CacheManager;
1313
import rxhttp.wrapper.cahce.CacheMode;
1414
import rxhttp.wrapper.cahce.CacheStrategy;
@@ -42,8 +42,8 @@ public static void setOnParamAssembly(@Nullable Function<? super Param, ? extend
4242
//设置转换器,可用于对Http返回的String 字符串解密
4343

4444
/**
45-
* @deprecated please user {@link #setResultDecoder(Function)} instead
4645
* @param decoder 数据转换器
46+
* @deprecated please user {@link #setResultDecoder(Function)} instead
4747
*/
4848
@Deprecated
4949
public static void setOnConverter(@Nullable Function<? super String, String> decoder) {
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*
2+
* Copyright (c) 2016-present, RxJava Contributors.
3+
* <p>
4+
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in
5+
* compliance with the License. You may obtain a copy of the License at
6+
* <p>
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
* <p>
9+
* Unless required by applicable law or agreed to in writing, software distributed under the License is
10+
* distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See
11+
* the License for the specific language governing permissions and limitations under the License.
12+
*/
13+
14+
package rxhttp.wrapper.annotations;
15+
16+
import java.lang.annotation.Documented;
17+
import java.lang.annotation.Retention;
18+
import java.lang.annotation.Target;
19+
20+
import static java.lang.annotation.ElementType.FIELD;
21+
import static java.lang.annotation.ElementType.LOCAL_VARIABLE;
22+
import static java.lang.annotation.ElementType.METHOD;
23+
import static java.lang.annotation.ElementType.PARAMETER;
24+
import static java.lang.annotation.RetentionPolicy.CLASS;
25+
26+
/**
27+
* Indicates that a field/parameter/variable/return type is never null.
28+
*/
29+
@Documented
30+
@Target(value = {FIELD, METHOD, PARAMETER, LOCAL_VARIABLE})
31+
@Retention(value = CLASS)
32+
public @interface NonNull {}
33+
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*
2+
* Copyright (c) 2016-present, RxJava Contributors.
3+
* <p>
4+
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in
5+
* compliance with the License. You may obtain a copy of the License at
6+
* <p>
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
* <p>
9+
* Unless required by applicable law or agreed to in writing, software distributed under the License is
10+
* distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See
11+
* the License for the specific language governing permissions and limitations under the License.
12+
*/
13+
14+
package rxhttp.wrapper.annotations;
15+
16+
import java.lang.annotation.Documented;
17+
import java.lang.annotation.Retention;
18+
import java.lang.annotation.Target;
19+
20+
import static java.lang.annotation.ElementType.FIELD;
21+
import static java.lang.annotation.ElementType.LOCAL_VARIABLE;
22+
import static java.lang.annotation.ElementType.METHOD;
23+
import static java.lang.annotation.ElementType.PARAMETER;
24+
import static java.lang.annotation.RetentionPolicy.CLASS;
25+
26+
/**
27+
* Indicates that a field/parameter/variable/return type may be null.
28+
*/
29+
@Documented
30+
@Target(value = {FIELD, METHOD, PARAMETER, LOCAL_VARIABLE})
31+
@Retention(value = CLASS)
32+
public @interface Nullable {}
33+

rxhttp/src/main/java/rxhttp/wrapper/cahce/CacheManager.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
import java.util.List;
1515
import java.util.NoSuchElementException;
1616

17-
import io.reactivex.annotations.Nullable;
1817
import okhttp3.CipherSuite;
1918
import okhttp3.Handshake;
2019
import okhttp3.Headers;
@@ -43,6 +42,7 @@
4342
import okio.Sink;
4443
import okio.Source;
4544
import okio.Timeout;
45+
import rxhttp.wrapper.annotations.Nullable;
4646

4747
import static java.util.concurrent.TimeUnit.MILLISECONDS;
4848
import static okhttp3.internal.Util.discard;
@@ -92,8 +92,9 @@ public long size() throws IOException {
9292

9393
/**
9494
* Create a cache of at most {@code maxSize} bytes in {@code directory}.
95+
*
9596
* @param directory File
96-
* @param maxSize long
97+
* @param maxSize long
9798
*/
9899
public CacheManager(File directory, long maxSize) {
99100
this(directory, maxSize, FileSystem.SYSTEM);
@@ -245,6 +246,7 @@ private void abortQuietly(@Nullable DiskLruCache.Editor editor) {
245246
*
246247
* <p>Note that if the application chooses to not call this method to initialize the cache. By
247248
* default, the okhttp will perform lazy initialization upon the first usage of the cache.
249+
*
248250
* @throws IOException 初始化失败
249251
*/
250252
public void initialize() throws IOException {

rxhttp/src/main/java/rxhttp/wrapper/cahce/InternalCache.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717

1818
import java.io.IOException;
1919

20-
import io.reactivex.annotations.Nullable;
2120
import okhttp3.Request;
2221
import okhttp3.Response;
22+
import rxhttp.wrapper.annotations.Nullable;
2323

2424
/**
2525
* RxHttp's internal cache interface. Applications shouldn't implement this: instead use {@link CacheManager}.

rxhttp/src/main/java/rxhttp/wrapper/callback/IConverter.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
import java.io.IOException;
55
import java.lang.reflect.Type;
66

7-
import io.reactivex.annotations.NonNull;
87
import okhttp3.RequestBody;
98
import okhttp3.ResponseBody;
9+
import rxhttp.wrapper.annotations.NonNull;
1010
import rxhttp.wrapper.converter.GsonConverter;
1111

1212
/**
@@ -34,7 +34,7 @@ public interface IConverter {
3434
* 对象转 RequestBody,目前(RxHttp 1.3.1版本)发送{application/json; charset=utf-8}类型请求前,将会调用此方法
3535
*
3636
* @param value T
37-
* @param <T> T
37+
* @param <T> T
3838
* @return RequestBody
3939
* @throws IOException 转换失败异常
4040
*/

rxhttp/src/main/java/rxhttp/wrapper/converter/GsonConverter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@
1212
import java.lang.reflect.Type;
1313
import java.nio.charset.Charset;
1414

15-
import io.reactivex.annotations.NonNull;
1615
import okhttp3.MediaType;
1716
import okhttp3.RequestBody;
1817
import okhttp3.ResponseBody;
1918
import okio.Buffer;
2019
import rxhttp.RxHttpPlugins;
20+
import rxhttp.wrapper.annotations.NonNull;
2121
import rxhttp.wrapper.callback.IConverter;
2222
import rxhttp.wrapper.utils.GsonUtil;
2323

0 commit comments

Comments
 (0)