8215281: Use String.isEmpty() when applicable in java.base

Reviewed-by: dfuchs, alanb
This commit is contained in:
Claes Redestad 2018-12-13 15:31:05 +01:00
parent c998ead188
commit a3df1d618e
155 changed files with 340 additions and 382 deletions

View file

@ -75,7 +75,7 @@ public abstract class AbstractAlgorithmConstraints
static boolean checkAlgorithm(String[] algorithms, String algorithm,
AlgorithmDecomposer decomposer) {
if (algorithm == null || algorithm.length() == 0) {
if (algorithm == null || algorithm.isEmpty()) {
throw new IllegalArgumentException("No algorithm name specified");
}

View file

@ -80,7 +80,7 @@ public class AlgorithmDecomposer {
* Please override the method if need to support more name pattern.
*/
public Set<String> decompose(String algorithm) {
if (algorithm == null || algorithm.length() == 0) {
if (algorithm == null || algorithm.isEmpty()) {
return new HashSet<>();
}
@ -167,7 +167,7 @@ public class AlgorithmDecomposer {
* message digest algorithm name to avoid overly complicated checking.
*/
public static Set<String> decomposeOneHash(String algorithm) {
if (algorithm == null || algorithm.length() == 0) {
if (algorithm == null || algorithm.isEmpty()) {
return new HashSet<>();
}

View file

@ -135,7 +135,7 @@ public class DisabledAlgorithmConstraints extends AbstractAlgorithmConstraints {
public final boolean permits(Set<CryptoPrimitive> primitives,
String algorithm, Key key, AlgorithmParameters parameters) {
if (algorithm == null || algorithm.length() == 0) {
if (algorithm == null || algorithm.isEmpty()) {
throw new IllegalArgumentException("No algorithm name specified");
}
@ -188,7 +188,7 @@ public class DisabledAlgorithmConstraints extends AbstractAlgorithmConstraints {
}
// check the signature algorithm with parameters
if (algorithm != null && algorithm.length() != 0) {
if (algorithm != null && !algorithm.isEmpty()) {
if (!permits(primitives, algorithm, parameters)) {
return false;
}

View file

@ -423,7 +423,7 @@ public class SignatureFileVerifier {
// This means we have an error in finding weak algorithms, run in
// debug mode to see permittedAlgs map's values.
if (w.length() == 0) {
if (w.isEmpty()) {
return "Unknown Algorithm(s)";
}