Tabnine Logo
QueryOrder
Code IndexAdd Tabnine to your IDE (free)

How to use
QueryOrder
in
io.yawp.repository.query

Best Java code snippets using io.yawp.repository.query.QueryOrder (Showing top 10 results out of 315)

origin: feroult/yawp

@SuppressWarnings({"rawtypes", "unchecked"})
public int compare(Object o1, Object o2) {
  Comparable value1 = getComparable(o1);
  Comparable value2 = getComparable(o2);
  if (value1 == null) {
    if (value2 == null) {
      return 0;
    } else {
      return isAsc() ? -1 : 1;
    }
  } else if (value2 == null) {
    return isAsc() ? 1 : -1;
  }
  int compare = value1.compareTo(value2);
  if (isDesc()) {
    compare *= -1;
  }
  return compare;
}
origin: feroult/yawp

  @Override
  public int compare(Object o1, Object o2) {
    for (QueryOrder order : postOrders) {
      int compare = order.compare(o1, o2);
      if (compare == 0) {
        continue;
      }
      return compare;
    }
    return 0;
  }
});
origin: feroult/yawp

public QueryBuilder<T> order(String property, String direction) {
  preOrders.add(new QueryOrder(null, property, direction));
  return this;
}
origin: feroult/yawp

public SortDirection getSortDirection(QueryOrder order) {
  if (order.isDesc()) {
    return SortDirection.DESCENDING;
  }
  if (order.isAsc()) {
    return SortDirection.ASCENDING;
  }
  throw new RuntimeException("Invalid sort direction");
}
origin: feroult/yawp

private String order() {
  if (CollectionUtils.isEmpty(builder.getPreOrders())) {
    return "";
  }
  Class<?> clazz = builder.getModel().getClazz();
  boolean first = true;
  StringBuilder sb = new StringBuilder();
  sb.append(" order by ");
  for (QueryOrder order : builder.getPreOrders()) {
    if (!first) {
      sb.append(", ");
    } else {
      first = false;
    }
    sb.append(String.format("properties->>'%s'", getActualFieldName(order.getProperty(), clazz)));
    if (order.isDesc()) {
      sb.append(" desc");
    }
  }
  return sb.toString();
}
origin: feroult/yawp

  private void assertOrderEquals(String property, String direction, QueryOrder order) {
    assertEquals(property, order.getProperty());
    assertEquals(direction, order.getDirection());
  }
}
origin: feroult/yawp

private void prepareQueryOrder(QueryBuilder<?> builder, Query q) {
  if (builder.getPreOrders().isEmpty()) {
    return;
  }
  for (QueryOrder order : builder.getPreOrders()) {
    String string = getActualFieldName(order.getProperty(), builder.getModel().getClazz());
    q.addSort(string, getSortDirection(order));
  }
}
origin: feroult/yawp

  @Override
  public int compare(Object o1, Object o2) {
    for (QueryOrder order : preOrders) {
      int compare = order.compare(o1, o2);
      if (compare == 0) {
        continue;
      }
      return compare;
    }
    return 0;
  }
});
origin: feroult/yawp

public QueryBuilder<T> sort(String entity, String property, String direction) {
  postOrders.add(new QueryOrder(entity, property, direction));
  return this;
}
origin: feroult/yawp

private List<QueryOrder> parseOrders(JsonArray jsonArray) {
  if (jsonArray == null) {
    return null;
  }
  List<QueryOrder> orders = new ArrayList<>();
  for (JsonElement jsonElement : jsonArray) {
    String entity = getJsonStringValue(jsonElement, "e");
    String property = getJsonStringValue(jsonElement, "p");
    String direction = getJsonStringValue(jsonElement, "d");
    orders.add(new QueryOrder(entity, property, direction));
  }
  return orders;
}
io.yawp.repository.queryQueryOrder

Most used methods

  • getProperty
  • isDesc
  • compare
  • isAsc
  • <init>
  • getComparable
  • getDirection

Popular in Java

  • Making http requests using okhttp
  • compareTo (BigDecimal)
  • getSharedPreferences (Context)
  • addToBackStack (FragmentTransaction)
  • Point (java.awt)
    A point representing a location in (x,y) coordinate space, specified in integer precision.
  • FileWriter (java.io)
    A specialized Writer that writes to a file in the file system. All write requests made by calling me
  • InputStream (java.io)
    A readable source of bytes.Most clients will use input streams that read data from the file system (
  • Socket (java.net)
    Provides a client-side TCP socket.
  • Calendar (java.util)
    Calendar is an abstract base class for converting between a Date object and a set of integer fields
  • JTextField (javax.swing)
  • Best IntelliJ plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now