@Override public int hashCode() { return hash(); }
/** * Add to the order by by parsing a raw expression. */ public void add(String rawExpression) { parse(rawExpression); }
@Override public OrderBy<T> order() { if (orderBy == null) { orderBy = new OrderBy<>(this, null); } return orderBy; }
private Property parseProperty(String[] pairs) { if (pairs.length == 0) { return null; } ArrayList<String> wordList = new ArrayList<String>(pairs.length); for (int i = 0; i < pairs.length; i++) { if (!isEmptyString(pairs[i])) { wordList.add(pairs[i]); } } if (wordList.isEmpty()) { return null; } if (wordList.size() == 1) { return new Property(wordList.get(0), true); } if (wordList.size() == 2) { boolean asc = isAscending(wordList.get(1)); return new Property(wordList.get(0), asc); } String m = "Expecting a max of 2 words in [" + Arrays.toString(pairs) + "] but got " + wordList.size(); throw new RuntimeException(m); }
private String parseInternal() { OrderBy<?> orderBy = query.getOrderBy(); if (orderBy == null){ return null; } StringBuilder sb = new StringBuilder(); List<Property> properties = orderBy.getProperties(); if (properties.isEmpty()){ // order by clause removed by filterMany() return null; } for (int i = 0; i < properties.size(); i++) { if (i > 0){ sb.append(", "); } Property p = properties.get(i); String expression = parseProperty(p); sb.append(expression); } return sb.toString(); }
@Override public void enterOrderby_property(EQLParser.Orderby_propertyContext ctx) { int childCount = ctx.getChildCount(); String path = child(ctx, 0); boolean asc = true; String nulls = null; String nullsFirstLast = null; if (childCount == 3) { asc = child(ctx, 1).startsWith(ASC); nullsFirstLast = ctx.getChild(2).getChild(1).getText(); nulls = NULLS; } else if (childCount == 2) { String firstChild = child(ctx, 1); if (firstChild.startsWith(NULLS)) { nullsFirstLast = ctx.getChild(1).getChild(1).getText(); nulls = NULLS; } else { asc = firstChild.startsWith(ASC); } } query.orderBy().add(new OrderBy.Property(path, asc, nulls, nullsFirstLast)); }
@Override public DefaultOrmQuery<T> setOrder(OrderBy<T> orderBy) { this.orderBy = orderBy; if (orderBy != null) { orderBy.setQuery(this); } return this; }
private void parse(String orderByClause) { if (orderByClause == null) { return; } String[] chunks = orderByClause.split(","); for (String chunk : chunks) { String[] pairs = chunk.split(" "); Property p = parseProperty(pairs); if (p != null) { list.add(p); } } }
copy.maxRows = maxRows; if (orderBy != null) { copy.orderBy = orderBy.copy();
public OrderBy<T> order() { if (orderBy == null){ orderBy = new OrderBy<T>(this, null); } return orderBy; }
private Property parseProperty(String[] pairs) { if (pairs.length == 0) { return null; } ArrayList<String> wordList = new ArrayList<String>(pairs.length); for (int i = 0; i < pairs.length; i++) { if (!isEmptyString(pairs[i])) { wordList.add(pairs[i]); } } if (wordList.isEmpty()) { return null; } if (wordList.size() == 1) { return new Property(wordList.get(0), true); } if (wordList.size() == 2) { boolean asc = isAscending(wordList.get(1)); return new Property(wordList.get(0), asc); } String m = "Expecting a max of 2 words in [" + Arrays.toString(pairs) + "] but got " + wordList.size(); throw new RuntimeException(m); }
private String parseInternal() { OrderBy<?> orderBy = query.getOrderBy(); if (orderBy == null) { return null; } StringBuilder sb = new StringBuilder(); List<Property> properties = orderBy.getProperties(); if (properties.isEmpty()) { // order by clause removed by filterMany() return null; } for (int i = 0; i < properties.size(); i++) { if (i > 0) { sb.append(", "); } Property p = properties.get(i); String expression = parseProperty(p); sb.append(expression); } return sb.toString(); }
public DefaultOrmQuery<T> setOrder(OrderBy<T> orderBy) { this.orderBy = orderBy; if (orderBy != null){ orderBy.setQuery(this); } return this; }
private void parse(String orderByClause) { if (orderByClause == null) { return; } String[] chunks = orderByClause.split(","); for (int i = 0; i < chunks.length; i++) { String[] pairs = chunks[i].split(" "); Property p = parseProperty(pairs); if (p != null) { list.add(p); } } }
copy.rawWhereClause = rawWhereClause; if (orderBy != null){ copy.orderBy = orderBy.copy();
public OrderBy<T> order() { if (orderBy == null){ orderBy = new OrderBy<T>(this, null); } return orderBy; }
private Property parseProperty(String[] pairs) { if (pairs.length == 0) { return null; } ArrayList<String> wordList = new ArrayList<>(pairs.length); for (String pair : pairs) { if (!isEmptyString(pair)) { wordList.add(pair); } } if (wordList.isEmpty()) { return null; } if (wordList.size() == 1) { return new Property(wordList.get(0), true); } if (wordList.size() == 2) { boolean asc = isAscending(wordList.get(1)); return new Property(wordList.get(0), asc); } if (wordList.size() == 4) { // nulls high or nulls low as 3rd and 4th boolean asc = isAscending(wordList.get(1)); return new Property(wordList.get(0), asc, wordList.get(2), wordList.get(3)); } String m = "Expecting a 1, 2 or 4 words in [" + Arrays.toString(pairs) + "] but got " + wordList; throw new RuntimeException(m); }
private String parseInternal() { OrderBy<?> orderBy = query.getOrderBy(); if (orderBy == null){ return null; } StringBuilder sb = new StringBuilder(); List<Property> properties = orderBy.getProperties(); if (properties.isEmpty()){ // order by clause removed by filterMany() return null; } for (int i = 0; i < properties.size(); i++) { if (i > 0){ sb.append(", "); } Property p = properties.get(i); String expression = parseProperty(p); sb.append(expression); } return sb.toString(); }