Skip to content

Commit

Permalink
Fixing SING_SINGLETON_HAS_NONPRIVATE_CONSTRUCTOR error
Browse files Browse the repository at this point in the history
  • Loading branch information
baldawar committed Apr 23, 2024
1 parent 78ce418 commit 2ba7f6c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
11 changes: 8 additions & 3 deletions src/main/software/amazon/event/ruler/input/DefaultParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,12 @@ public class DefaultParser implements MatchTypeParser, ByteParser {
private final SuffixParser suffixParser;
private final SuffixEqualsIgnoreCaseParser suffixEqualsIgnoreCaseParser;

DefaultParser() {
private DefaultParser() {
this(new WildcardParser(), new EqualsIgnoreCaseParser(), new SuffixParser(), new SuffixEqualsIgnoreCaseParser());
}

DefaultParser(WildcardParser wildcardParser, EqualsIgnoreCaseParser equalsIgnoreCaseParser, SuffixParser suffixParser,
SuffixEqualsIgnoreCaseParser suffixEqualsIgnoreCaseParser) {
private DefaultParser(WildcardParser wildcardParser, EqualsIgnoreCaseParser equalsIgnoreCaseParser,
SuffixParser suffixParser, SuffixEqualsIgnoreCaseParser suffixEqualsIgnoreCaseParser) {
this.wildcardParser = wildcardParser;
this.equalsIgnoreCaseParser = equalsIgnoreCaseParser;
this.suffixParser = suffixParser;
Expand All @@ -60,6 +60,11 @@ public static synchronized DefaultParser getParser() {
return SINGLETON;
}

static DefaultParser getNonSingletonParserForTesting(WildcardParser wildcardParser, EqualsIgnoreCaseParser equalsIgnoreCaseParser,
SuffixParser suffixParser, SuffixEqualsIgnoreCaseParser suffixEqualsIgnoreCaseParser) {
return new DefaultParser(wildcardParser, equalsIgnoreCaseParser, suffixParser, suffixEqualsIgnoreCaseParser);
}

@Override
public InputCharacter[] parse(final MatchType type, final String value) {
if (type == WILDCARD || type == ANYTHING_BUT_WILDCARD) {
Expand Down
2 changes: 1 addition & 1 deletion src/test/software/amazon/event/ruler/input/ParserTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public void testParseString() {
@Test
public void testOtherMatchTypes() {
final int[] parserInvokedCount = { 0, 0, 0, 0 };
DefaultParser parser = new DefaultParser(
DefaultParser parser = DefaultParser.getNonSingletonParserForTesting(
new WildcardParser() {
@Override
public InputCharacter[] parse(String value) {
Expand Down

0 comments on commit 2ba7f6c

Please sign in to comment.