Skip to content

Commit

Permalink
refactor(java-client): optimize the code style for checking if the li…
Browse files Browse the repository at this point in the history
…st is empty (#2122)
  • Loading branch information
empiredan authored Sep 23, 2024
1 parent d1f6d61 commit a6965ac
Showing 1 changed file with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ private Future<MultiGetResult> asyncMultiGet(
List<blob> sortKeyBlobs = new ArrayList<blob>();
Map<ByteBuffer, byte[]> setKeyMap = null;

if (sortKeys != null && sortKeys.size() > 0) {
if (sortKeys != null && !sortKeys.isEmpty()) {
setKeyMap = new TreeMap<ByteBuffer, byte[]>();
for (int i = 0; i < sortKeys.size(); i++) {
byte[] sortKey = sortKeys.get(i);
Expand Down Expand Up @@ -552,7 +552,7 @@ public Future<Void> asyncMultiSet(
new PException("Invalid parameter: hashKey length should be less than UINT16_MAX"));
return promise;
}
if (values == null || values.size() == 0) {
if (values == null || values.isEmpty()) {
promise.setFailure(new PException("Invalid parameter: values should not be null or empty"));
return promise;
}
Expand Down Expand Up @@ -1147,7 +1147,7 @@ public byte[] get(byte[] hashKey, byte[] sortKey, int timeout) throws PException
@Override
public void batchGet(List<Pair<byte[], byte[]>> keys, List<byte[]> values, int timeout)
throws PException {
if (keys == null || keys.size() == 0) {
if (keys == null || keys.isEmpty()) {
throw new PException("Invalid parameter: keys should not be null or empty");
}
if (values == null) {
Expand Down Expand Up @@ -1175,7 +1175,7 @@ public void batchGet(List<Pair<byte[], byte[]>> keys, List<byte[]> values, int t
public int batchGetByPartitions(
List<Pair<byte[], byte[]>> keys, List<Pair<PException, byte[]>> results, int timeout)
throws PException {
if (keys == null || keys.size() == 0) {
if (keys == null || keys.isEmpty()) {
throw new PException("Invalid parameter: keys should not be null or empty");
}
if (results == null) {
Expand Down Expand Up @@ -1265,7 +1265,7 @@ public int batchGetByPartitions(
public int batchGet2(
List<Pair<byte[], byte[]>> keys, List<Pair<PException, byte[]>> results, int timeout)
throws PException {
if (keys == null || keys.size() == 0) {
if (keys == null || keys.isEmpty()) {
throw new PException("Invalid parameter: keys should not be null or empty");
}
if (results == null) {
Expand Down Expand Up @@ -1392,7 +1392,7 @@ public MultiGetResult multiGet(
public void batchMultiGet(
List<Pair<byte[], List<byte[]>>> keys, List<HashKeyData> values, int timeout)
throws PException {
if (keys == null || keys.size() == 0) {
if (keys == null || keys.isEmpty()) {
throw new PException("Invalid parameter: keys should not be null or empty");
}
if (values == null) {
Expand Down Expand Up @@ -1426,7 +1426,7 @@ public int batchMultiGet2(
List<Pair<PException, HashKeyData>> results,
int timeout)
throws PException {
if (keys == null || keys.size() == 0) {
if (keys == null || keys.isEmpty()) {
throw new PException("Invalid parameter: keys should not be null or empty");
}
if (results == null) {
Expand Down Expand Up @@ -1610,7 +1610,7 @@ public void multiSet(byte[] hashKey, List<Pair<byte[], byte[]>> values, int time
@Override
public void batchMultiSet(List<HashKeyData> items, int ttlSeconds, int timeout)
throws PException {
if (items == null || items.size() == 0) {
if (items == null || items.isEmpty()) {
throw new PException("Invalid parameter: items should not be null or empty");
}
if (ttlSeconds < 0) {
Expand Down Expand Up @@ -1683,7 +1683,7 @@ public void del(byte[] hashKey, byte[] sortKey, int timeout) throws PException {

@Override
public void batchDel(List<Pair<byte[], byte[]>> keys, int timeout) throws PException {
if (keys == null || keys.size() == 0) {
if (keys == null || keys.isEmpty()) {
throw new PException("Invalid parameter: keys should not be null or empty");
}
List<Future<Void>> futures = new ArrayList<Future<Void>>();
Expand Down Expand Up @@ -1850,7 +1850,7 @@ public void delRange(

@Override
public void batchMultiDel(List<Pair<byte[], List<byte[]>>> keys, int timeout) throws PException {
if (keys == null || keys.size() == 0) {
if (keys == null || keys.isEmpty()) {
throw new PException("Invalid parameter: keys should not be null or empty");
}
List<Future<Void>> futures = new ArrayList<Future<Void>>();
Expand Down

0 comments on commit a6965ac

Please sign in to comment.