diff --git a/pom.xml b/pom.xml index 4196ae44..c54586aa 100644 --- a/pom.xml +++ b/pom.xml @@ -21,8 +21,6 @@ 4.12 1.21 - 1.7.29 - 2.13.3 3.8.1 @@ -257,13 +255,6 @@ - - - org.slf4j - slf4j-api - ${slf4j.version} - - junit @@ -271,24 +262,6 @@ ${junit.version} test - - org.apache.logging.log4j - log4j-api - ${log4j.version} - test - - - org.apache.logging.log4j - log4j-core - ${log4j.version} - test - - - org.apache.logging.log4j - log4j-slf4j-impl - ${log4j.version} - test - org.openjdk.jmh jmh-core diff --git a/src/main/java/com/github/curiousoddman/rgxgen/generator/nodes/Choice.java b/src/main/java/com/github/curiousoddman/rgxgen/generator/nodes/Choice.java index 2c40f946..b63bae53 100644 --- a/src/main/java/com/github/curiousoddman/rgxgen/generator/nodes/Choice.java +++ b/src/main/java/com/github/curiousoddman/rgxgen/generator/nodes/Choice.java @@ -17,21 +17,14 @@ /* **************************************************************************/ import com.github.curiousoddman.rgxgen.generator.visitors.NodeVisitor; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import java.util.Arrays; public class Choice implements Node { - private static final Logger LOGGER = LoggerFactory.getLogger(Choice.class); - private final Node[] aNodes; public Choice(Node... nodes) { - if (LOGGER.isTraceEnabled()) { - LOGGER.trace("Creating from {} ", Arrays.asList(nodes)); - } aNodes = nodes; } diff --git a/src/main/java/com/github/curiousoddman/rgxgen/generator/nodes/FinalSymbol.java b/src/main/java/com/github/curiousoddman/rgxgen/generator/nodes/FinalSymbol.java index 4d877bc7..c87ef129 100644 --- a/src/main/java/com/github/curiousoddman/rgxgen/generator/nodes/FinalSymbol.java +++ b/src/main/java/com/github/curiousoddman/rgxgen/generator/nodes/FinalSymbol.java @@ -17,17 +17,11 @@ /* **************************************************************************/ import com.github.curiousoddman.rgxgen.generator.visitors.NodeVisitor; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; public class FinalSymbol implements Node { - - private static final Logger LOGGER = LoggerFactory.getLogger(FinalSymbol.class); - private final String aValue; public FinalSymbol(String value) { - LOGGER.trace("Creating '{}'", value); aValue = value; } diff --git a/src/main/java/com/github/curiousoddman/rgxgen/generator/nodes/Group.java b/src/main/java/com/github/curiousoddman/rgxgen/generator/nodes/Group.java index 13510b21..8eeb2576 100644 --- a/src/main/java/com/github/curiousoddman/rgxgen/generator/nodes/Group.java +++ b/src/main/java/com/github/curiousoddman/rgxgen/generator/nodes/Group.java @@ -17,17 +17,12 @@ /* **************************************************************************/ import com.github.curiousoddman.rgxgen.generator.visitors.NodeVisitor; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; public class Group implements Node { - private static final Logger LOGGER = LoggerFactory.getLogger(Group.class); - private final Node aNode; private final int aGroupIndex; public Group(int index, Node node) { - LOGGER.trace("Crating idx = '{}' from '{}'", index, node); aNode = node; aGroupIndex = index; } diff --git a/src/main/java/com/github/curiousoddman/rgxgen/generator/nodes/GroupRef.java b/src/main/java/com/github/curiousoddman/rgxgen/generator/nodes/GroupRef.java index 3db4e3d1..bfbad5f8 100644 --- a/src/main/java/com/github/curiousoddman/rgxgen/generator/nodes/GroupRef.java +++ b/src/main/java/com/github/curiousoddman/rgxgen/generator/nodes/GroupRef.java @@ -17,17 +17,11 @@ /* **************************************************************************/ import com.github.curiousoddman.rgxgen.generator.visitors.NodeVisitor; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; public class GroupRef implements Node { - - private static final Logger LOGGER = LoggerFactory.getLogger(GroupRef.class); - private final int aIndex; public GroupRef(int index) { - LOGGER.trace("Crating idx = '{}'", index); aIndex = index; } diff --git a/src/main/java/com/github/curiousoddman/rgxgen/generator/nodes/NotSymbol.java b/src/main/java/com/github/curiousoddman/rgxgen/generator/nodes/NotSymbol.java index 06eda6fb..0858102e 100644 --- a/src/main/java/com/github/curiousoddman/rgxgen/generator/nodes/NotSymbol.java +++ b/src/main/java/com/github/curiousoddman/rgxgen/generator/nodes/NotSymbol.java @@ -17,19 +17,13 @@ /* **************************************************************************/ import com.github.curiousoddman.rgxgen.generator.visitors.NodeVisitor; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import java.util.regex.Pattern; public class NotSymbol implements Node { - - private static final Logger LOGGER = LoggerFactory.getLogger(NotSymbol.class); - private final Pattern aSubPattern; public NotSymbol(String pattern) { - LOGGER.trace("Crating '{}'", pattern); aSubPattern = Pattern.compile(pattern); } diff --git a/src/main/java/com/github/curiousoddman/rgxgen/generator/nodes/Repeat.java b/src/main/java/com/github/curiousoddman/rgxgen/generator/nodes/Repeat.java index 6061db45..ab3109f0 100644 --- a/src/main/java/com/github/curiousoddman/rgxgen/generator/nodes/Repeat.java +++ b/src/main/java/com/github/curiousoddman/rgxgen/generator/nodes/Repeat.java @@ -17,13 +17,8 @@ /* **************************************************************************/ import com.github.curiousoddman.rgxgen.generator.visitors.NodeVisitor; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; public class Repeat implements Node { - - private static final Logger LOGGER = LoggerFactory.getLogger(Repeat.class); - private final Node aNode; private final int aMin; private final int aMax; @@ -37,7 +32,6 @@ public Repeat(Node node, int times) { } public Repeat(Node node, int min, int max) { - LOGGER.trace("Crating ({} to {}) '{}'", min, max, node); aNode = node; aMin = min; aMax = max; diff --git a/src/main/java/com/github/curiousoddman/rgxgen/generator/nodes/Sequence.java b/src/main/java/com/github/curiousoddman/rgxgen/generator/nodes/Sequence.java index ce6d3150..26960408 100644 --- a/src/main/java/com/github/curiousoddman/rgxgen/generator/nodes/Sequence.java +++ b/src/main/java/com/github/curiousoddman/rgxgen/generator/nodes/Sequence.java @@ -17,21 +17,13 @@ /* **************************************************************************/ import com.github.curiousoddman.rgxgen.generator.visitors.NodeVisitor; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import java.util.Arrays; public class Sequence implements Node { - - private static final Logger LOGGER = LoggerFactory.getLogger(Sequence.class); - private final Node[] aNodes; public Sequence(Node... nodes) { - if (LOGGER.isTraceEnabled()) { - LOGGER.trace("Creating from {} ", Arrays.asList(nodes)); - } aNodes = nodes; } diff --git a/src/main/java/com/github/curiousoddman/rgxgen/generator/nodes/SymbolSet.java b/src/main/java/com/github/curiousoddman/rgxgen/generator/nodes/SymbolSet.java index 63f5edc0..c062e7bd 100644 --- a/src/main/java/com/github/curiousoddman/rgxgen/generator/nodes/SymbolSet.java +++ b/src/main/java/com/github/curiousoddman/rgxgen/generator/nodes/SymbolSet.java @@ -18,8 +18,6 @@ import com.github.curiousoddman.rgxgen.generator.visitors.NodeVisitor; import com.github.curiousoddman.rgxgen.util.Util; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import java.util.*; import java.util.stream.Collectors; @@ -29,9 +27,6 @@ * Generate Any printable character. */ public class SymbolSet implements Node { - - private static final Logger LOGGER = LoggerFactory.getLogger(SymbolSet.class); - private static final String[] ALL_SYMBOLS = new String[127 - 32]; public static String[] getAllSymbols() { @@ -46,10 +41,6 @@ public static String[] getAllSymbols() { ALL_SYMBOLS[i - SPACE_ASCII_CODE] = Character.valueOf((char) i) .toString(); } - - if (LOGGER.isTraceEnabled()) { - LOGGER.trace("All symbols {} ", Arrays.asList(ALL_SYMBOLS)); - } } /** @@ -114,7 +105,7 @@ public SymbolSet(String[] symbols, TYPE type) { this(Collections.emptyList(), symbols, type); } - public SymbolSet(List symbolRanges, TYPE type) { + public SymbolSet(Collection symbolRanges, TYPE type) { this(symbolRanges, Util.ZERO_LENGTH_STRING_ARRAY, type); } @@ -125,11 +116,7 @@ public SymbolSet(List symbolRanges, TYPE type) { * @param symbols symbols to include/exclude * @param type POSITIVE - include, NEGATIVE - exclude */ - public SymbolSet(List symbolRanges, String[] symbols, TYPE type) { - if (LOGGER.isTraceEnabled()) { - LOGGER.trace("Creating [positive = {}] from {} and {}", type, symbolRanges, Arrays.asList(symbols)); - } - + public SymbolSet(Collection symbolRanges, String[] symbols, TYPE type) { List initial = type == TYPE.NEGATIVE ? new ArrayList<>(Arrays.asList(ALL_SYMBOLS)) // First we need to add all, later we remove unnecessary : new ArrayList<>(ALL_SYMBOLS.length); // Most probably it will be enough. diff --git a/src/main/java/com/github/curiousoddman/rgxgen/generator/visitors/UniqueGenerationVisitor.java b/src/main/java/com/github/curiousoddman/rgxgen/generator/visitors/UniqueGenerationVisitor.java index d94428ca..a30858a5 100644 --- a/src/main/java/com/github/curiousoddman/rgxgen/generator/visitors/UniqueGenerationVisitor.java +++ b/src/main/java/com/github/curiousoddman/rgxgen/generator/visitors/UniqueGenerationVisitor.java @@ -20,8 +20,6 @@ import com.github.curiousoddman.rgxgen.iterators.ReferenceIterator; import com.github.curiousoddman.rgxgen.iterators.StringIterator; import com.github.curiousoddman.rgxgen.iterators.suppliers.*; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import java.util.ArrayList; import java.util.HashMap; @@ -30,9 +28,6 @@ import java.util.function.Supplier; public class UniqueGenerationVisitor implements NodeVisitor { - - private static final Logger LOGGER = LoggerFactory.getLogger(UniqueGenerationVisitor.class); - private final List> aIterators = new ArrayList<>(); private final Map> aReferenceIteratorMap; private final Map aGroupIterators; @@ -42,7 +37,6 @@ public UniqueGenerationVisitor() { } public UniqueGenerationVisitor(Map> referenceIteratorMap, Map groupIterators) { - LOGGER.trace("Creating\n\trefs: {}\n\tgrps: {}", referenceIteratorMap, groupIterators); aReferenceIteratorMap = referenceIteratorMap; aGroupIterators = groupIterators; } diff --git a/src/main/java/com/github/curiousoddman/rgxgen/iterators/ReferenceIterator.java b/src/main/java/com/github/curiousoddman/rgxgen/iterators/ReferenceIterator.java index e2eeb236..e8b799a3 100644 --- a/src/main/java/com/github/curiousoddman/rgxgen/iterators/ReferenceIterator.java +++ b/src/main/java/com/github/curiousoddman/rgxgen/iterators/ReferenceIterator.java @@ -16,13 +16,7 @@ limitations under the License. /* **************************************************************************/ -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - public class ReferenceIterator extends StringIterator { - - private static final Logger LOGGER = LoggerFactory.getLogger(ReferenceIterator.class); - private StringIterator aOther; private boolean hasNext = true; private String aLast; @@ -50,7 +44,6 @@ public void reset() { @Override public boolean hasNext() { - LOGGER.trace("hasNext = {}, aOther.current() = {}, aLast = {}", hasNext, aOther.current(), aLast); return hasNext || !aOther.current() .equals(aLast); } diff --git a/src/main/java/com/github/curiousoddman/rgxgen/iterators/StringIterator.java b/src/main/java/com/github/curiousoddman/rgxgen/iterators/StringIterator.java index cb9117e3..0f751f49 100644 --- a/src/main/java/com/github/curiousoddman/rgxgen/iterators/StringIterator.java +++ b/src/main/java/com/github/curiousoddman/rgxgen/iterators/StringIterator.java @@ -16,19 +16,13 @@ limitations under the License. /* **************************************************************************/ -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import java.util.Iterator; public abstract class StringIterator implements Iterator { - private static final Logger LOGGER = LoggerFactory.getLogger(StringIterator.class); - @SuppressWarnings("IteratorNextCanNotThrowNoSuchElementException") @Override public String next() { String current = nextImpl(); - LOGGER.trace("Produced value: '{}' using '{}'", current, this); return current; } diff --git a/src/main/java/com/github/curiousoddman/rgxgen/iterators/suppliers/GroupIteratorSupplier.java b/src/main/java/com/github/curiousoddman/rgxgen/iterators/suppliers/GroupIteratorSupplier.java index 7361e5d8..3794fdbe 100644 --- a/src/main/java/com/github/curiousoddman/rgxgen/iterators/suppliers/GroupIteratorSupplier.java +++ b/src/main/java/com/github/curiousoddman/rgxgen/iterators/suppliers/GroupIteratorSupplier.java @@ -18,8 +18,6 @@ import com.github.curiousoddman.rgxgen.iterators.ReferenceIterator; import com.github.curiousoddman.rgxgen.iterators.StringIterator; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import java.util.Collections; import java.util.List; @@ -27,9 +25,6 @@ import java.util.function.Supplier; public class GroupIteratorSupplier implements Supplier { - - private static final Logger LOGGER = LoggerFactory.getLogger(GroupIteratorSupplier.class); - private final Supplier aIteratorSupplier; private final Map> aReferenceIteratorMap; private final Map aGroupIteratorsMap; @@ -40,18 +35,14 @@ public GroupIteratorSupplier(Supplier iteratorSupplier, Map orDefault = aReferenceIteratorMap.getOrDefault(aIndex, Collections.emptyList()); - LOGGER.debug("ReferenceIterators to connect: {}", orDefault); + List orDefault = aReferenceIteratorMap.getOrDefault(aIndex, Collections.emptyList()); for (ReferenceIterator referenceIterator : orDefault) { - LOGGER.debug("GroupRef[{}] connecting to group {} ", aIndex, stringIterator); referenceIterator.setOther(stringIterator); } return stringIterator; diff --git a/src/main/java/com/github/curiousoddman/rgxgen/iterators/suppliers/ReferenceIteratorSupplier.java b/src/main/java/com/github/curiousoddman/rgxgen/iterators/suppliers/ReferenceIteratorSupplier.java index 25469ef3..d1efc4c5 100644 --- a/src/main/java/com/github/curiousoddman/rgxgen/iterators/suppliers/ReferenceIteratorSupplier.java +++ b/src/main/java/com/github/curiousoddman/rgxgen/iterators/suppliers/ReferenceIteratorSupplier.java @@ -18,8 +18,6 @@ import com.github.curiousoddman.rgxgen.iterators.ReferenceIterator; import com.github.curiousoddman.rgxgen.iterators.StringIterator; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import java.util.ArrayList; import java.util.List; @@ -27,9 +25,6 @@ import java.util.function.Supplier; public class ReferenceIteratorSupplier implements Supplier { - - private static final Logger LOGGER = LoggerFactory.getLogger(ReferenceIteratorSupplier.class); - private final Map> aReferenceIteratorMap; private final Map aGroupIteratorsMap; private final int aIndex; @@ -38,20 +33,16 @@ public ReferenceIteratorSupplier(Map> reference aReferenceIteratorMap = referenceIteratorMap; aGroupIteratorsMap = groupIteratorsMap; aIndex = index; - LOGGER.trace("Creating idx {}\n\trefs: {}\n\tgrps: {}", index, referenceIteratorMap, groupIteratorsMap); } @Override public StringIterator get() { - LOGGER.trace("Getting idx {}\n\trefs: {}\n\tgrps: {}", aIndex, aReferenceIteratorMap, aGroupIteratorsMap); ReferenceIterator referenceIterator = new ReferenceIterator(); final StringIterator stringIterator = aGroupIteratorsMap.get(aIndex); if (stringIterator != null) { - LOGGER.debug("GroupRef[{}] connecting to group {} ", aIndex, stringIterator); referenceIterator.setOther(stringIterator); } - LOGGER.debug("GroupRef[{}] adding to connection queue group ", aIndex); aReferenceIteratorMap.computeIfAbsent(aIndex, i -> new ArrayList<>()) .add(referenceIterator); diff --git a/src/main/java/com/github/curiousoddman/rgxgen/parsing/dflt/DefaultTreeBuilder.java b/src/main/java/com/github/curiousoddman/rgxgen/parsing/dflt/DefaultTreeBuilder.java index 240ae771..d28fa744 100644 --- a/src/main/java/com/github/curiousoddman/rgxgen/parsing/dflt/DefaultTreeBuilder.java +++ b/src/main/java/com/github/curiousoddman/rgxgen/parsing/dflt/DefaultTreeBuilder.java @@ -117,7 +117,7 @@ private GroupType processGroupType() { case "?<": GroupType res = GroupType.POSITIVE_LOOKBEHIND; - final char next = aCharIterator.next(); + char next = aCharIterator.next(); if (next == '!') { res = GroupType.NEGATIVE_LOOKBEHIND; } else if (next != '=') { // Positive Lookbehind does not affect generation. diff --git a/src/test/java/com/github/curiousoddman/rgxgen/CombinedTests.java b/src/test/java/com/github/curiousoddman/rgxgen/CombinedTests.java index 8c0225e1..94e94d8a 100644 --- a/src/test/java/com/github/curiousoddman/rgxgen/CombinedTests.java +++ b/src/test/java/com/github/curiousoddman/rgxgen/CombinedTests.java @@ -122,7 +122,7 @@ public void generateNotMatchingTest() { GenerationVisitor generationVisitor = new NotMatchingGenerationVisitor(); aTestPattern.aResultNode.visit(generationVisitor); boolean result = isValidGenerated(generationVisitor.getString()); - assertFalse("Text: '" + generationVisitor.getString() + "'matches pattern " + aTestPattern.aPattern, result); + assertFalse("Text: '" + generationVisitor.getString() + "' matches pattern " + aTestPattern.aPattern, result); } } diff --git a/src/test/java/com/github/curiousoddman/rgxgen/NotMatchingGenerationTests.java b/src/test/java/com/github/curiousoddman/rgxgen/NotMatchingGenerationTests.java index 2828b417..3bc87066 100644 --- a/src/test/java/com/github/curiousoddman/rgxgen/NotMatchingGenerationTests.java +++ b/src/test/java/com/github/curiousoddman/rgxgen/NotMatchingGenerationTests.java @@ -43,7 +43,7 @@ private static Collection initialData() { @Parameterized.Parameters(name = "{0}") public static Collection data() { return initialData().stream() - .flatMap(arr -> IntStream.range(0, 1000) + .flatMap(arr -> IntStream.range(0, 100) .mapToObj(i -> new Object[]{arr[0], arr[1], i})) .collect(Collectors.toList()); } diff --git a/src/test/java/com/github/curiousoddman/rgxgen/TestPattern.java b/src/test/java/com/github/curiousoddman/rgxgen/TestPattern.java index 4f54d109..39d8e777 100644 --- a/src/test/java/com/github/curiousoddman/rgxgen/TestPattern.java +++ b/src/test/java/com/github/curiousoddman/rgxgen/TestPattern.java @@ -246,13 +246,17 @@ public enum TestPattern { BigInteger.valueOf(2), Arrays.asList("", "A")), EMPTY_CHOICE_IN_THE_MIDDLE_OF_CHOICES("(B||A)", - new Group(1, new Choice(new FinalSymbol("B"), new FinalSymbol(""), new FinalSymbol("A"))), - BigInteger.valueOf(3), - Arrays.asList("B", "", "A")), + new Group(1, new Choice(new FinalSymbol("B"), new FinalSymbol(""), new FinalSymbol("A"))), + BigInteger.valueOf(3), + Arrays.asList("B", "", "A")), EMPTY_CHOICE_AT_THE_END_OF_CHOICES("(A|)", new Group(1, new Choice(new FinalSymbol("A"), new FinalSymbol(""))), BigInteger.valueOf(2), - Arrays.asList("A", "")); + Arrays.asList("A", "")), + CHOICE_IS_A_GROUP("(a|b)\\1", + new Sequence(new Group(1, new Choice(new FinalSymbol("a"), new FinalSymbol("b"))), new GroupRef(1)), + BigInteger.valueOf(2), + Arrays.asList("aa", "bb")); final String aPattern; final Node aResultNode; diff --git a/src/test/java/com/github/curiousoddman/rgxgen/TestingUtilities.java b/src/test/java/com/github/curiousoddman/rgxgen/TestingUtilities.java index 4328c16c..5305bad7 100644 --- a/src/test/java/com/github/curiousoddman/rgxgen/TestingUtilities.java +++ b/src/test/java/com/github/curiousoddman/rgxgen/TestingUtilities.java @@ -1,7 +1,5 @@ package com.github.curiousoddman.rgxgen; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import java.util.Iterator; import java.util.LinkedList; @@ -9,14 +7,11 @@ public final class TestingUtilities { - private static final Logger LOGGER = LoggerFactory.getLogger(TestingUtilities.class); - public static List iteratorToList(Iterator it) { List lst = new LinkedList<>(); while (it.hasNext()) { - final T next = it.next(); - LOGGER.trace("{}", next); + T next = it.next(); lst.add(next); }