@Test public void testParseOrderBy() { final MinijaxCriteriaQuery<Widget> query = Parser.parse( em.getCriteriaBuilder(), Widget.class, Tokenizer.tokenize("SELECT w FROM Widget w ORDER BY w.name")); assertNotNull(query); }
private void parseOrderBy() { consume(TokenType.KEYWORD_ORDER); consume(TokenType.KEYWORD_BY); final MinijaxPath<?> path = parsePath(); boolean ascending = true; if (index < tokens.size()) { final Token curr = getCurr(); if (curr.getTokenType() == TokenType.KEYWORD_ASC) { consume(TokenType.KEYWORD_ASC); } else if (curr.getTokenType() == TokenType.KEYWORD_DESC) { consume(TokenType.KEYWORD_DESC); ascending = false; } } query.orderBy(new MinijaxOrder(path, ascending)); }
Parser { private void parseOrderBy() { consume(TokenType.KEYWORD_ORDER); consume(TokenType.KEYWORD_BY); final MinijaxPath<?> path = parsePath(); boolean ascending = true; if (index < tokens.size()) { final Token curr = getCurr(); if (curr.getTokenType() == TokenType.KEYWORD_ASC) { consume(TokenType.KEYWORD_ASC); } else if (curr.getTokenType() == TokenType.KEYWORD_DESC) { consume(TokenType.KEYWORD_DESC); ascending = false; } } query.orderBy(new MinijaxOrder(path, ascending)); } }
Parser { private void parseOrderBy() { consume(TokenType.KEYWORD_ORDER); consume(TokenType.KEYWORD_BY); final MinijaxPath<?> path = parsePath(); boolean ascending = true; if (index < tokens.size()) { final Token curr = getCurr(); if (curr.getTokenType() == TokenType.KEYWORD_ASC) { consume(TokenType.KEYWORD_ASC); } else if (curr.getTokenType() == TokenType.KEYWORD_DESC) { consume(TokenType.KEYWORD_DESC); ascending = false; } } query.orderBy(new MinijaxOrder(path, ascending)); } private  Parser(final MinijaxCriteriaBuilder cb, final Class<T> resultType, final List<Token> tokens); }
Parser { private void parseOrderBy() { consume(TokenType.KEYWORD_ORDER); consume(TokenType.KEYWORD_BY); final MinijaxPath<?> path = parsePath(); boolean ascending = true; if (index < tokens.size()) { final Token curr = getCurr(); if (curr.getTokenType() == TokenType.KEYWORD_ASC) { consume(TokenType.KEYWORD_ASC); } else if (curr.getTokenType() == TokenType.KEYWORD_DESC) { consume(TokenType.KEYWORD_DESC); ascending = false; } } query.orderBy(new MinijaxOrder(path, ascending)); } private  Parser(final MinijaxCriteriaBuilder cb, final Class<T> resultType, final List<Token> tokens); static MinijaxCriteriaQuery<T> parse(final MinijaxCriteriaBuilder cb, final Class<T> resultType, final List<Token> tokens); }
Parser { private void parseOrderBy() { consume(TokenType.KEYWORD_ORDER); consume(TokenType.KEYWORD_BY); final MinijaxPath<?> path = parsePath(); boolean ascending = true; if (index < tokens.size()) { final Token curr = getCurr(); if (curr.getTokenType() == TokenType.KEYWORD_ASC) { consume(TokenType.KEYWORD_ASC); } else if (curr.getTokenType() == TokenType.KEYWORD_DESC) { consume(TokenType.KEYWORD_DESC); ascending = false; } } query.orderBy(new MinijaxOrder(path, ascending)); } private  Parser(final MinijaxCriteriaBuilder cb, final Class<T> resultType, final List<Token> tokens); static MinijaxCriteriaQuery<T> parse(final MinijaxCriteriaBuilder cb, final Class<T> resultType, final List<Token> tokens);  }