-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Upgrade Kotlin version to the latest.
- Cleanup the OffsetBasedPageRequest class. - Add .editorconfig. - Use let more.
- Loading branch information
Showing
13 changed files
with
1,291 additions
and
160 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,4 +23,4 @@ class VkConfig ( | |
|
||
@Value("\${vk.apiVersion}") | ||
val apiVersion: String | ||
): Oauth2Config | ||
): Oauth2Config |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
114 changes: 0 additions & 114 deletions
114
src/main/kotlin/org/motivepick/service/OffsetBasedPageRequest.kt
This file was deleted.
Oops, something went wrong.
45 changes: 45 additions & 0 deletions
45
src/main/kotlin/org/motivepick/service/OffsetBasedPageable.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package org.motivepick.service | ||
|
||
import org.springframework.data.domain.Pageable | ||
import org.springframework.data.domain.Sort | ||
|
||
@Suppress("DataClassPrivateConstructor") // Kotlin issue, will be fixed, see KT-11914 | ||
internal data class OffsetBasedPageable private constructor(private val offset: Long, private val limit: Int, private val sort: Sort) : Pageable { | ||
|
||
companion object { | ||
|
||
/** | ||
* Creates a new unsorted [OffsetBasedPageable]. | ||
* | ||
* @param offset zero-based offset. | ||
* @param limit the size of the elements to be returned. | ||
*/ | ||
operator fun invoke(offset: Long, limit: Int): OffsetBasedPageable { | ||
require(offset >= 0) { "Offset must not be less than zero" } | ||
require(limit >= 1) { "Limit must not be less than one" } | ||
return OffsetBasedPageable(offset, limit, Sort.unsorted()) | ||
} | ||
} | ||
|
||
override fun getPageNumber(): Int = (offset / limit).toInt() | ||
|
||
override fun getPageSize(): Int = limit | ||
|
||
override fun getOffset(): Long = offset | ||
|
||
override fun getSort(): Sort = sort | ||
|
||
override fun next(): Pageable = | ||
OffsetBasedPageable(getOffset() + pageSize, pageSize, getSort()) | ||
|
||
override fun previousOrFirst(): Pageable = | ||
if (hasPrevious()) OffsetBasedPageable(getOffset() - pageSize, pageSize, getSort()) else first() | ||
|
||
override fun first(): Pageable = | ||
OffsetBasedPageable(0, pageSize, getSort()) | ||
|
||
override fun withPage(pageNumber: Int): Pageable = | ||
OffsetBasedPageable(getOffset() + pageNumber * pageSize, pageSize, getSort()) | ||
|
||
override fun hasPrevious(): Boolean = offset > limit | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters