/** * Return a copy of this Property with the path trimmed. */ public Property copyWithTrim(String path) { return new Property(property.substring(path.length() + 1), ascending, collation, nulls, highLow); }
/** * Add a property with ascending order to this OrderBy. */ public Query<T> asc(String propertyName) { list.add(new Property(propertyName, true)); return query; }
/** * Add a property with ascending order to this OrderBy. */ public Query<T> asc(String propertyName, String collation) { list.add(new Property(propertyName, true, collation)); return query; }
private Property parseProperty(String chunk) { String[] pairs = chunk.split(" "); 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)); } return new Property(chunk.trim(), true); }
private static Property parseOrderProperty(String[] pairs) { if (pairs.length == 0) { return null; } ArrayList<String> wordList = Lists.newArrayListWithCapacity(pairs.length); for (String pair : pairs) { if (StringUtils.isNotBlank(pair)) { wordList.add(pair); } } if (wordList.isEmpty()) { return null; } String field = wordList.get(0); if (wordList.size() == 1) { if (field.startsWith("-")) { return new Property(field.substring(1), false); } else { return new Property(field, true); } } if (wordList.size() == 2) { boolean asc = isOrderAscending(wordList.get(1)); return new Property(field, asc); } throw new UnprocessableEntityException( Messages.get("info.query.orderby1.unprocessable.entity", Arrays.toString(pairs), wordList.size()) ); }
@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)); }
/** * Return a copy of this property. */ public Property copy() { return new Property(property, ascending, collation, nulls, highLow); }
/** * Add a property with ascending order to this OrderBy. */ public Query<T> asc(String propertyName, String collation) { list.add(new Property(propertyName, true, collation)); return query; }
/** * Add a property with ascending order to this OrderBy. */ public Query<T> asc(String propertyName) { list.add(new Property(propertyName, true)); return query; }
/** * Add a property with descending order to this OrderBy. */ public Query<T> desc(String propertyName) { list.add(new Property(propertyName, false)); return query; }
/** * Return a copy of this Property with the path trimmed. */ public Property copyWithTrim(String path) { return new Property(property.substring(path.length() + 1), ascending, collation, nulls, highLow); }
/** * Add a property with descending order to this OrderBy. */ public Query<T> desc(String propertyName, String collation) { list.add(new Property(propertyName, false, collation)); return query; }
private Property parseProperty(String chunk) { String[] pairs = chunk.split(" "); 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)); } return new Property(chunk.trim(), true); }
@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)); }
/** * Return a copy of this property. */ public Property copy() { return new Property(property, ascending, collation, nulls, highLow); }
/** * Add a property with descending order to this OrderBy. */ public Query<T> desc(String propertyName, String collation) { list.add(new Property(propertyName, false, collation)); return query; }
/** * Add a property with descending order to this OrderBy. */ public Query<T> desc(String propertyName) { list.add(new Property(propertyName, false)); return query; }