@Test public void testParse() { LiteralToken token = new LiteralToken(" some text "); ParseContext context = new ParseContext(" some text here"); token.parse(context); assertEquals(context.getIndex(), 11); }
@Override public void parse(ParseContext context) throws MonetaryParseException { if (!context.consume(token)) { if(token.trim().isEmpty()){ return; } context.setError(); context.setErrorMessage("Parse Error"); throw new MonetaryParseException(context.getOriginalInput(), context.getErrorIndex()); } }
LiteralToken implements FormatToken, Serializable { @Override public void parse(ParseContext context) throws MonetaryParseException { if (!context.consume(token)) { if(token.trim().isEmpty()){ return; } context.setError(); context.setErrorMessage("Parse Error"); throw new MonetaryParseException(context.getOriginalInput(), context.getErrorIndex()); } } }
LiteralToken implements FormatToken, Serializable { @Override public void parse(ParseContext context) throws MonetaryParseException { if (!context.consume(token)) { if(token.trim().isEmpty()){ return; } context.setError(); context.setErrorMessage("Parse Error"); throw new MonetaryParseException(context.getOriginalInput(), context.getErrorIndex()); } } LiteralToken(String token); }
LiteralToken implements FormatToken, Serializable { @Override public void parse(ParseContext context) throws MonetaryParseException { if (!context.consume(token)) { if(token.trim().isEmpty()){ return; } context.setError(); context.setErrorMessage("Parse Error"); throw new MonetaryParseException(context.getOriginalInput(), context.getErrorIndex()); } } LiteralToken(String token); @Override void parse(ParseContext context); @Override void print(Appendable appendable, MonetaryAmount amount); @Override String toString(); }
LiteralToken implements FormatToken, Serializable { @Override public void parse(ParseContext context) throws MonetaryParseException { if (!context.consume(token)) { if(token.trim().isEmpty()){ return; } context.setError(); context.setErrorMessage("Parse Error"); throw new MonetaryParseException(context.getOriginalInput(), context.getErrorIndex()); } } LiteralToken(String token); @Override void parse(ParseContext context); @Override void print(Appendable appendable, MonetaryAmount amount); @Override String toString();  }