Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

clean up Java build warnings #284

Merged
merged 1 commit into from
Sep 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 18 additions & 6 deletions src/main/java/com/easypost/service/ShipmentService.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import java.util.List;
import java.util.Map;
import java.util.function.Function;
import com.google.errorprone.annotations.InlineMe;

public class ShipmentService {
private final EasyPostClient client;
Expand Down Expand Up @@ -191,7 +192,9 @@ public Shipment newRates(final String id, final Map<String, Object> params, fina
* Deprecated: v5.5.0 - v7.0.0
*/
@Deprecated
public List<SmartRate> getSmartrates(final String id, final Map<String, Object> params) throws EasyPostException {
@InlineMe(replacement = "this.smartrates(id, params)")
public final List<SmartRate> getSmartrates(final String id, final Map<String, Object> params)
throws EasyPostException {
return this.smartrates(id, params);
}

Expand Down Expand Up @@ -402,7 +405,11 @@ public Shipment insure(final String id, final Map<String, Object> params) throws
* Deprecated: v5.5.0 - v7.0.0
*/
@Deprecated
public SmartRate lowestSmartRate(final String id, int deliveryDay, String deliveryAccuracy)
@InlineMe(
replacement = "this.lowestSmartRate(id, deliveryDay, SmartrateAccuracy.getByKeyName(deliveryAccuracy))",
imports = "com.easypost.model.SmartrateAccuracy"
)
public final SmartRate lowestSmartRate(final String id, int deliveryDay, String deliveryAccuracy)
throws EasyPostException {
return this.lowestSmartRate(id, deliveryDay, SmartrateAccuracy.getByKeyName(deliveryAccuracy));
}
Expand Down Expand Up @@ -436,8 +443,9 @@ public SmartRate lowestSmartRate(final String id, final int deliveryDay, Smartra
* Deprecated: v5.5.0 - v7.0.0
*/
@Deprecated
public List<SmartRate> getSmartrates(final String id) throws EasyPostException {
return this.getSmartrates(id, null);
@InlineMe(replacement = "this.smartrates(id, null)")
public final List<SmartRate> getSmartrates(final String id) throws EasyPostException {
return this.smartrates(id, null);
}

/**
Expand All @@ -453,8 +461,12 @@ public List<SmartRate> getSmartrates(final String id) throws EasyPostException {
* Deprecated: v5.5.0 - v7.0.0
*/
@Deprecated
public SmartRate getLowestSmartRate(final List<SmartRate> smartRates, int deliveryDay, String deliveryAccuracy)
throws EasyPostException {
@InlineMe(replacement =
"this.findLowestSmartrate(smartRates, deliveryDay, SmartrateAccuracy.getByKeyName(deliveryAccuracy))",
imports = "com.easypost.model.SmartrateAccuracy"
)
public final SmartRate getLowestSmartRate(final List<SmartRate> smartRates,
int deliveryDay, String deliveryAccuracy) throws EasyPostException {
return findLowestSmartrate(smartRates, deliveryDay, SmartrateAccuracy.getByKeyName(deliveryAccuracy));
}

Expand Down
4 changes: 4 additions & 0 deletions src/main/java/com/easypost/utils/Utilities.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import com.easypost.model.SmartRate;
import com.easypost.model.SmartrateAccuracy;
import com.easypost.model.StatelessRate;
import com.google.errorprone.annotations.InlineMe;

import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -151,6 +152,9 @@ public static Event validateWebhook(byte[] eventBody, Map<String, Object> header
* Deprecated: v5.5.0 - v7.0.0
*/
@Deprecated
@InlineMe(replacement =
"Utilities.findLowestSmartrate(smartrates, deliveryDay, SmartrateAccuracy.getByKeyName(deliveryAccuracy))",
imports = {"com.easypost.model.SmartrateAccuracy", "com.easypost.utils.Utilities"})
public static SmartRate getLowestSmartRate(final List<SmartRate> smartrates, int deliveryDay,
String deliveryAccuracy) throws EasyPostException {
return findLowestSmartrate(smartrates, deliveryDay, SmartrateAccuracy.getByKeyName(deliveryAccuracy));
Expand Down
3 changes: 2 additions & 1 deletion src/test/java/com/easypost/Fixtures.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import com.google.gson.reflect.TypeToken;

import java.io.IOException;
import java.io.UncheckedIOException;
import java.lang.reflect.Type;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
Expand Down Expand Up @@ -283,7 +284,7 @@ public static byte[] eventBytes() {
data = Files.readAllLines(Paths.get(fullFilePath), StandardCharsets.UTF_8)
.get(0).getBytes(Charset.defaultCharset());
} catch (IOException error) {
error.printStackTrace();
throw new UncheckedIOException(error);
}

return data;
Expand Down