1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.jclouds.blobstore.options;
20
21 import static com.google.common.base.Preconditions.checkArgument;
22 import static com.google.common.base.Preconditions.checkNotNull;
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38 public class ListOptions implements Cloneable {
39
40 public static class ImmutableListOptions extends ListOptions {
41 private final ListOptions delegate;
42
43 @Override
44 public ListContainerOptions afterMarker(String marker) {
45 throw new UnsupportedOperationException();
46 }
47
48 public ImmutableListOptions(ListOptions delegate) {
49 this.delegate = delegate;
50 }
51
52 @Override
53 public ListContainerOptions maxResults(int maxKeys) {
54 throw new UnsupportedOperationException();
55 }
56
57 @Override
58 public String getMarker() {
59 return delegate.getMarker();
60 }
61
62 @Override
63 public Integer getMaxResults() {
64 return delegate.getMaxResults();
65 }
66
67 @Override
68 public ListOptions clone() {
69 return delegate.clone();
70 }
71
72 @Override
73 public String toString() {
74 return delegate.toString();
75 }
76 }
77
78 public static final ImmutableListOptions NONE = new ImmutableListOptions(new ListOptions());
79
80 ListOptions(Integer maxKeys, String marker) {
81 this.maxKeys = maxKeys;
82 this.marker = marker;
83 }
84
85 public ListOptions() {
86 }
87
88 private Integer maxKeys;
89 private String marker;
90
91 public Integer getMaxResults() {
92 return maxKeys;
93 }
94
95 public String getMarker() {
96 return marker;
97 }
98
99
100
101
102
103 public ListOptions afterMarker(String marker) {
104 this.marker = checkNotNull(marker, "marker");
105 return this;
106 }
107
108
109
110
111
112 public ListOptions maxResults(int maxKeys) {
113 checkArgument(maxKeys >= 0, "maxKeys must be >= 0");
114 this.maxKeys = maxKeys;
115 return this;
116 }
117
118 public static class Builder {
119
120
121
122
123 public static ListOptions afterMarker(String marker) {
124 ListOptions options = new ListOptions();
125 return options.afterMarker(marker);
126 }
127
128
129
130
131 public static ListOptions maxResults(int maxKeys) {
132 ListOptions options = new ListOptions();
133 return options.maxResults(maxKeys);
134 }
135
136 }
137
138 @Override
139 protected ListOptions clone() {
140 return new ListOptions(maxKeys, marker);
141 }
142 }