From 0d6fb9602116d8ffec1b864b8276bbe108f6f616 Mon Sep 17 00:00:00 2001 From: Joao Pedro Truchinski Borba Date: Wed, 20 Nov 2024 23:30:20 -0300 Subject: [PATCH] chore: validate max allowed value --- src/main/java/io/github/jpdev/asaassdk/doc/Examples.java | 8 -------- .../java/io/github/jpdev/asaassdk/rest/action/Reader.java | 4 ++++ 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/src/main/java/io/github/jpdev/asaassdk/doc/Examples.java b/src/main/java/io/github/jpdev/asaassdk/doc/Examples.java index f91f3a8..cb93f4e 100644 --- a/src/main/java/io/github/jpdev/asaassdk/doc/Examples.java +++ b/src/main/java/io/github/jpdev/asaassdk/doc/Examples.java @@ -59,14 +59,6 @@ private static void paging() { PixTransactionReader reader = PixTransaction.reader(); ResourceSet page0 = reader.read(); ResourceSet page1 = reader.nextPage().read(); - - ArrayList pixTransactions = new ArrayList<>(); - pixTransactions.addAll(page0.getData()); - pixTransactions.addAll(page1.getData()); - - for (PixTransaction pixTransaction : pixTransactions) { - System.out.println(pixTransaction.getId().equals("6b212665-4963-460d-9005-3805281790a4")); - } } private static void pixTransaction() { diff --git a/src/main/java/io/github/jpdev/asaassdk/rest/action/Reader.java b/src/main/java/io/github/jpdev/asaassdk/rest/action/Reader.java index 9b70328..f7e8fbb 100644 --- a/src/main/java/io/github/jpdev/asaassdk/rest/action/Reader.java +++ b/src/main/java/io/github/jpdev/asaassdk/rest/action/Reader.java @@ -18,6 +18,8 @@ public abstract class Reader { public int limit = 10; public long offset = 0; + private static final int LIMIT_MAX_VALUE = 100; + public List activeFilters; public Integer getLimit() { @@ -25,6 +27,8 @@ public Integer getLimit() { } public Reader setLimit(Integer limit) { + if (limit > LIMIT_MAX_VALUE) throw new IllegalArgumentException("Limit cannot be greater than " + LIMIT_MAX_VALUE); + this.limit = limit; return this; }