Skip to content

Commit

Permalink
[Wen Hao] - using guava Range class instead of Spring Data JPA Range …
Browse files Browse the repository at this point in the history
…class.
  • Loading branch information
wenhao committed Mar 19, 2018
1 parent fdfa684 commit e82a84a
Show file tree
Hide file tree
Showing 12 changed files with 901 additions and 70 deletions.
28 changes: 17 additions & 11 deletions README.md
Expand Up @@ -21,6 +21,8 @@ English Version:

[Latest]

[3.2.2]

[3.2.1]

[3.1.0]
Expand All @@ -31,6 +33,8 @@ Chinese Version:

[最新]

[3.2.2_cn]

[3.2.1_cn]

[3.1.0_cn]
Expand All @@ -45,7 +49,7 @@ repositories {
}
dependencies {
compile 'com.github.wenhao:jpa-spec:3.2.1'
compile 'com.github.wenhao:jpa-spec:3.2.2'
}
```

Expand All @@ -55,7 +59,7 @@ dependencies {
<dependency>
<groupId>com.github.wenhao</groupId>
<artifactId>jpa-spec</artifactId>
<version>3.2.1</version>
<version>3.2.2</version>
</dependency>
```

Expand All @@ -81,7 +85,7 @@ public Page<Person> findAll(SearchRequest request) {
Specification<Person> specification = Specifications.<Person>and()
.eq(StringUtils.isNotBlank(request.getName()), "name", request.getName())
.gt(Objects.nonNull(request.getAge()), "age", 18)
.between("birthday", Range.of(inclusive(new Date()), inclusive(new Date())))
.between("birthday", Range.closed(new Date(), new Date()))
.like("nickName", "%og%", "%me")
.build();

Expand Down Expand Up @@ -150,8 +154,8 @@ find any person age between 18 and 25, birthday between someday and someday.
```java
public List<Person> findAll(SearchRequest request) {
Specification<Person> specification = Specifications.<Person>and()
.between(Objects.nonNull(request.getAge(), "age", Range.of(inclusive(18), inclusive(25)))
.between("birthday", Range.of(inclusive(new Date()), inclusive(new Date())))
.between(Objects.nonNull(request.getAge(), "age", Range.closed(18, 25))
.between("birthday", Range.closed(new Date(), new Date()))
.build();

return personRepository.findAll(specification);
Expand Down Expand Up @@ -236,7 +240,7 @@ public List<Phone> findAll(SearchRequest request) {
```java
public List<Phone> findAll(SearchRequest request) {
Specification<Person> specification = Specifications.<Person>and()
.between("age", Range.of(inclusive(10), inclusive(35)))
.between("age", Range.closed(10, 35))
.eq(StringUtils.isNotBlank(jack.getName()), "addresses.street", "Chengdu")
.build();

Expand Down Expand Up @@ -273,7 +277,7 @@ public List<Phone> findAll(SearchRequest request) {
```java
public List<Phone> findAll(SearchRequest request) {
Specification<Person> specification = Specifications.<Person>and()
.between("age", Range.of(inclusive(10), inclusive(35)))
.between("age", Range.closed(10, 35))
.predicate(StringUtils.isNotBlank(jack.getName()), ((root, query, cb) -> {
Join address = root.join("addresses", JoinType.LEFT);
return cb.equal(address.get("street"), "Chengdu");
Expand All @@ -293,7 +297,7 @@ public List<Person> findAll(SearchRequest request) {
Specification<Person> specification = Specifications.<Person>and()
.eq(StringUtils.isNotBlank(request.getName()), "name", request.getName())
.gt("age", 18)
.between("birthday", Range.of(inclusive(new Date()), inclusive(new Date())))
.between("birthday", Range.closed(new Date(), new Date()))
.like("nickName", "%og%")
.build();

Expand All @@ -315,7 +319,7 @@ public Page<Person> findAll(SearchRequest request) {
Specification<Person> specification = Specifications.<Person>and()
.eq(StringUtils.isNotBlank(request.getName()), "name", request.getName())
.gt("age", 18)
.between("birthday", Range.of(inclusive(new Date()), inclusive(new Date())))
.between("birthday", Range.closed(new Date(), new Date()))
.like("nickName", "%og%")
.build();

Expand Down Expand Up @@ -379,11 +383,13 @@ Copyright © 2016-2018 Wen Hao
Licensed under [Apache License]


[Latest]: ./docs/3.2.1.md
[Latest]: ./docs/3.2.2.md
[3.2.2]: ./docs/3.2.2.md
[3.2.1]: ./docs/3.2.1.md
[3.1.0]: ./docs/3.1.0.md
[3.0.0]: ./docs/3.0.0.md
[最新]: ./docs/3.2.1_cn.md
[最新]: ./docs/3.2.2_cn.md
[3.2.2_cn]: ./docs/3.2.2_cn.md
[3.2.1_cn]: ./docs/3.2.1_cn.md
[3.1.0_cn]: ./docs/3.1.0_cn.md
[3.0.0_cn]: ./docs/3.0.0_cn.md
Expand Down
20 changes: 10 additions & 10 deletions README_CN.md
Expand Up @@ -39,7 +39,7 @@ repositories {
}
dependencies {
compile 'com.github.wenhao:jpa-spec:3.2.1'
compile 'com.github.wenhao:jpa-spec:3.2.2'
}
```

Expand All @@ -49,7 +49,7 @@ dependencies {
<dependency>
<groupId>com.github.wenhao</groupId>
<artifactId>jpa-spec</artifactId>
<version>3.2.1</version>
<version>3.2.2</version>
</dependency>
```

Expand All @@ -59,7 +59,7 @@ dependencies {
<dependency>
<groupId>com.github.wenhao</groupId>
<artifactId>jpa-spec</artifactId>
<version>3.2.1</version>
<version>3.2.2</version>
<exclusions>
<exclusion>
<groupId>org.hibernate.javax.persistence</groupId>
Expand Down Expand Up @@ -116,7 +116,7 @@ public Page<Person> findAll(SearchRequest request) {
Specification<Person> specification = Specifications.<Person>and()
.eq(StringUtils.isNotBlank(request.getName()), "name", request.getName())
.gt(Objects.nonNull(request.getAge()), "age", 18)
.between("birthday", Range.of(inclusive(new Date()), inclusive(new Date())))
.between("birthday", Range.closed(new Date(), new Date()))
.like("nickName", "%og%", "%me")
.build();

Expand Down Expand Up @@ -212,8 +212,8 @@ find any person age between 18 and 25, birthday between someday and someday.
```java
public List<Person> findAll(SearchRequest request) {
Specification<Person> specification = Specifications.<Person>and()
.between(Objects.nonNull(request.getAge(), "age", Range.of(inclusive(18), inclusive(25)))
.between("birthday", Range.of(inclusive(new Date()), inclusive(new Date())))
.between(Objects.nonNull(request.getAge(), "age", Range.closed(18, 25))
.between("birthday", Range.closed(new Date(), new Date()))
.build();

return personRepository.findAll(specification);
Expand Down Expand Up @@ -330,7 +330,7 @@ public List<Phone> findAll(SearchRequest request) {
```java
public List<Phone> findAll(SearchRequest request) {
Specification<Person> specification = Specifications.<Person>and()
.between("age", Range.of(inclusive(10), inclusive(35)))
.between("age", Range.closed(10, 35))
.eq(StringUtils.isNotBlank(jack.getName()), "addresses.street", "Chengdu")
.build();

Expand Down Expand Up @@ -379,7 +379,7 @@ public List<Phone> findAll(SearchRequest request) {
```java
public List<Phone> findAll(SearchRequest request) {
Specification<Person> specification = Specifications.<Person>and()
.between("age", Range.of(inclusive(10), inclusive(35)))
.between("age", Range.closed(10, 35))
.predicate(StringUtils.isNotBlank(jack.getName()), ((root, query, cb) -> {
Join address = root.join("addresses", JoinType.LEFT);
return cb.equal(address.get("street"), "Chengdu");
Expand All @@ -402,7 +402,7 @@ public List<Person> findAll(SearchRequest request) {
Specification<Person> specification = Specifications.<Person>and()
.eq(StringUtils.isNotBlank(request.getName()), "name", request.getName())
.gt("age", 18)
.between("birthday", Range.of(inclusive(new Date()), inclusive(new Date())))
.between("birthday", Range.closed(new Date(), new Date()))
.like("nickName", "%og%")
.build();

Expand Down Expand Up @@ -430,7 +430,7 @@ public Page<Person> findAll(SearchRequest request) {
Specification<Person> specification = Specifications.<Person>and()
.eq(StringUtils.isNotBlank(request.getName()), "name", request.getName())
.gt("age", 18)
.between("birthday", Range.of(inclusive(new Date()), inclusive(new Date())))
.between("birthday", Range.closed(new Date(), new Date()))
.like("nickName", "%og%")
.build();

Expand Down
11 changes: 6 additions & 5 deletions build.gradle
Expand Up @@ -23,7 +23,7 @@ repositories {
}

group = 'com.github.wenhao'
version = '3.2.1'
version = '3.2.2'

idea {
project {
Expand All @@ -45,6 +45,7 @@ compileTestJava(compatibility)
dependencies {
compile("org.springframework.data:spring-data-jpa:$springDataJpaVersion")
compile("org.hibernate.javax.persistence:hibernate-jpa-2.1-api:$jpaVersion")
compile("com.google.guava:guava:$guavaVersion")

testCompile("org.springframework.boot:spring-boot-starter-data-jpa:$springBootVersion")
testCompile("org.springframework.boot:spring-boot-starter-test:$springBootVersion")
Expand Down Expand Up @@ -119,7 +120,7 @@ publishing {
artifact javadocJar
groupId 'com.github.wenhao'
artifactId 'jpa-spec'
version '3.2.1'
version '3.2.2'
pom.withXml {
def root = asNode()
root.appendNode('description', 'A JAP Query By Specification framework.')
Expand Down Expand Up @@ -154,10 +155,10 @@ bintray {
githubRepo = 'wenhao/jpa-spec'
githubReleaseNotesFile = 'README.md'
version {
name = '3.2.1'
desc = 'A JAP Query By Specification framework 3.2.1'
name = '3.2.2'
desc = 'A JAP Query By Specification framework 3.2.2'
released = new Date()
vcsTag = '3.2.1'
vcsTag = '3.2.2'
gpg {
sign = true
passphrase = 'passphrase'
Expand Down

0 comments on commit e82a84a

Please sign in to comment.