Skip to content

Commit f2ee19d

Browse files
committed
Remove unneeded request type enum
1 parent a41c831 commit f2ee19d

File tree

1 file changed

+8
-13
lines changed

1 file changed

+8
-13
lines changed

src/main/java/is/swan/mcmarketapi/request/sorting/Throttler.java

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,22 @@
22

33
import java.util.concurrent.atomic.AtomicLong;
44

5-
public class Throttler {
6-
enum RequestType {
7-
READ, WRITE
8-
}
9-
5+
import is.swan.mcmarketapi.request.Request.Method;
6+
7+
public class Throttler {
108
private final AtomicLong readLastRetry = new AtomicLong(0);
119
private final AtomicLong readLastRequest = new AtomicLong(System.currentTimeMillis());
1210

1311
private final AtomicLong writeLastRetry = new AtomicLong(0);
1412
private final AtomicLong writeLastRequest = new AtomicLong(System.currentTimeMillis());
1513

16-
public long stallFor(RequestType type) {
14+
public long stallFor(Method method) {
1715
long time = System.currentTimeMillis();
1816

19-
switch (type) {
20-
case READ:
21-
return Throttler.stalForHelper(this.readLastRetry, this.readLastRequest, time);
22-
case WRITE:
23-
return Throttler.stalForHelper(this.writeLastRetry, this.writeLastRequest, time);
24-
default:
25-
return 0;
17+
if (method == Method.GET) {
18+
return Throttler.stalForHelper(this.readLastRetry, this.readLastRequest, time);
19+
} else {
20+
return Throttler.stalForHelper(this.writeLastRetry, this.writeLastRequest, time);
2621
}
2722
}
2823

0 commit comments

Comments
 (0)