Package org.springframework.data.domain.Sort

Examples of org.springframework.data.domain.Sort.Order


        if (!StringUtils.hasText(property)) {
          continue;
        }

        allOrders.add(new Order(direction, property));
      }
    }

    return allOrders.isEmpty() ? null : new Sort(allOrders);
  }
View Full Code Here


   * (non-Javadoc)
   * @see javax.xml.bind.annotation.adapters.XmlAdapter#unmarshal(java.lang.Object)
   */
  @Override
  public Order unmarshal(OrderDto source) {
    return source == null ? null : new Order(source.direction, source.property);
  }
View Full Code Here

   * @see PropertyPath#from(String, Class)
   */
  private Order createOrder(String propertySource, Direction direction, Class<?> domainClass) {

    if (null == domainClass) {
      return new Order(direction, StringUtils.uncapitalize(propertySource));
    }
    PropertyPath propertyPath = PropertyPath.from(propertySource, domainClass);
    return new Order(direction, propertyPath.toDotPath());
  }
View Full Code Here

  @Test
  public void handlesMultipleDirectionsCorrectly() throws Exception {

    OrderBySource orderBySource = new OrderBySource("LastnameAscUsernameDesc");
    assertThat(orderBySource.toSort(), is(new Sort(new Order(ASC, "lastname"), new Order(DESC, "username"))));
  }
View Full Code Here

  @Test
  public void usesNestedPropertyCorrectly() throws Exception {

    OrderBySource source = new OrderBySource("BarNameDesc", Foo.class);
    assertThat(source.toSort(), is(new Sort(new Order(DESC, "bar.name"))));

  }
View Full Code Here

  public ExpectedException exception = ExpectedException.none();

  @Test
  public void parsesSimpleSortStringCorrectly() {

    assertSortStringParsedInto(new Sort(new Order("username")), SORT_1);
    assertSortStringParsedInto(new Sort(new Order(ASC, "username")), SORT_1);
    assertSortStringParsedInto(new Sort(new Order(ASC, "username"), //
        new Order(DESC, "lastname"), new Order(DESC, "firstname")), SORT_2);
    assertSortStringParsedInto(new Sort("firstname", "lastname"), SORT_3);
  }
View Full Code Here

   * @see DATACMNS-281
   * @author Kevin Raymond
   */
  @Test
  public void configuresIgnoreCaseForOrder() {
    assertThat(new Order(Direction.ASC, "foo").ignoreCase().isIgnoreCase(), is(true));
  }
View Full Code Here

   * @see DATACMNS-281
   * @author Kevin Raymond
   */
  @Test
  public void orderDoesNotIgnoreCaseByDefault() {
    assertThat(new Order(Direction.ASC, "foo").isIgnoreCase(), is(false));
  }
View Full Code Here

   * @see DATACMNS-436
   */
  @Test
  public void ordersWithDifferentIgnoreCaseDoNotEqual() {

    Order foo = new Order("foo");
    Order fooIgnoreCase = new Order("foo").ignoreCase();

    assertThat(foo, is(not(fooIgnoreCase)));
    assertThat(foo.hashCode(), is(not(fooIgnoreCase.hashCode())));
  }
View Full Code Here

    QUser user = QUser.user;
    QSort sort = new QSort(user.firstname.asc());

    Sort result = sort.and(new Sort(Direction.ASC, "lastname"));
    assertThat(result, is(Matchers.<Order> iterableWithSize(2)));
    assertThat(result, hasItems(new Order(Direction.ASC, "lastname"), new Order(Direction.ASC, "firstname")));
  }
View Full Code Here

TOP

Related Classes of org.springframework.data.domain.Sort.Order

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.