Tabnine Logo
Sort$Direction
Code IndexAdd Tabnine to your IDE (free)

How to use
Sort$Direction
in
org.springframework.data.domain

Best Java code snippets using org.springframework.data.domain.Sort$Direction (Showing top 20 results out of 423)

origin: org.springframework.data/spring-data-mongodb

public Document getIndexKeys() {
  Document document = new Document();
  for (Entry<String, Direction> entry : fieldSpec.entrySet()) {
    document.put(entry.getKey(), Direction.ASC.equals(entry.getValue()) ? 1 : -1);
  }
  return document;
}
origin: spring-projects/spring-data-jpa

private static String toJpaDirection(Order order) {
  return order.getDirection().name().toLowerCase(Locale.US);
}
origin: org.springframework.data/spring-data-mongodb

/**
 * 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;
}
origin: com.blossom-project/blossom-core-common

for (Order order : pageable.getSort()) {
 SortBuilder sortBuilder = SortBuilders.fieldSort("dto." + order.getProperty())
  .order(SortOrder.valueOf(order.getDirection().name()));
 searchRequest.addSort(sortBuilder);
origin: org.ligoj.bootstrap/bootstrap-business

  && ormProperty.indexOf('(') == -1) {
if (ormProperty.indexOf('.') == -1) {
  sort = Sort.by(new Sort.Order(Direction.valueOf(direction.toUpperCase(Locale.ENGLISH)), ormProperty)
      .ignoreCase());
} else {
  sort = JpaSort.unsafe(Direction.valueOf(direction.toUpperCase(Locale.ENGLISH)),
      "UPPER(" + ormProperty + ")");
sort = JpaSort.unsafe(Direction.valueOf(direction.toUpperCase(Locale.ENGLISH)), ormProperty);
origin: com.mmnaseri.utils/spring-data-mock

final SortDirection direction = order.getDirection().equals(Sort.Direction.ASC) ? SortDirection.ASCENDING : SortDirection.DESCENDING;
final NullHandling nullHandling;
switch (order.getNullHandling()) {
origin: mmnaseri/spring-data-mock

final SortDirection direction = order.getDirection().equals(Sort.Direction.ASC) ? SortDirection.ASCENDING : SortDirection.DESCENDING;
final NullHandling nullHandling;
switch (order.getNullHandling()) {
origin: terasolunaorg/terasoluna-gfw

/**
 * Creates and returns a map of attributes to be used by pagination functionality in displaying the results<br>
 * <p>
 * Pagination functionality supports only a single sort order. If a {@code Sort} instance containing multiple {@code Order}
 * elements is passed as argument, the last {@code Order} element will be applicable
 * </p>
 * @param pageIndex index of page number (page index is start with 0).
 * @param size size of page.
 * @param sort Sort option for queries.
 * @return Map&lt;String, Object&gt; instance of attributes
 */
public static Map<String, Object> createAttributeMap(int pageIndex,
    int size, Sort sort) {
  Map<String, Object> attr = new HashMap<String, Object>(3);
  attr.put(PAGE_ATTR, pageIndex);
  attr.put(SIZE_ATTR, size);
  if (sort != null) {
    Iterator<Order> orders = sort.iterator();
    if (orders.hasNext()) {
      // support only one order
      Order order = orders.next();
      attr.put(SORT_ORDER_PROPERTY_ATTR, order.getProperty());
      attr.put(SORT_ORDER_DIRECTION_ATTR, order.getDirection()
          .toString());
    }
  }
  return attr;
}
origin: apache/servicemix-bundles

if (Direction.DESC.equals(order.getDirection())) {
origin: jpenren/thymeleaf-spring-data-dialect

/**
 * Creates an url to sort data by fieldName
 * 
 * @param context execution context
 * @param fieldName field name to sort
 * @param forcedDir optional, if specified then only this sort direction will be allowed
 * @return sort URL
 */
public static String createSortUrl(final ITemplateContext context, final String fieldName, final Direction forcedDir) {
  // Params can be prefixed to manage multiple pagination on the same page
  final String prefix = getParamPrefix(context);
  final Collection<String> excludedParams = Arrays
      .asList(new String[] { prefix.concat(SORT), prefix.concat(PAGE) });
  final String baseUrl = buildBaseUrl(context, excludedParams);
  final StringBuilder sortParam = new StringBuilder();
  final Page<?> page = findPage(context);
  final Sort sort = page.getSort();
  final boolean hasPreviousOrder = sort != null && sort.getOrderFor(fieldName) != null;
  if (forcedDir != null) {
    sortParam.append(fieldName).append(COMMA).append(forcedDir.toString().toLowerCase());
  } else if (hasPreviousOrder) {
    // Sort parameters exists for this field, modify direction
    Order previousOrder = sort.getOrderFor(fieldName);
    Direction dir = previousOrder.isAscending() ? Direction.DESC : Direction.ASC;
    sortParam.append(fieldName).append(COMMA).append(dir.toString().toLowerCase());
  } else {
    sortParam.append(fieldName);
  }
  return buildUrl(baseUrl, context).append(SORT).append(EQ).append(sortParam).toString();
}
origin: Exrick/x-cloud

  public static Pageable initPage(PageVo page){

    Pageable pageable = null;
    int pageNumber = page.getPageNumber();
    int pageSize = page.getPageSize();
    String sort = page.getSort();
    String order = page.getOrder();

    if(pageNumber<1){
      pageNumber = 1;
    }
    if(pageSize<1){
      pageSize = 10;
    }
    if(StrUtil.isNotBlank(sort)) {
      Sort.Direction d;
      if(StrUtil.isBlank(order)) {
        d = Sort.Direction.DESC;
      }else {
        d = Sort.Direction.valueOf(order.toUpperCase());
      }
      Sort s = new Sort(d,sort);
      pageable = PageRequest.of(pageNumber-1, pageSize,s);
    }else {
      pageable = PageRequest.of(pageNumber-1, pageSize);
    }
    return pageable;
  }
}
origin: org.springframework.data/spring-data-keyvalue

if (Direction.DESC.equals(order.getDirection())) {
origin: spring-projects/spring-data-keyvalue

if (Direction.DESC.equals(order.getDirection())) {
origin: ueboot/ueboot

public Page<T> find(StringQuery stringQuery, Pageable pageable) {
  Assert.notNull(stringQuery, "StringQuery must not be null");
  Sort sort = pageable.getSort();
  if (sort != null) {
    int count = 0;
    Iterator<Sort.Order> it = sort.iterator();
    //自动拼接order by 属性
    while (it.hasNext()) {
      Sort.Order s = it.next();
      String name = s.getProperty();
      String dir = s.getDirection().name();
      if (count == 0) {
        stringQuery.predicate(true)
            .query(" order by " + name + " " + dir);
      } else {
        stringQuery.predicate(true)
            .query(", " + name + " " + dir);
      }
      count++;
    }
  }
  String query = stringQuery.getQuery();
  NamedParams params = stringQuery.getParams();
  return find(query, params, pageable);
}
origin: io.github.jpenren/thymeleaf-spring-data-dialect

/**
 * Creates an url to sort data by fieldName
 * 
 * @param context execution context
 * @param fieldName field name to sort
 * @return sort URL
 */
public static String createSortUrl(final ITemplateContext context, final String fieldName) {
  // Params can be prefixed to manage multiple pagination on the same page
  final String prefix = getParamPrefix(context);
  final Collection<String> excludedParams = Arrays
      .asList(new String[] { prefix.concat(SORT), prefix.concat(PAGE) });
  final String baseUrl = buildBaseUrl(context, excludedParams);
  final StringBuilder sortParam = new StringBuilder();
  final Page<?> page = findPage(context);
  final Sort sort = page.getSort();
  final boolean hasPreviousOrder = sort != null && sort.getOrderFor(fieldName) != null;
  if (hasPreviousOrder) {
    // Sort parameters exists for this field, modify direction
    Order previousOrder = sort.getOrderFor(fieldName);
    Direction dir = previousOrder.isAscending() ? Direction.DESC : Direction.ASC;
    sortParam.append(fieldName).append(COMMA).append(dir.toString().toLowerCase());
  } else {
    sortParam.append(fieldName);
  }
  return buildUrl(baseUrl, context).append(SORT).append(EQ).append(sortParam).toString();
}
origin: michaellavelle/spring-data-dynamodb

protected void applySortIfSpecified(QueryRequest queryRequest, List<String> permittedPropertyNames) {
  if (permittedPropertyNames.size() > 2) {
    throw new UnsupportedOperationException("Can only sort by at most a single global hash and range key");
  }
  if (sort != null) {
    boolean sortAlreadySet = false;
    for (Order order : sort) {
      if (permittedPropertyNames.contains(order.getProperty())) {
        if (sortAlreadySet) {
          throw new UnsupportedOperationException("Sorting by multiple attributes not possible");
        }
        if (queryRequest.getKeyConditions().size() > 1 && !hasIndexHashKeyEqualCondition()) {
          throw new UnsupportedOperationException(
              "Sorting for global index queries with criteria on both hash and range not possible");
        }
        queryRequest.setScanIndexForward(order.getDirection().equals(Direction.ASC));
        sortAlreadySet = true;
      } else {
        throw new UnsupportedOperationException("Sorting only possible by " + permittedPropertyNames
            + " for the criteria specified");
      }
    }
  }
}
origin: OpenWiseSolutions/openhub-framework

/**
 * Creates the {@code GET} sortable query based upon configuration. With this method it is necessary to use
 * URLDecoder#decode(String, String) to decode URL or use {@link #toUrl(URIBuilder)}.
 *
 * <p/>
 * <pre>{@code
 *  createSortPair(new Sort(new Sort.Order(Sort.Direction.DESC, "dateFrom"))) &rarr; sort=name&name,dir=desc
 * }</pre>
 *
 * @param sort the sort instrument
 * @return the list of {@link NameValuePair}
 * @see URLDecoder#decode(String, String)
 * @see #toUrl(URIBuilder)
 */
public static List<NameValuePair> createSortPair(Sort sort) {
  List<NameValuePair> sortableQuery = new LinkedList<>();
  for (Sort.Order order : sort) {
    sortableQuery.add(new BasicNameValuePair("sort", order.getProperty().concat(",")
      .concat(order.getDirection().toString().toLowerCase())));
  }
  return sortableQuery;
}
origin: oasp/oasp4j

@Override
public void serialize(Pageable pageable, JsonGenerator gen, SerializerProvider serializers) throws IOException {
 if (pageable == null) {
  return;
 }
 gen.writeStartObject();
 gen.writeNumberField(PageableJsonDeserializer.PROPERTY_PAGE_NUMBER, pageable.getPageNumber());
 gen.writeNumberField(PageableJsonDeserializer.PROPERTY_PAGE_SIZE, pageable.getPageSize());
 Sort sort = pageable.getSort();
 if (sort != null) {
  gen.writeFieldName(PageableJsonDeserializer.PROPERTY_SORT);
  gen.writeStartArray();
  for (Order order : sort) {
   gen.writeStartObject();
   gen.writeStringField(PageableJsonDeserializer.PROPERTY_PROPERTY, order.getProperty());
   gen.writeStringField(PageableJsonDeserializer.PROPERTY_DIRECTION, order.getDirection().toString());
   gen.writeEndObject();
  }
  gen.writeEndArray();
 }
 gen.writeEndObject();
}
origin: com.github.derjust/spring-data-dynamodb

protected void applySortIfSpecified(QueryRequest queryRequest, List<String> permittedPropertyNames) {
  if (permittedPropertyNames.size() > 2) {
    throw new UnsupportedOperationException("Can only sort by at most a single global hash and range key");
  }
  boolean sortAlreadySet = false;
  for (Order order : sort) {
    if (permittedPropertyNames.contains(order.getProperty())) {
      if (sortAlreadySet) {
        throw new UnsupportedOperationException("Sorting by multiple attributes not possible");
      }
      if (queryRequest.getKeyConditions().size() > 1 && !hasIndexHashKeyEqualCondition()) {
        throw new UnsupportedOperationException(
            "Sorting for global index queries with criteria on both hash and range not possible");
      }
      queryRequest.setScanIndexForward(order.getDirection().equals(Direction.ASC));
      sortAlreadySet = true;
    } else {
      throw new UnsupportedOperationException("Sorting only possible by " + permittedPropertyNames
          + " for the criteria specified and not for " + order.getProperty());
    }
  }
}
origin: m4rciosouza/ponto-inteligente-api

/**
 * Retorna a listagem de lançamentos de um funcionário.
 * 
 * @param funcionarioId
 * @return ResponseEntity<Response<LancamentoDto>>
 */
@GetMapping(value = "/funcionario/{funcionarioId}")
public ResponseEntity<Response<Page<LancamentoDto>>> listarPorFuncionarioId(
    @PathVariable("funcionarioId") Long funcionarioId,
    @RequestParam(value = "pag", defaultValue = "0") int pag,
    @RequestParam(value = "ord", defaultValue = "id") String ord,
    @RequestParam(value = "dir", defaultValue = "DESC") String dir) {
  log.info("Buscando lançamentos por ID do funcionário: {}, página: {}", funcionarioId, pag);
  Response<Page<LancamentoDto>> response = new Response<Page<LancamentoDto>>();
  PageRequest pageRequest = new PageRequest(pag, this.qtdPorPagina, Direction.valueOf(dir), ord);
  Page<Lancamento> lancamentos = this.lancamentoService.buscarPorFuncionarioId(funcionarioId, pageRequest);
  Page<LancamentoDto> lancamentosDto = lancamentos.map(lancamento -> this.converterLancamentoDto(lancamento));
  response.setData(lancamentosDto);
  return ResponseEntity.ok(response);
}
org.springframework.data.domainSort$Direction

Javadoc

Enumeration for sort directions.

Most used methods

  • fromString
    Returns the Direction enum for the given String value.
  • equals
  • name
  • valueOf
  • toString
  • isAscending
  • isDescending
    Returns whether the direction is descending.
  • fromStringOrNull
  • hashCode
  • fromOptionalString
    Returns the Direction enum for the given String or null if it cannot be parsed into an enum value.

Popular in Java

  • Creating JSON documents from java classes using gson
  • getExternalFilesDir (Context)
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • getResourceAsStream (ClassLoader)
  • IOException (java.io)
    Signals a general, I/O-related error. Error details may be specified when calling the constructor, a
  • DateFormat (java.text)
    Formats or parses dates and times.This class provides factories for obtaining instances configured f
  • Collection (java.util)
    Collection is the root of the collection hierarchy. It defines operations on data collections and t
  • StringTokenizer (java.util)
    Breaks a string into tokens; new code should probably use String#split.> // Legacy code: StringTo
  • ThreadPoolExecutor (java.util.concurrent)
    An ExecutorService that executes each submitted task using one of possibly several pooled threads, n
  • Scheduler (org.quartz)
    This is the main interface of a Quartz Scheduler. A Scheduler maintains a registry of org.quartz.Job
  • From CI to AI: The AI layer in your organization
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