From 7d496978f555010f6938eef8c9ae53abade9cddf Mon Sep 17 00:00:00 2001 From: Mark Paluch Date: Thu, 11 May 2017 09:19:06 +0200 Subject: [PATCH] DATACMNS-1058 - Polishing. Improve Javadoc. Extend year range in license header. Original pull request: #214. --- .../data/domain/PageRequest.java | 54 +++++++++++++------ .../repository/query/RepositoryQuery.java | 13 +++-- 2 files changed, 44 insertions(+), 23 deletions(-) diff --git a/src/main/java/org/springframework/data/domain/PageRequest.java b/src/main/java/org/springframework/data/domain/PageRequest.java index 895660ef0..3d3b42973 100644 --- a/src/main/java/org/springframework/data/domain/PageRequest.java +++ b/src/main/java/org/springframework/data/domain/PageRequest.java @@ -1,5 +1,5 @@ /* - * Copyright 2008-2014 the original author or authors. + * Copyright 2008-2017 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,13 +15,11 @@ */ package org.springframework.data.domain; -import java.util.Optional; - import org.springframework.data.domain.Sort.Direction; /** * Basic Java Bean implementation of {@code Pageable}. - * + * * @author Oliver Gierke * @author Thomas Darimont */ @@ -34,7 +32,7 @@ public class PageRequest extends AbstractPageRequest { /** * Creates a new {@link PageRequest}. Pages are zero indexed, thus providing 0 for {@code page} will return the first * page. - * + * * @param page zero-based page index. * @param size the size of the page to be returned. * @deprecated use {@link #of(int, int)} instead. @@ -46,7 +44,7 @@ public class PageRequest extends AbstractPageRequest { /** * Creates a new {@link PageRequest} with sort parameters applied. - * + * * @param page zero-based page index. * @param size the size of the page to be returned. * @param direction the direction of the {@link Sort} to be specified, can be {@literal null}. @@ -60,11 +58,11 @@ public class PageRequest extends AbstractPageRequest { /** * Creates a new {@link PageRequest} with sort parameters applied. - * + * * @param page zero-based page index. * @param size the size of the page to be returned. * @param sort can be {@literal null}. - * @deprecated use {@link #of(int, int, Optional)} instead. + * @deprecated since 2.0, use {@link #of(int, int, Sort)} instead. */ @Deprecated public PageRequest(int page, int size, Sort sort) { @@ -74,14 +72,38 @@ public class PageRequest extends AbstractPageRequest { this.sort = sort; } - public static PageRequest of(int page, int site) { - return of(page, site, Sort.unsorted()); + /** + * Creates a new unsorted {@link PageRequest}. + * + * @param page zero-based page index. + * @param size the size of the page to be returned. + * @since 2.0 + */ + public static PageRequest of(int page, int size) { + return of(page, size, Sort.unsorted()); } - public static PageRequest of(int page, int site, Sort sort) { - return new PageRequest(page, site, sort); + /** + * Creates a new {@link PageRequest} with sort parameters applied. + * + * @param page zero-based page index. + * @param size the size of the page to be returned. + * @param sort must not be {@literal null}. + * @since 2.0 + */ + public static PageRequest of(int page, int size, Sort sort) { + return new PageRequest(page, size, sort); } + /** + * Creates a new {@link PageRequest} with sort direction and properties applied. + * + * @param page zero-based page index. + * @param size the size of the page to be returned. + * @param direction must not be {@literal null}. + * @param properties must not be {@literal null}. + * @since 2.0 + */ public static PageRequest of(int page, int size, Direction direction, String... properties) { return of(page, size, Sort.by(direction, properties)); } @@ -94,7 +116,7 @@ public class PageRequest extends AbstractPageRequest { return sort; } - /* + /* * (non-Javadoc) * @see org.springframework.data.domain.Pageable#next() */ @@ -102,7 +124,7 @@ public class PageRequest extends AbstractPageRequest { return new PageRequest(getPageNumber() + 1, getPageSize(), getSort()); } - /* + /* * (non-Javadoc) * @see org.springframework.data.domain.AbstractPageRequest#previous() */ @@ -110,7 +132,7 @@ public class PageRequest extends AbstractPageRequest { return getPageNumber() == 0 ? this : new PageRequest(getPageNumber() - 1, getPageSize(), getSort()); } - /* + /* * (non-Javadoc) * @see org.springframework.data.domain.Pageable#first() */ @@ -147,7 +169,7 @@ public class PageRequest extends AbstractPageRequest { return 31 * super.hashCode() + sort.hashCode(); } - /* + /* * (non-Javadoc) * @see java.lang.Object#toString() */ diff --git a/src/main/java/org/springframework/data/repository/query/RepositoryQuery.java b/src/main/java/org/springframework/data/repository/query/RepositoryQuery.java index 33d5d208d..649acfda1 100644 --- a/src/main/java/org/springframework/data/repository/query/RepositoryQuery.java +++ b/src/main/java/org/springframework/data/repository/query/RepositoryQuery.java @@ -17,24 +17,23 @@ package org.springframework.data.repository.query; /** * Interface for a query abstraction. - * + * * @author Oliver Gierke */ public interface RepositoryQuery { /** * Executes the {@link RepositoryQuery} with the given parameters. - * - * @param store + * * @param parameters * @return */ - public Object execute(Object[] parameters); + Object execute(Object[] parameters); /** * Returns the - * + * * @return */ - public QueryMethod getQueryMethod(); -} \ No newline at end of file + QueryMethod getQueryMethod(); +}