Use isEmpty().
Don't nest else clauses needlessly.
diff --git a/src/main/java/org/apache/commons/math4/linear/RealMatrixFormat.java b/src/main/java/org/apache/commons/math4/linear/RealMatrixFormat.java
index ff025f8..51ccdc5 100644
--- a/src/main/java/org/apache/commons/math4/linear/RealMatrixFormat.java
+++ b/src/main/java/org/apache/commons/math4/linear/RealMatrixFormat.java
@@ -322,23 +322,21 @@
if (!rowComponents.isEmpty()) {
CompositeFormat.parseAndIgnoreWhitespace(source, pos);
if (!CompositeFormat.parseFixedstring(source, trimmedColumnSeparator, pos)) {
- if (trimmedRowSuffix.length() != 0 &&
+ if (!trimmedRowSuffix.isEmpty() &&
!CompositeFormat.parseFixedstring(source, trimmedRowSuffix, pos)) {
return null;
- } else {
- CompositeFormat.parseAndIgnoreWhitespace(source, pos);
- if (CompositeFormat.parseFixedstring(source, trimmedRowSeparator, pos)) {
- matrix.add(rowComponents);
- rowComponents = new ArrayList<>();
- continue;
- } else {
- loop = false;
- }
}
+ CompositeFormat.parseAndIgnoreWhitespace(source, pos);
+ if (CompositeFormat.parseFixedstring(source, trimmedRowSeparator, pos)) {
+ matrix.add(rowComponents);
+ rowComponents = new ArrayList<>();
+ continue;
+ }
+ loop = false;
}
} else {
CompositeFormat.parseAndIgnoreWhitespace(source, pos);
- if (trimmedRowPrefix.length() != 0 &&
+ if (!trimmedRowPrefix.isEmpty() &&
!CompositeFormat.parseFixedstring(source, trimmedRowPrefix, pos)) {
return null;
}