1+ /*
2+ *
3+ * Copyright 2017-2018 the original author or authors.
4+ *
5+ * Licensed under the Apache License, Version 2.0 (the "License");
6+ * you may not use this file except in compliance with the License.
7+ * You may obtain a copy of the License at
8+ *
9+ * http://www.apache.org/licenses/LICENSE-2.0
10+ *
11+ * Unless required by applicable law or agreed to in writing, software
12+ * distributed under the License is distributed on an "AS IS" BASIS,
13+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+ * See the License for the specific language governing permissions and
15+ * limitations under the License.
16+ *
17+ *
18+ */
19+ package springfox .documentation .spring .web .dummy .models ;
20+
21+ import com .fasterxml .jackson .annotation .JsonIgnore ;
22+ import springfox .documentation .spring .web .dummy .controllers .SortDirection ;
23+
24+ import javax .validation .constraints .Max ;
25+ import javax .validation .constraints .Min ;
26+ import javax .validation .constraints .NotNull ;
27+ import java .util .HashMap ;
28+ import java .util .Map ;
29+
30+ public class Bug1749 {
31+ @ NotNull
32+ @ Min (value = 1 , message = "must be > 1" )
33+ private Integer pageNumber = 1 ;
34+ @ NotNull
35+ @ Max (value = 50 , message = "must be < 50" )
36+ private Integer pageSize = 20 ;
37+ private SortDirection sortDirection ;
38+ private String sortField ;
39+
40+ public Bug1749 (int pageNumber , int pageSize ) {
41+ this .pageNumber = pageNumber ;
42+ this .pageSize = pageSize ;
43+ }
44+
45+ public Bug1749 (int pageNumber , int pageSize , String sortField ) {
46+ this (pageNumber , pageSize );
47+ this .sortField = sortField ;
48+ }
49+
50+ public Bug1749 (int pageNumber , int pageSize , String sortField , SortDirection sortDirection ) {
51+ this (pageNumber , pageSize , sortField );
52+ this .sortDirection = sortDirection ;
53+ }
54+
55+ public Map <String , String > toMap () {
56+ Map <String , String > map = new HashMap <String , String >();
57+ map .put ("pageNumber" , Integer .toString (pageNumber ));
58+ map .put ("pageSize" , Integer .toString (pageSize ));
59+ if (sortDirection != null ) {
60+ map .put ("sortDirection" , sortDirection .toString ());
61+ }
62+ if (sortField != null ) {
63+ map .put ("sortField" , sortField );
64+ }
65+ return map ;
66+ }
67+
68+ // region Auto-generated code
69+ public Bug1749 () {
70+ }
71+
72+ @ JsonIgnore
73+ public boolean isAscending () {
74+ return sortDirection == SortDirection .ASC ;
75+ }
76+
77+ @ JsonIgnore
78+ public boolean isSet () {
79+ return pageNumber != null && pageSize != null ;
80+ }
81+
82+ public Bug1749 setSort (String field , SortDirection direction ) {
83+ this .sortField = field ;
84+ this .sortDirection = direction ;
85+ return this ;
86+ }
87+
88+ public Integer getPageNumber () {
89+ return pageNumber ;
90+ }
91+
92+ public void setPageNumber (Integer pageNumber ) {
93+ this .pageNumber = pageNumber ;
94+ }
95+
96+ public Integer getPageSize () {
97+ return pageSize ;
98+ }
99+
100+ public void setPageSize (Integer pageSize ) {
101+ this .pageSize = pageSize ;
102+ }
103+
104+ public SortDirection getSortDirection () {
105+ return sortDirection ;
106+ }
107+
108+ public void setSortDirection (SortDirection sortDirection ) {
109+ this .sortDirection = sortDirection ;
110+ }
111+
112+ public String getSortField () {
113+ return sortField ;
114+ }
115+
116+ public void setSortField (String sortField ) {
117+ this .sortField = sortField ;
118+ }
119+ // endregion
120+ }
0 commit comments