-
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.
- Loading branch information
1 parent
7ad8cd7
commit cf0a872
Showing
3 changed files
with
67 additions
and
4 deletions.
There are no files selected for viewing
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
37 changes: 37 additions & 0 deletions
37
src/main/java/fr/ouestfrance/querydsl/service/ext/HasRange.java
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,37 @@ | ||
package fr.ouestfrance.querydsl.service.ext; | ||
|
||
/** | ||
* Interface for range values | ||
* | ||
* @param <T> the type of the range (like localDate, String, integers, ...) | ||
*/ | ||
public interface HasRange<T> { | ||
|
||
/** | ||
* Get the lower bound of the range | ||
* | ||
* @return the lower bound or null if unbounded | ||
*/ | ||
T getLower(); | ||
|
||
/** | ||
* Get the upper bound of the range | ||
* | ||
* @return the upper bound or null if unbounded | ||
*/ | ||
T getUpper(); | ||
|
||
/** | ||
* Check if the lower bound is inclusive | ||
* | ||
* @return true if the lower bound is inclusive | ||
*/ | ||
boolean isLowerInclusive(); | ||
|
||
/** | ||
* Check if the upper bound is inclusive | ||
* | ||
* @return true if the upper bound is inclusive | ||
*/ | ||
boolean isUpperInclusive(); | ||
} |
21 changes: 21 additions & 0 deletions
21
src/main/java/fr/ouestfrance/querydsl/service/validators/impl/HasRangeValidator.java
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,21 @@ | ||
package fr.ouestfrance.querydsl.service.validators.impl; | ||
|
||
import fr.ouestfrance.querydsl.service.ext.HasRange; | ||
import fr.ouestfrance.querydsl.service.validators.FilterFieldValidator; | ||
import lombok.NoArgsConstructor; | ||
|
||
/** | ||
* Validator that handle filter on HasRange | ||
*/ | ||
@NoArgsConstructor | ||
public class HasRangeValidator implements FilterFieldValidator { | ||
@Override | ||
public boolean validate(Class<?> clazz) { | ||
return HasRange.class.isAssignableFrom(clazz); | ||
} | ||
|
||
@Override | ||
public String message() { | ||
return "should be applied to HasRange"; | ||
} | ||
} |