Skip to content

Commit c478f44

Browse files
authored
Merge branch 'eugenp:master' into spring-web-test1
2 parents 9b13da1 + f05bf46 commit c478f44

File tree

117 files changed

+1367
-1229
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

117 files changed

+1367
-1229
lines changed

apache-libraries/src/main/java/com/baeldung/apache/avro/model/Active.java renamed to apache-libraries/src/main/java/com/baeldung/apache/avro/generated/Active.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,13 @@
33
*
44
* DO NOT EDIT DIRECTLY
55
*/
6-
package com.baeldung.apache.avro.model;
7-
@SuppressWarnings("all")
6+
package com.baeldung.apache.avro.generated;
87
@org.apache.avro.specific.AvroGenerated
9-
public enum Active {
8+
public enum Active implements org.apache.avro.generic.GenericEnumSymbol<Active> {
109
YES, NO ;
11-
public static final org.apache.avro.Schema SCHEMA$ = new org.apache.avro.Schema.Parser().parse("{\"type\":\"enum\",\"name\":\"Active\",\"namespace\":\"com.baeldung.avro.model\",\"symbols\":[\"YES\",\"NO\"]}");
10+
public static final org.apache.avro.Schema SCHEMA$ = new org.apache.avro.Schema.Parser().parse("{\"type\":\"enum\",\"name\":\"Active\",\"namespace\":\"com.baeldung.apache.avro.generated\",\"symbols\":[\"YES\",\"NO\"]}");
1211
public static org.apache.avro.Schema getClassSchema() { return SCHEMA$; }
12+
13+
@Override
14+
public org.apache.avro.Schema getSchema() { return SCHEMA$; }
1315
}

apache-libraries/src/main/java/com/baeldung/apache/avro/util/model/AvroHttpRequest.java renamed to apache-libraries/src/main/java/com/baeldung/apache/avro/generated/AvroHttpRequest.java

Lines changed: 225 additions & 67 deletions
Large diffs are not rendered by default.

apache-libraries/src/main/java/com/baeldung/apache/avro/model/ClientIdentifier.java renamed to apache-libraries/src/main/java/com/baeldung/apache/avro/generated/ClientIdentifier.java

Lines changed: 134 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -3,30 +3,42 @@
33
*
44
* DO NOT EDIT DIRECTLY
55
*/
6-
package com.baeldung.apache.avro.model;
6+
package com.baeldung.apache.avro.generated;
77

8+
import org.apache.avro.generic.GenericArray;
89
import org.apache.avro.specific.SpecificData;
10+
import org.apache.avro.util.Utf8;
911
import org.apache.avro.message.BinaryMessageEncoder;
1012
import org.apache.avro.message.BinaryMessageDecoder;
1113
import org.apache.avro.message.SchemaStore;
1214

13-
@SuppressWarnings("all")
1415
@org.apache.avro.specific.AvroGenerated
1516
public class ClientIdentifier extends org.apache.avro.specific.SpecificRecordBase implements org.apache.avro.specific.SpecificRecord {
16-
private static final long serialVersionUID = 8754570983127295424L;
17-
public static final org.apache.avro.Schema SCHEMA$ = new org.apache.avro.Schema.Parser().parse("{\"type\":\"record\",\"name\":\"ClientIdentifier\",\"namespace\":\"com.baeldung.avro.model\",\"fields\":[{\"name\":\"hostName\",\"type\":\"string\"},{\"name\":\"ipAddress\",\"type\":\"string\"}]}");
17+
private static final long serialVersionUID = -1549393766288162557L;
18+
19+
20+
public static final org.apache.avro.Schema SCHEMA$ = new org.apache.avro.Schema.Parser().parse("{\"type\":\"record\",\"name\":\"ClientIdentifier\",\"namespace\":\"com.baeldung.apache.avro.generated\",\"fields\":[{\"name\":\"hostName\",\"type\":{\"type\":\"string\",\"avro.java.string\":\"String\"}},{\"name\":\"ipAddress\",\"type\":{\"type\":\"string\",\"avro.java.string\":\"String\"}}]}");
1821
public static org.apache.avro.Schema getClassSchema() { return SCHEMA$; }
1922

20-
private static SpecificData MODEL$ = new SpecificData();
23+
private static final SpecificData MODEL$ = new SpecificData();
2124

2225
private static final BinaryMessageEncoder<ClientIdentifier> ENCODER =
23-
new BinaryMessageEncoder<ClientIdentifier>(MODEL$, SCHEMA$);
26+
new BinaryMessageEncoder<>(MODEL$, SCHEMA$);
2427

2528
private static final BinaryMessageDecoder<ClientIdentifier> DECODER =
26-
new BinaryMessageDecoder<ClientIdentifier>(MODEL$, SCHEMA$);
29+
new BinaryMessageDecoder<>(MODEL$, SCHEMA$);
30+
31+
/**
32+
* Return the BinaryMessageEncoder instance used by this class.
33+
* @return the message encoder used by this class
34+
*/
35+
public static BinaryMessageEncoder<ClientIdentifier> getEncoder() {
36+
return ENCODER;
37+
}
2738

2839
/**
2940
* Return the BinaryMessageDecoder instance used by this class.
41+
* @return the message decoder used by this class
3042
*/
3143
public static BinaryMessageDecoder<ClientIdentifier> getDecoder() {
3244
return DECODER;
@@ -35,24 +47,34 @@ public static BinaryMessageDecoder<ClientIdentifier> getDecoder() {
3547
/**
3648
* Create a new BinaryMessageDecoder instance for this class that uses the specified {@link SchemaStore}.
3749
* @param resolver a {@link SchemaStore} used to find schemas by fingerprint
50+
* @return a BinaryMessageDecoder instance for this class backed by the given SchemaStore
3851
*/
3952
public static BinaryMessageDecoder<ClientIdentifier> createDecoder(SchemaStore resolver) {
40-
return new BinaryMessageDecoder<ClientIdentifier>(MODEL$, SCHEMA$, resolver);
53+
return new BinaryMessageDecoder<>(MODEL$, SCHEMA$, resolver);
4154
}
4255

43-
/** Serializes this ClientIdentifier to a ByteBuffer. */
56+
/**
57+
* Serializes this ClientIdentifier to a ByteBuffer.
58+
* @return a buffer holding the serialized data for this instance
59+
* @throws java.io.IOException if this instance could not be serialized
60+
*/
4461
public java.nio.ByteBuffer toByteBuffer() throws java.io.IOException {
4562
return ENCODER.encode(this);
4663
}
4764

48-
/** Deserializes a ClientIdentifier from a ByteBuffer. */
65+
/**
66+
* Deserializes a ClientIdentifier from a ByteBuffer.
67+
* @param b a byte buffer holding serialized data for an instance of this class
68+
* @return a ClientIdentifier instance decoded from the given buffer
69+
* @throws java.io.IOException if the given bytes could not be deserialized into an instance of this class
70+
*/
4971
public static ClientIdentifier fromByteBuffer(
5072
java.nio.ByteBuffer b) throws java.io.IOException {
5173
return DECODER.decode(b);
5274
}
5375

54-
@Deprecated public java.lang.CharSequence hostName;
55-
@Deprecated public java.lang.CharSequence ipAddress;
76+
private java.lang.String hostName;
77+
private java.lang.String ipAddress;
5678

5779
/**
5880
* Default constructor. Note that this does not initialize fields
@@ -66,125 +88,143 @@ public ClientIdentifier() {}
6688
* @param hostName The new value for hostName
6789
* @param ipAddress The new value for ipAddress
6890
*/
69-
public ClientIdentifier(java.lang.CharSequence hostName, java.lang.CharSequence ipAddress) {
91+
public ClientIdentifier(java.lang.String hostName, java.lang.String ipAddress) {
7092
this.hostName = hostName;
7193
this.ipAddress = ipAddress;
7294
}
7395

96+
@Override
97+
public org.apache.avro.specific.SpecificData getSpecificData() { return MODEL$; }
98+
99+
@Override
74100
public org.apache.avro.Schema getSchema() { return SCHEMA$; }
101+
75102
// Used by DatumWriter. Applications should not call.
103+
@Override
76104
public java.lang.Object get(int field$) {
77105
switch (field$) {
78106
case 0: return hostName;
79107
case 1: return ipAddress;
80-
default: throw new org.apache.avro.AvroRuntimeException("Bad index");
108+
default: throw new IndexOutOfBoundsException("Invalid index: " + field$);
81109
}
82110
}
83111

84112
// Used by DatumReader. Applications should not call.
113+
@Override
85114
@SuppressWarnings(value="unchecked")
86115
public void put(int field$, java.lang.Object value$) {
87116
switch (field$) {
88-
case 0: hostName = (java.lang.CharSequence)value$; break;
89-
case 1: ipAddress = (java.lang.CharSequence)value$; break;
90-
default: throw new org.apache.avro.AvroRuntimeException("Bad index");
117+
case 0: hostName = value$ != null ? value$.toString() : null; break;
118+
case 1: ipAddress = value$ != null ? value$.toString() : null; break;
119+
default: throw new IndexOutOfBoundsException("Invalid index: " + field$);
91120
}
92121
}
93122

94123
/**
95124
* Gets the value of the 'hostName' field.
96125
* @return The value of the 'hostName' field.
97126
*/
98-
public java.lang.CharSequence getHostName() {
127+
public java.lang.String getHostName() {
99128
return hostName;
100129
}
101130

131+
102132
/**
103133
* Sets the value of the 'hostName' field.
104134
* @param value the value to set.
105135
*/
106-
public void setHostName(java.lang.CharSequence value) {
136+
public void setHostName(java.lang.String value) {
107137
this.hostName = value;
108138
}
109139

110140
/**
111141
* Gets the value of the 'ipAddress' field.
112142
* @return The value of the 'ipAddress' field.
113143
*/
114-
public java.lang.CharSequence getIpAddress() {
144+
public java.lang.String getIpAddress() {
115145
return ipAddress;
116146
}
117147

148+
118149
/**
119150
* Sets the value of the 'ipAddress' field.
120151
* @param value the value to set.
121152
*/
122-
public void setIpAddress(java.lang.CharSequence value) {
153+
public void setIpAddress(java.lang.String value) {
123154
this.ipAddress = value;
124155
}
125156

126157
/**
127158
* Creates a new ClientIdentifier RecordBuilder.
128159
* @return A new ClientIdentifier RecordBuilder
129160
*/
130-
public static ClientIdentifier.Builder newBuilder() {
131-
return new ClientIdentifier.Builder();
161+
public static com.baeldung.apache.avro.generated.ClientIdentifier.Builder newBuilder() {
162+
return new com.baeldung.apache.avro.generated.ClientIdentifier.Builder();
132163
}
133164

134165
/**
135166
* Creates a new ClientIdentifier RecordBuilder by copying an existing Builder.
136167
* @param other The existing builder to copy.
137168
* @return A new ClientIdentifier RecordBuilder
138169
*/
139-
public static ClientIdentifier.Builder newBuilder(ClientIdentifier.Builder other) {
140-
return new ClientIdentifier.Builder(other);
170+
public static com.baeldung.apache.avro.generated.ClientIdentifier.Builder newBuilder(com.baeldung.apache.avro.generated.ClientIdentifier.Builder other) {
171+
if (other == null) {
172+
return new com.baeldung.apache.avro.generated.ClientIdentifier.Builder();
173+
} else {
174+
return new com.baeldung.apache.avro.generated.ClientIdentifier.Builder(other);
175+
}
141176
}
142177

143178
/**
144179
* Creates a new ClientIdentifier RecordBuilder by copying an existing ClientIdentifier instance.
145180
* @param other The existing instance to copy.
146181
* @return A new ClientIdentifier RecordBuilder
147182
*/
148-
public static ClientIdentifier.Builder newBuilder(ClientIdentifier other) {
149-
return new ClientIdentifier.Builder(other);
183+
public static com.baeldung.apache.avro.generated.ClientIdentifier.Builder newBuilder(com.baeldung.apache.avro.generated.ClientIdentifier other) {
184+
if (other == null) {
185+
return new com.baeldung.apache.avro.generated.ClientIdentifier.Builder();
186+
} else {
187+
return new com.baeldung.apache.avro.generated.ClientIdentifier.Builder(other);
188+
}
150189
}
151190

152191
/**
153192
* RecordBuilder for ClientIdentifier instances.
154193
*/
194+
@org.apache.avro.specific.AvroGenerated
155195
public static class Builder extends org.apache.avro.specific.SpecificRecordBuilderBase<ClientIdentifier>
156196
implements org.apache.avro.data.RecordBuilder<ClientIdentifier> {
157197

158-
private java.lang.CharSequence hostName;
159-
private java.lang.CharSequence ipAddress;
198+
private java.lang.String hostName;
199+
private java.lang.String ipAddress;
160200

161201
/** Creates a new Builder */
162202
private Builder() {
163-
super(SCHEMA$);
203+
super(SCHEMA$, MODEL$);
164204
}
165205

166206
/**
167207
* Creates a Builder by copying an existing Builder.
168208
* @param other The existing Builder to copy.
169209
*/
170-
private Builder(ClientIdentifier.Builder other) {
210+
private Builder(com.baeldung.apache.avro.generated.ClientIdentifier.Builder other) {
171211
super(other);
172212
if (isValidValue(fields()[0], other.hostName)) {
173213
this.hostName = data().deepCopy(fields()[0].schema(), other.hostName);
174-
fieldSetFlags()[0] = true;
214+
fieldSetFlags()[0] = other.fieldSetFlags()[0];
175215
}
176216
if (isValidValue(fields()[1], other.ipAddress)) {
177217
this.ipAddress = data().deepCopy(fields()[1].schema(), other.ipAddress);
178-
fieldSetFlags()[1] = true;
218+
fieldSetFlags()[1] = other.fieldSetFlags()[1];
179219
}
180220
}
181221

182222
/**
183223
* Creates a Builder by copying an existing ClientIdentifier instance
184224
* @param other The existing instance to copy.
185225
*/
186-
private Builder(ClientIdentifier other) {
187-
super(SCHEMA$);
226+
private Builder(com.baeldung.apache.avro.generated.ClientIdentifier other) {
227+
super(SCHEMA$, MODEL$);
188228
if (isValidValue(fields()[0], other.hostName)) {
189229
this.hostName = data().deepCopy(fields()[0].schema(), other.hostName);
190230
fieldSetFlags()[0] = true;
@@ -199,16 +239,17 @@ private Builder(ClientIdentifier other) {
199239
* Gets the value of the 'hostName' field.
200240
* @return The value.
201241
*/
202-
public java.lang.CharSequence getHostName() {
242+
public java.lang.String getHostName() {
203243
return hostName;
204244
}
205245

246+
206247
/**
207248
* Sets the value of the 'hostName' field.
208249
* @param value The value of 'hostName'.
209250
* @return This builder.
210251
*/
211-
public ClientIdentifier.Builder setHostName(java.lang.CharSequence value) {
252+
public com.baeldung.apache.avro.generated.ClientIdentifier.Builder setHostName(java.lang.String value) {
212253
validate(fields()[0], value);
213254
this.hostName = value;
214255
fieldSetFlags()[0] = true;
@@ -228,7 +269,7 @@ public boolean hasHostName() {
228269
* Clears the value of the 'hostName' field.
229270
* @return This builder.
230271
*/
231-
public ClientIdentifier.Builder clearHostName() {
272+
public com.baeldung.apache.avro.generated.ClientIdentifier.Builder clearHostName() {
232273
hostName = null;
233274
fieldSetFlags()[0] = false;
234275
return this;
@@ -238,16 +279,17 @@ public ClientIdentifier.Builder clearHostName() {
238279
* Gets the value of the 'ipAddress' field.
239280
* @return The value.
240281
*/
241-
public java.lang.CharSequence getIpAddress() {
282+
public java.lang.String getIpAddress() {
242283
return ipAddress;
243284
}
244285

286+
245287
/**
246288
* Sets the value of the 'ipAddress' field.
247289
* @param value The value of 'ipAddress'.
248290
* @return This builder.
249291
*/
250-
public ClientIdentifier.Builder setIpAddress(java.lang.CharSequence value) {
292+
public com.baeldung.apache.avro.generated.ClientIdentifier.Builder setIpAddress(java.lang.String value) {
251293
validate(fields()[1], value);
252294
this.ipAddress = value;
253295
fieldSetFlags()[1] = true;
@@ -267,7 +309,7 @@ public boolean hasIpAddress() {
267309
* Clears the value of the 'ipAddress' field.
268310
* @return This builder.
269311
*/
270-
public ClientIdentifier.Builder clearIpAddress() {
312+
public com.baeldung.apache.avro.generated.ClientIdentifier.Builder clearIpAddress() {
271313
ipAddress = null;
272314
fieldSetFlags()[1] = false;
273315
return this;
@@ -278,9 +320,11 @@ public ClientIdentifier.Builder clearIpAddress() {
278320
public ClientIdentifier build() {
279321
try {
280322
ClientIdentifier record = new ClientIdentifier();
281-
record.hostName = fieldSetFlags()[0] ? this.hostName : (java.lang.CharSequence) defaultValue(fields()[0]);
282-
record.ipAddress = fieldSetFlags()[1] ? this.ipAddress : (java.lang.CharSequence) defaultValue(fields()[1]);
323+
record.hostName = fieldSetFlags()[0] ? this.hostName : (java.lang.String) defaultValue(fields()[0]);
324+
record.ipAddress = fieldSetFlags()[1] ? this.ipAddress : (java.lang.String) defaultValue(fields()[1]);
283325
return record;
326+
} catch (org.apache.avro.AvroMissingFieldException e) {
327+
throw e;
284328
} catch (java.lang.Exception e) {
285329
throw new org.apache.avro.AvroRuntimeException(e);
286330
}
@@ -305,4 +349,51 @@ public ClientIdentifier build() {
305349
READER$.read(this, SpecificData.getDecoder(in));
306350
}
307351

352+
@Override protected boolean hasCustomCoders() { return true; }
353+
354+
@Override public void customEncode(org.apache.avro.io.Encoder out)
355+
throws java.io.IOException
356+
{
357+
out.writeString(this.hostName);
358+
359+
out.writeString(this.ipAddress);
360+
361+
}
362+
363+
@Override public void customDecode(org.apache.avro.io.ResolvingDecoder in)
364+
throws java.io.IOException
365+
{
366+
org.apache.avro.Schema.Field[] fieldOrder = in.readFieldOrderIfDiff();
367+
if (fieldOrder == null) {
368+
this.hostName = in.readString();
369+
370+
this.ipAddress = in.readString();
371+
372+
} else {
373+
for (int i = 0; i < 2; i++) {
374+
switch (fieldOrder[i].pos()) {
375+
case 0:
376+
this.hostName = in.readString();
377+
break;
378+
379+
case 1:
380+
this.ipAddress = in.readString();
381+
break;
382+
383+
default:
384+
throw new java.io.IOException("Corrupt ResolvingDecoder.");
385+
}
386+
}
387+
}
388+
}
308389
}
390+
391+
392+
393+
394+
395+
396+
397+
398+
399+

0 commit comments

Comments
 (0)