Skip to content

Commit 0b4a726

Browse files
committed
removed assertutils
1 parent 8b4a5a3 commit 0b4a726

File tree

5 files changed

+11
-57
lines changed

5 files changed

+11
-57
lines changed

src/main/java/com/igormaznitsa/prologparser/terms/PrologInt.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
import java.util.Map;
2828
import java.util.stream.IntStream;
2929

30-
import static com.igormaznitsa.prologparser.utils.AssertUtils.assertStringNotNullAndNotEmpty;
3130
import static java.util.Objects.requireNonNull;
3231

3332
/**
@@ -74,9 +73,8 @@ public PrologInt(final BigInteger value, final int line, final int pos) {
7473
}
7574

7675
private static BigInteger valueOf(final String text) {
77-
assertStringNotNullAndNotEmpty(text);
7876
BigInteger result = null;
79-
if (text.charAt(0) == '-') {
77+
if (assertNonEmptyString(text).charAt(0) == '-') {
8078
if (text.length() < 4) {
8179
result = cachedValues.get(text);
8280
}

src/main/java/com/igormaznitsa/prologparser/terms/PrologTerm.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import java.io.Serializable;
2727
import java.math.BigDecimal;
2828
import java.util.List;
29+
import java.util.Objects;
2930
import java.util.stream.Stream;
3031

3132
import static com.igormaznitsa.prologparser.terms.Quotation.NONE;
@@ -87,6 +88,13 @@ public static Quotation findQuotation(final String atomText) {
8788
return result;
8889
}
8990

91+
protected static String assertNonEmptyString(final String str) {
92+
if (Objects.requireNonNull(str).isEmpty()) {
93+
throw new IllegalArgumentException("Expected non-empty string");
94+
}
95+
return str;
96+
}
97+
9098
/**
9199
* Flat content of the term for comma, make sense for structures.
92100
*

src/main/java/com/igormaznitsa/prologparser/terms/PrologVar.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@
2121

2222
package com.igormaznitsa.prologparser.terms;
2323

24-
import com.igormaznitsa.prologparser.utils.AssertUtils;
25-
2624
/**
2725
* Representation of prolog variable.
2826
*/
@@ -46,7 +44,7 @@ public PrologVar(final int line, final int pos) {
4644
public PrologVar(final String text) {
4745
super(text, Quotation.NONE);
4846

49-
final char startWith = AssertUtils.assertStringNotNullAndNotEmpty(text).charAt(0);
47+
final char startWith = assertNonEmptyString(text).charAt(0);
5048

5149
if (!Character.isUpperCase(startWith) && startWith != '_') {
5250
throw new IllegalArgumentException("Var must start with upper case char or '_' [" + text + ']');

src/main/java/com/igormaznitsa/prologparser/tokenizer/Op.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
import com.igormaznitsa.prologparser.terms.PrologTerm;
2828
import com.igormaznitsa.prologparser.terms.Quotation;
2929
import com.igormaznitsa.prologparser.terms.TermType;
30-
import com.igormaznitsa.prologparser.utils.AssertUtils;
3130

3231
import java.util.ArrayList;
3332
import java.util.Arrays;
@@ -221,9 +220,7 @@ private static String[] assertOpValidOpName(final String[] names) {
221220
}
222221

223222
private static String assertOpValidOpName(final String name) {
224-
AssertUtils.assertStringNotNullAndNotEmpty(name);
225-
226-
final char firstChar = name.charAt(0);
223+
final char firstChar = assertNonEmptyString(name).charAt(0);
227224

228225
if (Character.isWhitespace(firstChar) || Character.isISOControl(firstChar)) {
229226
throw new IllegalArgumentException("Space char as first one");

src/main/java/com/igormaznitsa/prologparser/utils/AssertUtils.java

Lines changed: 0 additions & 47 deletions
This file was deleted.

0 commit comments

Comments
 (0)