@Test public void is_reusable() { Parser<GherkinDocument.Builder> parser = new Parser<>(new GherkinDocumentBuilder(idGenerator)); TokenMatcher matcher = new TokenMatcher(); GherkinDocument d1 = parser.parse("Feature: 1", matcher).build(); GherkinDocument d2 = parser.parse("Feature: 2", matcher).build(); assertEquals("1", d1.getFeature().getName()); assertEquals("2", d2.getFeature().getName()); }
@Override public void build(Token token) { RuleType ruleType = RuleType.cast(token.matchedType); if (token.matchedType == TokenType.Comment) { gherkinDocumentBuilder.addComments(Comment.newBuilder() .setLocation(getLocation(token, 0)) .setText(token.matchedText) ); } else { currentNode().add(ruleType, token); } }
GherkinDocumentBuilder implements Builder<GherkinDocument.Builder> { @Override public void build(Token token) { RuleType ruleType = RuleType.cast(token.matchedType); if (token.matchedType == TokenType.Comment) { gherkinDocumentBuilder.addComments(Comment.newBuilder() .setLocation(getLocation(token, 0)) .setText(token.matchedText) ); } else { currentNode().add(ruleType, token); } } }
GherkinDocumentBuilder implements Builder<GherkinDocument.Builder> { @Override public void build(Token token) { RuleType ruleType = RuleType.cast(token.matchedType); if (token.matchedType == TokenType.Comment) { gherkinDocumentBuilder.addComments(Comment.newBuilder() .setLocation(getLocation(token, 0)) .setText(token.matchedText) ); } else { currentNode().add(ruleType, token); } } GherkinDocumentBuilder(IdGenerator idGenerator); }
GherkinDocumentBuilder implements Builder<GherkinDocument.Builder> { @Override public void build(Token token) { RuleType ruleType = RuleType.cast(token.matchedType); if (token.matchedType == TokenType.Comment) { gherkinDocumentBuilder.addComments(Comment.newBuilder() .setLocation(getLocation(token, 0)) .setText(token.matchedText) ); } else { currentNode().add(ruleType, token); } } GherkinDocumentBuilder(IdGenerator idGenerator); @Override void reset(); @Override void build(Token token); @Override void startRule(RuleType ruleType); @Override void endRule(RuleType ruleType); @Override GherkinDocument.Builder getResult(); }
GherkinDocumentBuilder implements Builder<GherkinDocument.Builder> { @Override public void build(Token token) { RuleType ruleType = RuleType.cast(token.matchedType); if (token.matchedType == TokenType.Comment) { gherkinDocumentBuilder.addComments(Comment.newBuilder() .setLocation(getLocation(token, 0)) .setText(token.matchedText) ); } else { currentNode().add(ruleType, token); } } GherkinDocumentBuilder(IdGenerator idGenerator); @Override void reset(); @Override void build(Token token); @Override void startRule(RuleType ruleType); @Override void endRule(RuleType ruleType); @Override GherkinDocument.Builder getResult();  }