1 package com.atlassian.marketplace.client.api;
2
3 import com.atlassian.fugue.Option;
4
5 import static com.atlassian.fugue.Option.none;
6 import static com.atlassian.marketplace.client.api.QueryProperties.describeParams;
7 import static com.atlassian.marketplace.client.api.QueryProperties.describeValues;
8 import static com.google.common.base.Preconditions.checkNotNull;
9
10
11
12
13
14 public final class ApplicationVersionsQuery implements QueryProperties.Bounds
15 {
16 private static final ApplicationVersionsQuery DEFAULT_QUERY = builder().build();
17
18 private final Option<Integer> afterBuildNumber;
19 private final QueryBounds bounds;
20
21
22
23
24 public static Builder builder()
25 {
26 return new Builder();
27 }
28
29
30
31
32 public static ApplicationVersionsQuery any()
33 {
34 return DEFAULT_QUERY;
35 }
36
37
38
39
40 public static Builder builder(ApplicationVersionsQuery query)
41 {
42 Builder builder = builder()
43 .afterBuildNumber(query.getAfterBuildNumber())
44 .bounds(query.getBounds());
45
46 return builder;
47 }
48
49 private ApplicationVersionsQuery(Builder builder)
50 {
51 afterBuildNumber = builder.afterBuildNumber;
52 bounds = builder.bounds;
53 }
54
55
56
57
58
59
60 public Option<Integer> getAfterBuildNumber()
61 {
62 return afterBuildNumber;
63 }
64
65 @Override
66 public QueryBounds getBounds()
67 {
68 return bounds;
69 }
70
71 @SuppressWarnings("unchecked")
72 @Override
73 public String toString()
74 {
75 return describeParams("ApplicationVersionsQuery",
76 describeValues("afterBuildNumber", afterBuildNumber),
77 bounds.describe()
78 );
79 }
80
81 @Override
82 public boolean equals(Object other)
83 {
84 return (other instanceof ApplicationVersionsQuery) ? toString().equals(other.toString()) : false;
85 }
86
87 @Override
88 public int hashCode()
89 {
90 return toString().hashCode();
91 }
92
93
94
95
96 public static class Builder implements QueryBuilderProperties.Bounds<Builder>
97 {
98 private Option<Integer> afterBuildNumber = none();
99 private QueryBounds bounds = QueryBounds.defaultBounds();
100
101
102
103
104 public ApplicationVersionsQuery build()
105 {
106 return new ApplicationVersionsQuery(this);
107 }
108
109
110
111
112
113
114
115
116
117
118 public Builder afterBuildNumber(Option<Integer> afterBuildNumber)
119 {
120 this.afterBuildNumber = checkNotNull(afterBuildNumber);
121 return this;
122 }
123
124 @Override
125 public Builder bounds(QueryBounds bounds)
126 {
127 this.bounds = checkNotNull(bounds);
128 return this;
129 }
130 }
131 }