1
- package org .baeldung .persistence .dao .rsql ;
1
+ package com .baeldung .persistence .dao .rsql ;
2
2
3
3
import java .util .List ;
4
4
import java .util .Objects ;
5
5
import java .util .stream .Collectors ;
6
6
7
- import org .springframework .data .jpa .domain .Specifications ;
7
+ import org .springframework .data .jpa .domain .Specification ;
8
8
9
9
import cz .jirutka .rsql .parser .ast .ComparisonNode ;
10
10
import cz .jirutka .rsql .parser .ast .LogicalNode ;
13
13
14
14
public class GenericRsqlSpecBuilder <T > {
15
15
16
- public Specifications <T > createSpecification (final Node node ) {
16
+ public Specification <T > createSpecification (final Node node ) {
17
17
if (node instanceof LogicalNode ) {
18
18
return createSpecification ((LogicalNode ) node );
19
19
}
@@ -23,31 +23,31 @@ public Specifications<T> createSpecification(final Node node) {
23
23
return null ;
24
24
}
25
25
26
- public Specifications <T > createSpecification (final LogicalNode logicalNode ) {
26
+ public Specification <T > createSpecification (final LogicalNode logicalNode ) {
27
27
28
- List <Specifications <T >> specs = logicalNode .getChildren ()
28
+ List <Specification <T >> specs = logicalNode .getChildren ()
29
29
.stream ()
30
30
.map (node -> createSpecification (node ))
31
31
.filter (Objects ::nonNull )
32
32
.collect (Collectors .toList ());
33
33
34
- Specifications <T > result = specs .get (0 );
34
+ Specification <T > result = specs .get (0 );
35
35
if (logicalNode .getOperator () == LogicalOperator .AND ) {
36
36
for (int i = 1 ; i < specs .size (); i ++) {
37
- result = Specifications .where (result ).and (specs .get (i ));
37
+ result = Specification .where (result ).and (specs .get (i ));
38
38
}
39
39
}
40
40
else if (logicalNode .getOperator () == LogicalOperator .OR ) {
41
41
for (int i = 1 ; i < specs .size (); i ++) {
42
- result = Specifications .where (result ).or (specs .get (i ));
42
+ result = Specification .where (result ).or (specs .get (i ));
43
43
}
44
44
}
45
45
46
46
return result ;
47
47
}
48
48
49
- public Specifications <T > createSpecification (final ComparisonNode comparisonNode ) {
50
- return Specifications .where (new GenericRsqlSpecification <T >(comparisonNode .getSelector (), comparisonNode .getOperator (), comparisonNode .getArguments ()));
49
+ public Specification <T > createSpecification (final ComparisonNode comparisonNode ) {
50
+ return Specification .where (new GenericRsqlSpecification <T >(comparisonNode .getSelector (), comparisonNode .getOperator (), comparisonNode .getArguments ()));
51
51
}
52
52
53
53
}
0 commit comments