Replace uses of Spring CollectionUtils

See Javadoc in new bisq.common.util.CollectionUtils class.
This commit is contained in:
Chris Beams 2019-12-18 07:03:28 +01:00
parent f5a1854762
commit 2c7829948b
No known key found for this signature in database
GPG Key ID: 3D214F8F5BC5ED73
51 changed files with 116 additions and 100 deletions

View File

@ -17,11 +17,10 @@
package bisq.common.proto.persistable;
import bisq.common.util.CollectionUtils;
import com.google.protobuf.Message;
import org.springframework.util.CollectionUtils;
import java.util.ArrayList;
import java.util.List;

View File

@ -0,0 +1,35 @@
package bisq.common.util;
import java.util.Collection;
import java.util.Map;
/**
* Collection utility methods copied from Spring Framework v4.3.6's
* {@code org.springframework.util.CollectionUtils} class in order to make it possible to
* drop Bisq's dependency on Spring altogether. The name of the class and methods have
* been preserved here to minimize the impact to the Bisq codebase of making this change.
* All that is necessary to swap this implementation in is to change the CollectionUtils
* import statement.
*/
public class CollectionUtils {
/**
* Return {@code true} if the supplied Collection is {@code null} or empty.
* Otherwise, return {@code false}.
* @param collection the Collection to check
* @return whether the given Collection is empty
*/
public static boolean isEmpty(Collection<?> collection) {
return (collection == null || collection.isEmpty());
}
/**
* Return {@code true} if the supplied Map is {@code null} or empty.
* Otherwise, return {@code false}.
* @param map the Map to check
* @return whether the given Map is empty
*/
public static boolean isEmpty(Map<?, ?> map) {
return (map == null || map.isEmpty());
}
}

View File

@ -22,12 +22,11 @@ import bisq.network.p2p.storage.payload.ProtectedStoragePayload;
import bisq.common.app.Version;
import bisq.common.crypto.Sig;
import bisq.common.util.CollectionUtils;
import bisq.common.util.ExtraDataMapValidator;
import com.google.protobuf.ByteString;
import org.springframework.util.CollectionUtils;
import java.security.PublicKey;
import java.util.Map;

View File

@ -21,13 +21,12 @@ import bisq.core.dao.governance.ConsensusCritical;
import bisq.common.proto.network.NetworkPayload;
import bisq.common.proto.persistable.PersistablePayload;
import bisq.common.util.CollectionUtils;
import bisq.common.util.ExtraDataMapValidator;
import bisq.common.util.Utilities;
import com.google.protobuf.ByteString;
import org.springframework.util.CollectionUtils;
import java.util.Map;
import java.util.Optional;

View File

@ -25,12 +25,11 @@ import bisq.network.p2p.storage.payload.ProtectedStoragePayload;
import bisq.common.crypto.Sig;
import bisq.common.proto.persistable.PersistablePayload;
import bisq.common.util.CollectionUtils;
import bisq.common.util.ExtraDataMapValidator;
import com.google.protobuf.ByteString;
import org.springframework.util.CollectionUtils;
import java.security.PublicKey;
import java.util.Map;

View File

@ -23,8 +23,7 @@ import bisq.core.dao.state.model.ImmutableDaoStateModel;
import bisq.core.dao.state.model.blockchain.TxType;
import bisq.common.app.Version;
import org.springframework.util.CollectionUtils;
import bisq.common.util.CollectionUtils;
import java.util.Date;
import java.util.Map;

View File

@ -25,13 +25,12 @@ import bisq.core.dao.state.model.blockchain.TxType;
import bisq.common.app.Version;
import bisq.common.config.BaseCurrencyNetwork;
import bisq.common.util.CollectionUtils;
import org.bitcoinj.core.Address;
import org.bitcoinj.core.AddressFormatException;
import org.bitcoinj.core.Coin;
import org.springframework.util.CollectionUtils;
import java.util.Date;
import java.util.Map;

View File

@ -23,8 +23,7 @@ import bisq.core.dao.state.model.ImmutableDaoStateModel;
import bisq.core.dao.state.model.blockchain.TxType;
import bisq.common.app.Version;
import org.springframework.util.CollectionUtils;
import bisq.common.util.CollectionUtils;
import java.util.Date;
import java.util.Map;

View File

@ -23,8 +23,7 @@ import bisq.core.dao.state.model.ImmutableDaoStateModel;
import bisq.core.dao.state.model.blockchain.TxType;
import bisq.common.app.Version;
import org.springframework.util.CollectionUtils;
import bisq.common.util.CollectionUtils;
import java.util.Date;
import java.util.Map;

View File

@ -25,13 +25,12 @@ import bisq.core.dao.state.model.blockchain.TxType;
import bisq.common.app.Version;
import bisq.common.config.BaseCurrencyNetwork;
import bisq.common.util.CollectionUtils;
import org.bitcoinj.core.Address;
import org.bitcoinj.core.AddressFormatException;
import org.bitcoinj.core.Coin;
import org.springframework.util.CollectionUtils;
import java.util.Date;
import java.util.Map;

View File

@ -23,8 +23,7 @@ import bisq.core.dao.state.model.ImmutableDaoStateModel;
import bisq.core.dao.state.model.blockchain.TxType;
import bisq.common.app.Version;
import org.springframework.util.CollectionUtils;
import bisq.common.util.CollectionUtils;
import java.util.Date;
import java.util.Map;

View File

@ -23,8 +23,7 @@ import bisq.core.dao.state.model.ImmutableDaoStateModel;
import bisq.core.dao.state.model.blockchain.TxType;
import bisq.common.app.Version;
import org.springframework.util.CollectionUtils;
import bisq.common.util.CollectionUtils;
import java.util.Date;
import java.util.Map;

View File

@ -21,12 +21,11 @@ import bisq.network.p2p.storage.payload.ExpirablePayload;
import bisq.network.p2p.storage.payload.ProtectedStoragePayload;
import bisq.common.crypto.Sig;
import bisq.common.util.CollectionUtils;
import bisq.common.util.ExtraDataMapValidator;
import com.google.protobuf.ByteString;
import org.springframework.util.CollectionUtils;
import com.google.common.annotations.VisibleForTesting;
import java.security.PublicKey;

View File

@ -24,11 +24,10 @@ import bisq.network.p2p.storage.payload.RequiresOwnerIsOnlinePayload;
import bisq.common.crypto.PubKeyRing;
import bisq.common.proto.ProtoUtil;
import bisq.common.util.CollectionUtils;
import bisq.common.util.ExtraDataMapValidator;
import bisq.common.util.JsonExclude;
import org.springframework.util.CollectionUtils;
import java.security.PublicKey;
import java.util.ArrayList;

View File

@ -19,9 +19,9 @@ package bisq.core.payment.payload;
import bisq.core.locale.Res;
import com.google.protobuf.Message;
import bisq.common.util.CollectionUtils;
import org.springframework.util.CollectionUtils;
import com.google.protobuf.Message;
import java.nio.charset.Charset;

View File

@ -19,9 +19,9 @@ package bisq.core.payment.payload;
import bisq.core.locale.Res;
import com.google.protobuf.Message;
import bisq.common.util.CollectionUtils;
import org.springframework.util.CollectionUtils;
import com.google.protobuf.Message;
import java.nio.charset.Charset;

View File

@ -19,9 +19,9 @@ package bisq.core.payment.payload;
import bisq.core.locale.Res;
import com.google.protobuf.Message;
import bisq.common.util.CollectionUtils;
import org.springframework.util.CollectionUtils;
import com.google.protobuf.Message;
import java.nio.charset.Charset;

View File

@ -21,9 +21,9 @@ import bisq.core.locale.BankUtil;
import bisq.core.locale.CountryUtil;
import bisq.core.locale.Res;
import com.google.protobuf.Message;
import bisq.common.util.CollectionUtils;
import org.springframework.util.CollectionUtils;
import com.google.protobuf.Message;
import java.nio.charset.Charset;

View File

@ -19,9 +19,9 @@ package bisq.core.payment.payload;
import bisq.core.locale.Res;
import com.google.protobuf.Message;
import bisq.common.util.CollectionUtils;
import org.springframework.util.CollectionUtils;
import com.google.protobuf.Message;
import java.nio.charset.Charset;

View File

@ -19,9 +19,9 @@ package bisq.core.payment.payload;
import bisq.core.locale.Res;
import com.google.protobuf.Message;
import bisq.common.util.CollectionUtils;
import org.springframework.util.CollectionUtils;
import com.google.protobuf.Message;
import java.nio.charset.Charset;

View File

@ -18,9 +18,9 @@
package bisq.core.payment.payload;
import com.google.protobuf.Message;
import bisq.common.util.CollectionUtils;
import org.springframework.util.CollectionUtils;
import com.google.protobuf.Message;
import java.util.HashMap;
import java.util.Map;

View File

@ -19,9 +19,9 @@ package bisq.core.payment.payload;
import bisq.core.locale.Res;
import com.google.protobuf.Message;
import bisq.common.util.CollectionUtils;
import org.springframework.util.CollectionUtils;
import com.google.protobuf.Message;
import org.apache.commons.lang3.ArrayUtils;

View File

@ -19,9 +19,9 @@ package bisq.core.payment.payload;
import bisq.core.locale.Res;
import com.google.protobuf.Message;
import bisq.common.util.CollectionUtils;
import org.springframework.util.CollectionUtils;
import com.google.protobuf.Message;
import org.apache.commons.lang3.ArrayUtils;

View File

@ -19,9 +19,9 @@ package bisq.core.payment.payload;
import bisq.core.locale.Res;
import com.google.protobuf.Message;
import bisq.common.util.CollectionUtils;
import org.springframework.util.CollectionUtils;
import com.google.protobuf.Message;
import java.nio.charset.Charset;

View File

@ -18,9 +18,9 @@
package bisq.core.payment.payload;
import com.google.protobuf.Message;
import bisq.common.util.CollectionUtils;
import org.springframework.util.CollectionUtils;
import com.google.protobuf.Message;
import java.util.HashMap;
import java.util.Map;

View File

@ -19,9 +19,9 @@ package bisq.core.payment.payload;
import bisq.core.locale.Res;
import com.google.protobuf.Message;
import bisq.common.util.CollectionUtils;
import org.springframework.util.CollectionUtils;
import com.google.protobuf.Message;
import org.apache.commons.lang3.ArrayUtils;

View File

@ -19,9 +19,9 @@ package bisq.core.payment.payload;
import bisq.core.locale.Res;
import com.google.protobuf.Message;
import bisq.common.util.CollectionUtils;
import org.springframework.util.CollectionUtils;
import com.google.protobuf.Message;
import java.nio.charset.Charset;

View File

@ -19,9 +19,9 @@ package bisq.core.payment.payload;
import bisq.core.locale.Res;
import com.google.protobuf.Message;
import bisq.common.util.CollectionUtils;
import org.springframework.util.CollectionUtils;
import com.google.protobuf.Message;
import java.nio.charset.Charset;

View File

@ -21,9 +21,9 @@ import bisq.core.locale.BankUtil;
import bisq.core.locale.CountryUtil;
import bisq.core.locale.Res;
import com.google.protobuf.Message;
import bisq.common.util.CollectionUtils;
import org.springframework.util.CollectionUtils;
import com.google.protobuf.Message;
import java.nio.charset.Charset;

View File

@ -19,9 +19,9 @@ package bisq.core.payment.payload;
import bisq.core.locale.Res;
import com.google.protobuf.Message;
import bisq.common.util.CollectionUtils;
import org.springframework.util.CollectionUtils;
import com.google.protobuf.Message;
import java.util.HashMap;
import java.util.Map;

View File

@ -19,9 +19,9 @@ package bisq.core.payment.payload;
import bisq.core.locale.Res;
import com.google.protobuf.Message;
import bisq.common.util.CollectionUtils;
import org.springframework.util.CollectionUtils;
import com.google.protobuf.Message;
import java.nio.charset.Charset;

View File

@ -19,9 +19,9 @@ package bisq.core.payment.payload;
import bisq.core.locale.Res;
import com.google.protobuf.Message;
import bisq.common.util.CollectionUtils;
import org.springframework.util.CollectionUtils;
import com.google.protobuf.Message;
import java.nio.charset.Charset;

View File

@ -19,9 +19,9 @@ package bisq.core.payment.payload;
import bisq.core.locale.Res;
import com.google.protobuf.Message;
import bisq.common.util.CollectionUtils;
import org.springframework.util.CollectionUtils;
import com.google.protobuf.Message;
import java.nio.charset.Charset;

View File

@ -19,9 +19,9 @@ package bisq.core.payment.payload;
import bisq.core.locale.Res;
import com.google.protobuf.Message;
import bisq.common.util.CollectionUtils;
import org.springframework.util.CollectionUtils;
import com.google.protobuf.Message;
import java.nio.charset.Charset;

View File

@ -19,9 +19,9 @@ package bisq.core.payment.payload;
import bisq.core.locale.Res;
import com.google.protobuf.Message;
import bisq.common.util.CollectionUtils;
import org.springframework.util.CollectionUtils;
import com.google.protobuf.Message;
import java.nio.charset.Charset;

View File

@ -19,9 +19,9 @@ package bisq.core.payment.payload;
import bisq.core.locale.Res;
import com.google.protobuf.Message;
import bisq.common.util.CollectionUtils;
import org.springframework.util.CollectionUtils;
import com.google.protobuf.Message;
import java.util.HashMap;
import java.util.Map;

View File

@ -21,9 +21,9 @@ import bisq.core.locale.Country;
import bisq.core.locale.CountryUtil;
import bisq.core.locale.Res;
import com.google.protobuf.Message;
import bisq.common.util.CollectionUtils;
import org.springframework.util.CollectionUtils;
import com.google.protobuf.Message;
import org.apache.commons.lang3.ArrayUtils;

View File

@ -21,9 +21,9 @@ import bisq.core.locale.Country;
import bisq.core.locale.CountryUtil;
import bisq.core.locale.Res;
import com.google.protobuf.Message;
import bisq.common.util.CollectionUtils;
import org.springframework.util.CollectionUtils;
import com.google.protobuf.Message;
import org.apache.commons.lang3.ArrayUtils;

View File

@ -19,9 +19,9 @@ package bisq.core.payment.payload;
import bisq.core.locale.Res;
import com.google.protobuf.Message;
import bisq.common.util.CollectionUtils;
import org.springframework.util.CollectionUtils;
import com.google.protobuf.Message;
import com.google.common.base.Joiner;

View File

@ -19,9 +19,9 @@ package bisq.core.payment.payload;
import bisq.core.locale.Res;
import com.google.protobuf.Message;
import bisq.common.util.CollectionUtils;
import org.springframework.util.CollectionUtils;
import com.google.protobuf.Message;
import java.nio.charset.Charset;

View File

@ -19,9 +19,9 @@ package bisq.core.payment.payload;
import bisq.core.locale.Res;
import com.google.protobuf.Message;
import bisq.common.util.CollectionUtils;
import org.springframework.util.CollectionUtils;
import com.google.protobuf.Message;
import org.apache.commons.lang3.ArrayUtils;

View File

@ -19,9 +19,9 @@ package bisq.core.payment.payload;
import bisq.core.locale.Res;
import com.google.protobuf.Message;
import bisq.common.util.CollectionUtils;
import org.springframework.util.CollectionUtils;
import com.google.protobuf.Message;
import java.nio.charset.Charset;

View File

@ -19,9 +19,9 @@ package bisq.core.payment.payload;
import bisq.core.locale.Res;
import com.google.protobuf.Message;
import bisq.common.util.CollectionUtils;
import org.springframework.util.CollectionUtils;
import com.google.protobuf.Message;
import java.nio.charset.Charset;

View File

@ -19,9 +19,9 @@ package bisq.core.payment.payload;
import bisq.core.locale.Res;
import com.google.protobuf.Message;
import bisq.common.util.CollectionUtils;
import org.springframework.util.CollectionUtils;
import com.google.protobuf.Message;
import java.nio.charset.Charset;

View File

@ -21,9 +21,9 @@ import bisq.core.locale.BankUtil;
import bisq.core.locale.CountryUtil;
import bisq.core.locale.Res;
import com.google.protobuf.Message;
import bisq.common.util.CollectionUtils;
import org.springframework.util.CollectionUtils;
import com.google.protobuf.Message;
import java.nio.charset.Charset;

View File

@ -23,12 +23,11 @@ import bisq.network.p2p.NodeAddress;
import bisq.common.crypto.PubKeyRing;
import bisq.common.proto.ProtoUtil;
import bisq.common.util.CollectionUtils;
import bisq.common.util.Utilities;
import com.google.protobuf.ByteString;
import org.springframework.util.CollectionUtils;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

View File

@ -23,11 +23,10 @@ import bisq.network.p2p.NodeAddress;
import bisq.common.crypto.PubKeyRing;
import bisq.common.proto.ProtoUtil;
import bisq.common.util.CollectionUtils;
import com.google.protobuf.ByteString;
import org.springframework.util.CollectionUtils;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

View File

@ -26,11 +26,10 @@ import bisq.common.app.Capabilities;
import bisq.common.app.Capability;
import bisq.common.crypto.PubKeyRing;
import bisq.common.proto.ProtoUtil;
import bisq.common.util.CollectionUtils;
import com.google.protobuf.ByteString;
import org.springframework.util.CollectionUtils;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

View File

@ -29,6 +29,7 @@ import bisq.network.p2p.storage.payload.ProtectedStoragePayload;
import bisq.common.crypto.Sig;
import bisq.common.proto.persistable.PersistablePayload;
import bisq.common.util.CollectionUtils;
import bisq.common.util.ExtraDataMapValidator;
import bisq.common.util.JsonExclude;
@ -38,8 +39,6 @@ import org.bitcoinj.core.Coin;
import org.bitcoinj.utils.ExchangeRate;
import org.bitcoinj.utils.Fiat;
import org.springframework.util.CollectionUtils;
import java.security.PublicKey;
import java.util.Date;

View File

@ -32,6 +32,7 @@ import bisq.common.app.Capabilities;
import bisq.common.app.Capability;
import bisq.common.crypto.Hash;
import bisq.common.proto.persistable.PersistableEnvelope;
import bisq.common.util.CollectionUtils;
import bisq.common.util.ExtraDataMapValidator;
import bisq.common.util.JsonExclude;
import bisq.common.util.Utilities;
@ -42,8 +43,6 @@ import org.bitcoinj.core.Coin;
import org.bitcoinj.utils.ExchangeRate;
import org.bitcoinj.utils.Fiat;
import org.springframework.util.CollectionUtils;
import com.google.common.base.Charsets;
import java.util.Date;

View File

@ -21,12 +21,11 @@ import bisq.network.p2p.PrefixedSealedAndSignedMessage;
import bisq.network.p2p.storage.messages.AddOncePayload;
import bisq.common.crypto.Sig;
import bisq.common.util.CollectionUtils;
import bisq.common.util.ExtraDataMapValidator;
import com.google.protobuf.ByteString;
import org.springframework.util.CollectionUtils;
import java.security.PublicKey;
import java.util.Map;