1 /*
2  * Copyright 2017-2020 the original author or authors.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      https://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package org.springframework.data.domain;
17
18 /**
19  * {@link Pageable} implementation to represent the absence of pagination information.
20  *
21  * @author Oliver Gierke
22  */

23 enum Unpaged implements Pageable {
24
25     INSTANCE;
26
27     /*
28      * (non-Javadoc)
29      * @see org.springframework.data.domain.Pageable#isPaged()
30      */

31     @Override
32     public boolean isPaged() {
33         return false;
34     }
35
36     /*
37      * (non-Javadoc)
38      * @see org.springframework.data.domain.Pageable#previousOrFirst()
39      */

40     @Override
41     public Pageable previousOrFirst() {
42         return this;
43     }
44
45     /*
46      * (non-Javadoc)
47      * @see org.springframework.data.domain.Pageable#next()
48      */

49     @Override
50     public Pageable next() {
51         return this;
52     }
53
54     /*
55      * (non-Javadoc)
56      * @see org.springframework.data.domain.Pageable#hasPrevious()
57      */

58     @Override
59     public boolean hasPrevious() {
60         return false;
61     }
62
63     /*
64      * (non-Javadoc)
65      * @see org.springframework.data.domain.Pageable#getSort()
66      */

67     @Override
68     public Sort getSort() {
69         return Sort.unsorted();
70     }
71
72     /*
73      * (non-Javadoc)
74      * @see org.springframework.data.domain.Pageable#getPageSize()
75      */

76     @Override
77     public int getPageSize() {
78         throw new UnsupportedOperationException();
79     }
80
81     /*
82      * (non-Javadoc)
83      * @see org.springframework.data.domain.Pageable#getPageNumber()
84      */

85     @Override
86     public int getPageNumber() {
87         throw new UnsupportedOperationException();
88     }
89
90     /*
91      * (non-Javadoc)
92      * @see org.springframework.data.domain.Pageable#getOffset()
93      */

94     @Override
95     public long getOffset() {
96         throw new UnsupportedOperationException();
97     }
98
99     /*
100      * (non-Javadoc)
101      * @see org.springframework.data.domain.Pageable#first()
102      */

103     @Override
104     public Pageable first() {
105         return this;
106     }
107 }
108