Skip to content

Commit 2845972

Browse files
authored
Merge pull request #94 from therepanic/migrate-nullability-annotations-to-jspecify
Migrate nullability annotations to jspecify
2 parents bc927a6 + efd3cf5 commit 2845972

35 files changed

+147
-117
lines changed

client/build.gradle

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ plugins {
55
dependencies {
66
implementation project(":utils")
77
implementation libs.okhttp
8+
compileOnly libs.jspecify
89
testImplementation libs.mockwebserver
910
implementation libs.gson
1011
implementation libs.jsoup
@@ -25,12 +26,6 @@ java {
2526
}
2627
}
2728

28-
tasks.withType(Javadoc).configureEach {
29-
failOnError = true
30-
options.addStringOption('Xdoclint:all', '-quiet')
31-
options.addBooleanOption('Xwerror', true)
32-
}
33-
3429
tasks.named("build") {
3530
dependsOn(javadoc)
3631
}

client/src/main/java/com/therepanic/funpay4j/client/OkHttpFunPayClient.java

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
import java.util.Map;
1919
import java.util.stream.Collectors;
2020

21-
import lombok.NonNull;
2221
import okhttp3.MultipartBody;
2322
import okhttp3.OkHttpClient;
2423
import okhttp3.Request;
@@ -40,24 +39,24 @@
4039
* @since 1.0.3
4140
*/
4241
public class OkHttpFunPayClient implements FunPayClient {
43-
@NonNull private final OkHttpClient httpClient;
42+
private final OkHttpClient httpClient;
4443

45-
@NonNull private final String baseURL;
44+
private final String baseURL;
4645

4746
/**
4847
* Creates a new OkHttpFunPayClient instance
4948
*
5049
* @param httpClient httpClient required to send http requests
5150
* @param baseURL base URL of the primary server
5251
*/
53-
public OkHttpFunPayClient(@NonNull OkHttpClient httpClient, @NonNull String baseURL) {
52+
public OkHttpFunPayClient(OkHttpClient httpClient, String baseURL) {
5453
this.httpClient = httpClient;
5554
this.baseURL = baseURL;
5655
}
5756

5857
/** {@inheritDoc} */
5958
@Override
60-
public void updateAvatar(@NonNull String goldenKey, byte @NonNull [] newAvatar)
59+
public void updateAvatar(String goldenKey, byte[] newAvatar)
6160
throws FunPayApiException, InvalidGoldenKeyException {
6261
RequestBody requestBody =
6362
new MultipartBody.Builder()
@@ -85,7 +84,7 @@ public void updateAvatar(@NonNull String goldenKey, byte @NonNull [] newAvatar)
8584

8685
/** {@inheritDoc} */
8786
@Override
88-
public void raiseAllOffers(@NonNull String goldenKey, long gameId, long lotId)
87+
public void raiseAllOffers(String goldenKey, long gameId, long lotId)
8988
throws FunPayApiException, InvalidGoldenKeyException, OfferAlreadyRaisedException {
9089
RequestBody requestBody =
9190
new MultipartBody.Builder()
@@ -123,10 +122,7 @@ public void raiseAllOffers(@NonNull String goldenKey, long gameId, long lotId)
123122
/** {@inheritDoc} */
124123
@Override
125124
public void saveOffer(
126-
@NonNull String goldenKey,
127-
@NonNull String csrfToken,
128-
@NonNull String phpSessionId,
129-
@NonNull SaveOfferRequest request)
125+
String goldenKey, String csrfToken, String phpSessionId, SaveOfferRequest request)
130126
throws FunPayApiException, InvalidGoldenKeyException {
131127
MultipartBody.Builder multipartBody =
132128
new MultipartBody.Builder()
@@ -249,7 +245,7 @@ public void saveOffer(
249245

250246
/** {@inheritDoc} */
251247
@Override
252-
public Long addOfferImage(@NonNull String goldenKey, byte @NonNull [] image)
248+
public Long addOfferImage(String goldenKey, byte[] image)
253249
throws FunPayApiException, InvalidGoldenKeyException {
254250
RequestBody requestBody =
255251
new MultipartBody.Builder()
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/*
2+
* Licensed under the Apache License, Version 2.0 (the "License");
3+
* you may not use this file except in compliance with the License.
4+
* You may obtain a copy of the License at
5+
*
6+
* http://www.apache.org/licenses/LICENSE-2.0
7+
*
8+
* Unless required by applicable law or agreed to in writing, software
9+
* distributed under the License is distributed on an "AS IS" BASIS,
10+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
* See the License for the specific language governing permissions and
12+
* limitations under the License.
13+
*/
14+
15+
@org.jspecify.annotations.NullMarked
16+
package com.therepanic.funpay4j.client;

client/src/main/java/com/therepanic/funpay4j/objects/transaction/ParsedTransaction.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
import lombok.Builder;
2121
import lombok.Data;
2222

23-
import org.jetbrains.annotations.Nullable;
23+
import org.jspecify.annotations.Nullable;
2424

2525
/**
2626
* This object represents the parsed FunPay transaction

client/src/main/java/com/therepanic/funpay4j/objects/user/ParsedPreviewUser.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
import lombok.NoArgsConstructor;
2020
import lombok.experimental.SuperBuilder;
2121

22-
import org.jetbrains.annotations.Nullable;
22+
import org.jspecify.annotations.Nullable;
2323

2424
/**
2525
* This object represents the parsed FunPay preview user

client/src/main/java/com/therepanic/funpay4j/objects/user/ParsedSellerReview.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
import lombok.NoArgsConstructor;
2020
import lombok.experimental.SuperBuilder;
2121

22-
import org.jetbrains.annotations.Nullable;
22+
import org.jspecify.annotations.Nullable;
2323

2424
/**
2525
* This object represents the parsed FunPay seller review

client/src/main/java/com/therepanic/funpay4j/objects/user/ParsedUser.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
import lombok.NoArgsConstructor;
2323
import lombok.experimental.SuperBuilder;
2424

25-
import org.jetbrains.annotations.Nullable;
25+
import org.jspecify.annotations.Nullable;
2626

2727
/**
2828
* This object represents the parsed FunPay user

client/src/main/java/com/therepanic/funpay4j/parser/FunPayParser.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616

1717
import java.util.List;
1818

19+
import org.jspecify.annotations.Nullable;
20+
1921
import com.therepanic.funpay4j.exceptions.FunPayApiException;
2022
import com.therepanic.funpay4j.exceptions.InvalidGoldenKeyException;
2123
import com.therepanic.funpay4j.exceptions.lot.LotNotFoundException;
@@ -158,7 +160,7 @@ List<ParsedSellerReview> parseSellerReviews(
158160
* @throws InvalidGoldenKeyException if the golden key is incorrect
159161
*/
160162
List<ParsedTransaction> parseTransactions(
161-
String goldenKey, long userId, ParsedTransactionType type, int pages)
163+
String goldenKey, long userId, @Nullable ParsedTransactionType type, int pages)
162164
throws FunPayApiException, UserNotFoundException, InvalidGoldenKeyException;
163165

164166
/**

client/src/main/java/com/therepanic/funpay4j/parser/JsoupFunPayParser.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
import java.util.Map;
2424
import java.util.Optional;
2525

26-
import lombok.NonNull;
2726
import okhttp3.MultipartBody;
2827
import okhttp3.OkHttpClient;
2928
import okhttp3.Request;
@@ -33,6 +32,7 @@
3332
import org.jsoup.Jsoup;
3433
import org.jsoup.nodes.Document;
3534
import org.jsoup.nodes.Element;
35+
import org.jspecify.annotations.Nullable;
3636

3737
import com.google.gson.JsonParser;
3838
import com.therepanic.funpay4j.FunPayUserUtil;
@@ -67,17 +67,17 @@
6767
* @since 1.0.0
6868
*/
6969
public class JsoupFunPayParser implements FunPayParser {
70-
@NonNull private final OkHttpClient httpClient;
70+
private final OkHttpClient httpClient;
7171

72-
@NonNull private final String baseURL;
72+
private final String baseURL;
7373

7474
/**
7575
* Creates a new JsoupFunPayParser instance
7676
*
7777
* @param httpClient httpClient required to send http requests
7878
* @param baseURL base URL of the primary server
7979
*/
80-
public JsoupFunPayParser(@NonNull OkHttpClient httpClient, @NonNull String baseURL) {
80+
public JsoupFunPayParser(OkHttpClient httpClient, String baseURL) {
8181
this.httpClient = httpClient;
8282
this.baseURL = baseURL;
8383
}
@@ -232,7 +232,7 @@ public ParsedLot parseLot(long lotId) throws FunPayApiException, LotNotFoundExce
232232

233233
/** {@inheritDoc} */
234234
@Override
235-
public List<ParsedPromoGame> parsePromoGames(@NonNull String query) throws FunPayApiException {
235+
public List<ParsedPromoGame> parsePromoGames(String query) throws FunPayApiException {
236236
List<ParsedPromoGame> currentPromoGames = new ArrayList<>();
237237

238238
RequestBody requestBody =
@@ -563,7 +563,7 @@ public ParsedOrder parseOrder(String goldenKey, String orderId)
563563

564564
/** {@inheritDoc} */
565565
@Override
566-
public CsrfTokenAndPHPSESSID parseCsrfTokenAndPHPSESSID(@NonNull String goldenKey)
566+
public CsrfTokenAndPHPSESSID parseCsrfTokenAndPHPSESSID(String goldenKey)
567567
throws FunPayApiException {
568568
// We send a request to /unknown URL that doesn't exist to get a page where it will be
569569
// reported that the page doesn't exist.
@@ -612,7 +612,7 @@ public CsrfTokenAndPHPSESSID parseCsrfTokenAndPHPSESSID(@NonNull String goldenKe
612612
* @throws FunPayApiException if the other api-related exception
613613
* @throws UserNotFoundException if the user with id does not found
614614
*/
615-
private ParsedUser parseUserInternal(String goldenKey, long userId)
615+
private ParsedUser parseUserInternal(@Nullable String goldenKey, long userId)
616616
throws FunPayApiException, UserNotFoundException {
617617
Request.Builder newCallBuilder =
618618
new Request.Builder().get().url(baseURL + "/users/" + userId + "/");
@@ -795,7 +795,7 @@ private ParsedUser parseUserInternal(String goldenKey, long userId)
795795
* @throws InvalidGoldenKeyException if the golden key is incorrect
796796
*/
797797
private List<ParsedTransaction> parseTransactionsInternal(
798-
String goldenKey, long userId, ParsedTransactionType type, int pages)
798+
String goldenKey, long userId, @Nullable ParsedTransactionType type, int pages)
799799
throws FunPayApiException, UserNotFoundException, InvalidGoldenKeyException {
800800
List<ParsedTransaction> parsedTransactions = new ArrayList<>();
801801

@@ -927,7 +927,7 @@ private List<ParsedTransaction> parseTransactionsInternal(
927927
* @throws UserNotFoundException if the user with id does not found/seller
928928
*/
929929
private List<ParsedSellerReview> parseSellerReviewsInternal(
930-
String goldenKey, long userId, int pages, String starsFilter)
930+
@Nullable String goldenKey, long userId, int pages, @Nullable String starsFilter)
931931
throws FunPayApiException, UserNotFoundException {
932932
List<ParsedSellerReview> currentSellerReviews = new ArrayList<>();
933933

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/*
2+
* Licensed under the Apache License, Version 2.0 (the "License");
3+
* you may not use this file except in compliance with the License.
4+
* You may obtain a copy of the License at
5+
*
6+
* http://www.apache.org/licenses/LICENSE-2.0
7+
*
8+
* Unless required by applicable law or agreed to in writing, software
9+
* distributed under the License is distributed on an "AS IS" BASIS,
10+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
* See the License for the specific language governing permissions and
12+
* limitations under the License.
13+
*/
14+
15+
@org.jspecify.annotations.NullMarked
16+
package com.therepanic.funpay4j.parser;

0 commit comments

Comments
 (0)