30
30
* GitHub history for details.
31
31
*/
32
32
33
+ //----------------------------------------------------
34
+ // THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST.
35
+ //----------------------------------------------------
36
+
33
37
package org .opensearch .client .opensearch ._types ;
34
38
35
39
import jakarta .json .stream .JsonGenerator ;
40
+ import java .util .Objects ;
36
41
import java .util .function .Function ;
42
+ import javax .annotation .Generated ;
43
+ import javax .annotation .Nonnull ;
37
44
import org .opensearch .client .json .JsonpDeserializable ;
38
45
import org .opensearch .client .json .JsonpDeserializer ;
39
46
import org .opensearch .client .json .JsonpMapper ;
40
47
import org .opensearch .client .json .JsonpSerializable ;
48
+ import org .opensearch .client .json .PlainJsonSerializable ;
41
49
import org .opensearch .client .json .UnionDeserializer ;
42
50
import org .opensearch .client .util .ApiTypeHelper ;
43
51
import org .opensearch .client .util .ObjectBuilder ;
48
56
// typedef: _types.GeoHashPrecision
49
57
50
58
/**
51
- * A precision that can be expressed as a geohash length between 1 and 12, or a
52
- * distance measure like "1km", "10m".
53
- *
59
+ * The level of geohash precision, which can be expressed as a geohash length between 1 and 12 or as a distance measure, such as
60
+ * "1km" or "10m".
54
61
*/
55
62
@ JsonpDeserializable
56
- public class GeoHashPrecision implements TaggedUnion <GeoHashPrecision .Kind , Object >, JsonpSerializable {
57
-
63
+ @ Generated ("org.opensearch.client.codegen.CodeGenerator" )
64
+ public class GeoHashPrecision implements TaggedUnion <GeoHashPrecision .Kind , Object >, PlainJsonSerializable {
65
+ /**
66
+ * {@link GeoHashPrecision} variant kinds.
67
+ */
58
68
public enum Kind {
59
- GeohashLength ,
60
- Distance
61
-
69
+ Distance ,
70
+ GeohashLength
62
71
}
63
72
64
73
private final Kind _kind ;
@@ -79,61 +88,56 @@ private GeoHashPrecision(Kind kind, Object value) {
79
88
this ._value = value ;
80
89
}
81
90
91
+ private GeoHashPrecision (Builder builder ) {
92
+ this ._kind = ApiTypeHelper .requireNonNull (builder ._kind , builder , "<variant kind>" );
93
+ this ._value = ApiTypeHelper .requireNonNull (builder ._value , builder , "<variant value>" );
94
+ }
95
+
96
+ public static GeoHashPrecision of (Function <GeoHashPrecision .Builder , ObjectBuilder <GeoHashPrecision >> fn ) {
97
+ return fn .apply (new Builder ()).build ();
98
+ }
99
+
82
100
public String _toJsonString () {
83
101
switch (_kind ) {
84
- case GeohashLength :
85
- return this .geohashLength ().toString ();
86
102
case Distance :
87
103
return this .distance ();
88
-
104
+ case GeohashLength :
105
+ return String .valueOf (this .geohashLength ());
89
106
default :
90
107
throw new IllegalStateException ("Unknown kind " + _kind );
91
108
}
92
109
}
93
110
94
- private GeoHashPrecision (Builder builder ) {
95
-
96
- this ._kind = ApiTypeHelper .requireNonNull (builder ._kind , builder , "<variant kind>" );
97
- this ._value = ApiTypeHelper .requireNonNull (builder ._value , builder , "<variant value>" );
98
-
99
- }
100
-
101
- public static GeoHashPrecision of (Function <Builder , ObjectBuilder <GeoHashPrecision >> fn ) {
102
- return fn .apply (new Builder ()).build ();
103
- }
104
-
105
111
/**
106
- * Is this variant instance of kind {@code geohash_length }?
112
+ * Is this variant instance of kind {@code distance }?
107
113
*/
108
- public boolean isGeohashLength () {
109
- return _kind == Kind .GeohashLength ;
114
+ public boolean isDistance () {
115
+ return _kind == Kind .Distance ;
110
116
}
111
117
112
118
/**
113
- * Get the {@code geohash_length } variant value.
119
+ * Get the {@code distance } variant value.
114
120
*
115
- * @throws IllegalStateException
116
- * if the current variant is not of the {@code geohash_length} kind.
121
+ * @throws IllegalStateException if the current variant is not the {@code distance} kind.
117
122
*/
118
- public Number geohashLength () {
119
- return TaggedUnionUtils .get (this , Kind .GeohashLength );
123
+ public String distance () {
124
+ return TaggedUnionUtils .get (this , Kind .Distance );
120
125
}
121
126
122
127
/**
123
- * Is this variant instance of kind {@code distance }?
128
+ * Is this variant instance of kind {@code geohash_length }?
124
129
*/
125
- public boolean isDistance () {
126
- return _kind == Kind .Distance ;
130
+ public boolean isGeohashLength () {
131
+ return _kind == Kind .GeohashLength ;
127
132
}
128
133
129
134
/**
130
- * Get the {@code distance } variant value.
135
+ * Get the {@code geohash_length } variant value.
131
136
*
132
- * @throws IllegalStateException
133
- * if the current variant is not of the {@code distance} kind.
137
+ * @throws IllegalStateException if the current variant is not the {@code geohash_length} kind.
134
138
*/
135
- public String distance () {
136
- return TaggedUnionUtils .get (this , Kind .Distance );
139
+ public Integer geohashLength () {
140
+ return TaggedUnionUtils .get (this , Kind .GeohashLength );
137
141
}
138
142
139
143
@ Override
@@ -142,27 +146,35 @@ public void serialize(JsonGenerator generator, JsonpMapper mapper) {
142
146
((JsonpSerializable ) _value ).serialize (generator , mapper );
143
147
} else {
144
148
switch (_kind ) {
145
- case GeohashLength :
146
- generator .write (((Number ) this ._value ).doubleValue ());
147
-
148
- break ;
149
149
case Distance :
150
150
generator .write (((String ) this ._value ));
151
-
151
+ break ;
152
+ case GeohashLength :
153
+ generator .write (((Integer ) this ._value ));
152
154
break ;
153
155
}
154
156
}
157
+ }
155
158
159
+ @ Nonnull
160
+ public Builder toBuilder () {
161
+ return new Builder (this );
162
+ }
163
+
164
+ @ Nonnull
165
+ public static Builder builder () {
166
+ return new Builder ();
156
167
}
157
168
158
169
public static class Builder extends ObjectBuilderBase implements ObjectBuilder <GeoHashPrecision > {
159
170
private Kind _kind ;
160
171
private Object _value ;
161
172
162
- public ObjectBuilder <GeoHashPrecision > geohashLength (Number v ) {
163
- this ._kind = Kind .GeohashLength ;
164
- this ._value = v ;
165
- return this ;
173
+ public Builder () {}
174
+
175
+ private Builder (GeoHashPrecision o ) {
176
+ this ._kind = o ._kind ;
177
+ this ._value = o ._value ;
166
178
}
167
179
168
180
public ObjectBuilder <GeoHashPrecision > distance (String v ) {
@@ -171,21 +183,43 @@ public ObjectBuilder<GeoHashPrecision> distance(String v) {
171
183
return this ;
172
184
}
173
185
186
+ public ObjectBuilder <GeoHashPrecision > geohashLength (Integer v ) {
187
+ this ._kind = Kind .GeohashLength ;
188
+ this ._value = v ;
189
+ return this ;
190
+ }
191
+
192
+ @ Override
174
193
public GeoHashPrecision build () {
175
194
_checkSingleUse ();
176
195
return new GeoHashPrecision (this );
177
196
}
178
-
179
197
}
180
198
181
199
private static JsonpDeserializer <GeoHashPrecision > buildGeoHashPrecisionDeserializer () {
182
200
return new UnionDeserializer .Builder <GeoHashPrecision , Kind , Object >(GeoHashPrecision ::new , false ).addMember (
183
- Kind .GeohashLength ,
184
- JsonpDeserializer .numberDeserializer ()
185
- ).addMember (Kind .Distance , JsonpDeserializer .stringDeserializer ()).build ();
201
+ Kind .Distance ,
202
+ JsonpDeserializer .stringDeserializer ()
203
+ ).addMember (Kind .GeohashLength , JsonpDeserializer .integerDeserializer ()).build ();
186
204
}
187
205
188
206
public static final JsonpDeserializer <GeoHashPrecision > _DESERIALIZER = JsonpDeserializer .lazy (
189
207
GeoHashPrecision ::buildGeoHashPrecisionDeserializer
190
208
);
209
+
210
+ @ Override
211
+ public int hashCode () {
212
+ int result = 17 ;
213
+ result = 31 * result + Objects .hashCode (this ._kind );
214
+ result = 31 * result + Objects .hashCode (this ._value );
215
+ return result ;
216
+ }
217
+
218
+ @ Override
219
+ public boolean equals (Object o ) {
220
+ if (this == o ) return true ;
221
+ if (o == null || this .getClass () != o .getClass ()) return false ;
222
+ GeoHashPrecision other = (GeoHashPrecision ) o ;
223
+ return Objects .equals (this ._kind , other ._kind ) && Objects .equals (this ._value , other ._value );
224
+ }
191
225
}
0 commit comments