/**
  * Removes a single sort field from the current sort information.
  *
  * @return the modified SolrQuery object, for easy chaining
  * @since 4.2
  */
 public SolrQuery removeSort(String itemName) {
   if (sortClauses != null) {
     for (SortClause existing : sortClauses) {
       if (existing.getItem().equals(itemName)) {
         sortClauses.remove(existing);
         if (sortClauses.isEmpty()) sortClauses = null;
         serializeSorts();
         break;
       }
     }
   }
   return this;
 }
 /**
  * Updates or adds a single sort field specification to the current sort information. If the sort
  * field already exist in the sort information map, it's position is unchanged and the sort order
  * is set; if it does not exist, it is appended at the end with the specified order..
  *
  * @return the modified SolrQuery object, for easy chaining
  * @since 4.2
  */
 public SolrQuery addOrUpdateSort(SortClause sortClause) {
   if (sortClauses != null) {
     for (int index = 0; index < sortClauses.size(); index++) {
       SortClause existing = sortClauses.get(index);
       if (existing.getItem().equals(sortClause.getItem())) {
         sortClauses.set(index, sortClause);
         serializeSorts();
         return this;
       }
     }
   }
   return addSort(sortClause);
 }
 private void serializeSorts() {
   if (sortClauses == null || sortClauses.isEmpty()) {
     remove(CommonParams.SORT);
   } else {
     StringBuilder sb = new StringBuilder();
     for (SortClause sortClause : sortClauses) {
       if (sb.length() > 0) sb.append(",");
       sb.append(sortClause.getItem());
       sb.append(" ");
       sb.append(sortClause.getOrder());
     }
     set(CommonParams.SORT, sb.toString());
   }
 }
 /**
  * Removes a single sort field from the current sort information.
  *
  * @return the modified SolrQuery object, for easy chaining
  * @since 4.2
  */
 public SolrQuery removeSort(SortClause sortClause) {
   return removeSort(sortClause.getItem());
 }
 public boolean equals(Object other) {
   if (this == other) return true;
   if (!(other instanceof SortClause)) return false;
   final SortClause that = (SortClause) other;
   return this.getItem().equals(that.getItem()) && this.getOrder().equals(that.getOrder());
 }