/** * Creates a new {@link SortModifier} instance given {@link Direction}. * * @param direction must not be {@literal null}. */ SortModifier(Direction direction) { Assert.notNull(direction, "Direction must not be null!"); this.sort = direction.isAscending() ? 1 : -1; }
/** * Creates a new {@link SortModifier} instance given {@link Direction}. * * @param direction must not be {@literal null}. */ SortModifier(Direction direction) { Assert.notNull(direction, "Direction must not be null!"); this.sort = direction.isAscending() ? 1 : -1; }
private StringBuilder getSortClause(Sort sort) { StringBuilder sortClause = new StringBuilder(); for (Order order : sort) { if (sortClause.length() != 0) { sortClause.append(',').append(' '); } sortClause.append(order.getProperty()).append(' ').append(order.getDirection().isAscending() ? "ASC" : "DESC"); } return sortClause; }
/** * Returns whether sorting for this property shall be ascending. * * @return */ public boolean isAscending() { return this.direction.isAscending(); }
private StringBuilder getSortClause(Sort sort) { StringBuilder sortClause = new StringBuilder(); for (Order order : sort) { if (sortClause.length() != 0) { sortClause.append(',').append(' '); } sortClause.append(order.getProperty()).append(' ').append(order.getDirection().isAscending() ? "ASC" : "DESC"); } return sortClause; }