Skip to content

Commit 44ebb50

Browse files
committed
Start removing Lombok: should have mentioned earlier but bit too intrusive unfortunately (requires installing of pieces in classpath)
1 parent dbb733f commit 44ebb50

File tree

5 files changed

+107
-88
lines changed

5 files changed

+107
-88
lines changed

avro/src/main/java/com/fasterxml/jackson/dataformat/avro/AvroAnnotationIntrospector.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public PropertyName findNameForDeserialization(Annotated a) {
6969
public Object findDeserializer(Annotated am) {
7070
AvroEncode ann = _findAnnotation(am, AvroEncode.class);
7171
if (ann != null) {
72-
return new CustomEncodingDeserializer<>((CustomEncoding)ClassUtil.createInstance(ann.using(), true));
72+
return new CustomEncodingDeserializer<>((CustomEncoding<?>)ClassUtil.createInstance(ann.using(), true));
7373
}
7474
return null;
7575
}
@@ -127,7 +127,7 @@ public Object findSerializer(Annotated a) {
127127
}
128128
AvroEncode ann = _findAnnotation(a, AvroEncode.class);
129129
if (ann != null) {
130-
return new CustomEncodingSerializer<>((CustomEncoding)ClassUtil.createInstance(ann.using(), true));
130+
return new CustomEncodingSerializer<>((CustomEncoding<?>)ClassUtil.createInstance(ann.using(), true));
131131
}
132132
return null;
133133
}

avro/src/test/java/com/fasterxml/jackson/dataformat/avro/interop/annotations/AvroEncodeTest.java

Lines changed: 38 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@
66
import java.util.HashMap;
77
import java.util.Map;
88

9-
import lombok.AllArgsConstructor;
10-
import lombok.Data;
11-
import lombok.NoArgsConstructor;
129
import org.apache.avro.io.Decoder;
1310
import org.apache.avro.io.Encoder;
1411
import org.apache.avro.reflect.AvroEncode;
@@ -24,44 +21,39 @@
2421
import static org.assertj.core.api.Assertions.assertThat;
2522

2623
public class AvroEncodeTest extends InteropTestBase {
27-
28-
@Data
2924
static class Wrapper {
30-
31-
private double precedingValue = 0.18273465;
25+
public double precedingValue = 0.18273465;
3226

3327
@AvroEncode(using = ApacheImplEncoding.class)
34-
private CustomComponent component;
28+
public CustomComponent component;
3529

36-
private int followingValue = 3456;
30+
public int followingValue = 3456;
3731

32+
public void setComponent(CustomComponent c) { component = c; }
3833
}
3934

40-
@Data
41-
@AllArgsConstructor
42-
@NoArgsConstructor
4335
static class CustomComponent {
36+
public int intValue;
4437

45-
private int intValue;
46-
47-
private byte byteValue;
38+
public byte byteValue;
4839

49-
private short shortValue;
40+
public short shortValue;
5041

51-
private String stringValue;
42+
public String stringValue;
5243

5344
@Nullable
54-
private Map<String, ArrayList<Integer>> mapValue;
45+
public Map<String, ArrayList<Integer>> mapValue;
5546

5647
@Nullable
57-
private CustomComponent nestedRecordValue;
48+
public CustomComponent nestedRecordValue;
5849

5950
@Nullable
60-
private Double doubleValue;
51+
public Double doubleValue;
6152

6253
@Nullable
63-
private Long longValue;
54+
public Long longValue;
6455

56+
protected CustomComponent() { }
6557
}
6658

6759
public static class ApacheImplEncoding extends CustomEncoding<CustomComponent> {
@@ -91,54 +83,57 @@ public void setup() throws IOException {
9183
wrapper = new Wrapper();
9284
//
9385
wrapper.setComponent(new CustomComponent());
94-
wrapper.getComponent().setByteValue((byte) 126);
95-
wrapper.getComponent().setIntValue(897125364);
96-
wrapper.getComponent().setShortValue((short) -7614);
97-
wrapper.getComponent().setMapValue(new HashMap<String, ArrayList<Integer>>());
98-
wrapper.getComponent().getMapValue().put("birds", new ArrayList<>(Arrays.asList(1, 2, 3, 4, 5, 6)));
99-
wrapper.getComponent().getMapValue().put("cats", new ArrayList<Integer>());
100-
wrapper.getComponent().getMapValue().put("dogs", new ArrayList<>(Arrays.asList(-1234, 56, 6767, 54134, 57, 86)));
101-
wrapper.getComponent().setStringValue("Hello World!");
102-
//
103-
wrapper.getComponent().setNestedRecordValue(new CustomComponent());
104-
wrapper.getComponent().getNestedRecordValue().setByteValue((byte) 42);
105-
wrapper.getComponent().getNestedRecordValue().setIntValue(9557748);
106-
wrapper.getComponent().getNestedRecordValue().setShortValue((short) -1542);
107-
wrapper.getComponent().getNestedRecordValue().setDoubleValue(Double.POSITIVE_INFINITY);
108-
wrapper.getComponent().getNestedRecordValue().setLongValue(Long.MAX_VALUE);
109-
wrapper.getComponent().getNestedRecordValue().setStringValue("Nested Hello World!");
86+
wrapper.component.byteValue = (byte) 126;
87+
wrapper.component.intValue = 897125364;
88+
wrapper.component.shortValue = (short) -7614;
89+
Map<String, ArrayList<Integer>> mv = new HashMap<>();
90+
wrapper.component.mapValue = mv;
91+
mv.put("birds", new ArrayList<>(Arrays.asList(1, 2, 3, 4, 5, 6)));
92+
mv.put("cats", new ArrayList<Integer>());
93+
mv.put("dogs", new ArrayList<>(Arrays.asList(-1234, 56, 6767, 54134, 57, 86)));
94+
wrapper.component.stringValue = "Hello World!";
95+
96+
CustomComponent cc = new CustomComponent();
97+
cc.byteValue = (byte) 42;
98+
cc.intValue = 9557748;
99+
cc.shortValue = (short) -1542;
100+
cc.doubleValue = Double.POSITIVE_INFINITY;
101+
cc.longValue = Long.MAX_VALUE;
102+
cc.stringValue = "Nested Hello World!";
103+
wrapper.component.nestedRecordValue = cc;
104+
110105
//
111106
result = roundTrip(wrapper);
112107
}
113108

114109
@Test
115110
public void testByteValue() {
116-
assertThat(result.getComponent().getByteValue()).isEqualTo(wrapper.getComponent().getByteValue());
111+
assertThat(result.component.byteValue).isEqualTo(wrapper.component.byteValue);
117112
}
118113

119114
@Test
120115
public void testShortValue() {
121-
assertThat(result.getComponent().getShortValue()).isEqualTo(wrapper.getComponent().getShortValue());
116+
assertThat(result.component.shortValue).isEqualTo(wrapper.component.shortValue);
122117
}
123118

124119
@Test
125120
public void testStringValue() {
126-
assertThat(result.getComponent().getStringValue()).isEqualTo(wrapper.getComponent().getStringValue());
121+
assertThat(result.component.stringValue).isEqualTo(wrapper.component.stringValue);
127122
}
128123

129124
@Test
130125
public void testDoubleValue() {
131-
assertThat(result.getComponent().getDoubleValue()).isEqualTo(wrapper.getComponent().getDoubleValue());
126+
assertThat(result.component.doubleValue).isEqualTo(wrapper.component.doubleValue);
132127
}
133128

134129
@Test
135130
public void testLongValue() {
136-
assertThat(result.getComponent().getLongValue()).isEqualTo(wrapper.getComponent().getLongValue());
131+
assertThat(result.component.longValue).isEqualTo(wrapper.component.longValue);
137132
}
138133

139134
@Test
140135
public void testIntegerValue() {
141-
assertThat(result.getComponent().getIntValue()).isEqualTo(wrapper.getComponent().getIntValue());
136+
assertThat(result.component.intValue).isEqualTo(wrapper.component.intValue);
142137
}
143138

144139
}

avro/src/test/java/com/fasterxml/jackson/dataformat/avro/interop/annotations/AvroSchemaTest.java

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import com.fasterxml.jackson.dataformat.avro.interop.ApacheAvroInteropUtil;
66
import com.fasterxml.jackson.dataformat.avro.interop.InteropTestBase;
77

8-
import lombok.Data;
98
import org.apache.avro.Schema;
109
import org.apache.avro.reflect.AvroSchema;
1110
import org.apache.avro.reflect.Nullable;
@@ -27,27 +26,23 @@
2726
* Additionally, tests that class and property descriptions are picked up correctly when using Jackson annotations
2827
*/
2928
public class AvroSchemaTest extends InteropTestBase {
30-
31-
@Data
3229
@AvroSchema("{\"type\":\"string\"}")
3330
public static class OverriddenClassSchema {
34-
int field;
31+
public int field;
3532
}
3633

37-
@Data
3834
@JsonClassDescription("A cool class!")
3935
public static class OverriddenFieldSchema {
40-
4136
@AvroSchema("{\"type\":\"int\"}")
42-
private String myField;
37+
public String myField;
4338

4439
@Nullable
4540
@JsonPropertyDescription("the best field in the world")
46-
private OverriddenClassSchema recursiveOverride;
41+
public OverriddenClassSchema recursiveOverride;
4742

4843
@Nullable
4944
@AvroSchema("{\"type\":\"long\"}")
50-
private OverriddenClassSchema precedenceField;
45+
public OverriddenClassSchema precedenceField;
5146
}
5247

5348
@Test

avro/src/test/java/com/fasterxml/jackson/dataformat/avro/interop/annotations/UnionTest.java

Lines changed: 63 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@
44
import java.util.Arrays;
55
import java.util.List;
66

7-
import lombok.AllArgsConstructor;
8-
import lombok.Data;
9-
import lombok.NoArgsConstructor;
107
import org.apache.avro.UnresolvedUnionException;
118
import org.apache.avro.reflect.Nullable;
129
import org.apache.avro.reflect.Union;
@@ -24,53 +21,86 @@
2421
public class UnionTest extends InteropTestBase {
2522

2623
@Union({ Cat.class, Dog.class })
27-
public interface Animal {
28-
29-
}
30-
31-
@Data
32-
@AllArgsConstructor
33-
@NoArgsConstructor
34-
public static class Cat implements Animal {
24+
public interface Animal { }
3525

26+
static class Cat implements Animal {
3627
@Nullable
37-
private String color;
28+
public String color;
29+
30+
protected Cat() { }
31+
public Cat(String c) { color = c; }
32+
33+
@Override
34+
public boolean equals(Object o) {
35+
if (o.getClass() == getClass()) {
36+
Cat other = (Cat) o;
37+
if (color == null) return other.color == null;
38+
else return color.equals(other.color);
39+
}
40+
return false;
41+
}
3842
}
3943

40-
@Data
41-
@AllArgsConstructor
42-
@NoArgsConstructor
43-
public static class Dog implements Animal {
44+
static class Dog implements Animal {
45+
public int size;
46+
47+
protected Dog() { }
48+
public Dog(int s) { size = s; }
4449

45-
private int size;
50+
@Override
51+
public boolean equals(Object o) {
52+
return (o.getClass() == getClass())
53+
&& (size == ((Dog) o).size);
54+
}
4655
}
4756

48-
@Data
49-
@AllArgsConstructor
50-
@NoArgsConstructor
51-
public static class Bird implements Animal {
57+
static class Bird implements Animal {
58+
public boolean flying;
5259

53-
private boolean flying;
60+
protected Bird() { }
61+
public Bird(boolean f) { flying = f; }
62+
63+
@Override
64+
public boolean equals(Object o) {
65+
return (o.getClass() == getClass())
66+
&& (flying == ((Bird) o).flying);
67+
}
5468
}
5569

56-
@Data
57-
@AllArgsConstructor
58-
@NoArgsConstructor
5970
public static class Cage {
60-
61-
private Animal animal;
71+
public Animal animal;
72+
73+
public Cage(Animal a) { animal = a; }
74+
protected Cage() { }
75+
76+
@Override
77+
public boolean equals(Object o) {
78+
if (o instanceof Cage) {
79+
Cage other = (Cage) o;
80+
if (animal == null) return other.animal == null;
81+
return animal.equals(other.animal);
82+
}
83+
return false;
84+
}
6285
}
6386

64-
@Data
65-
@AllArgsConstructor
66-
@NoArgsConstructor
6787
public static class PetShop {
88+
public List<Animal> pets;
6889

69-
public PetShop(Animal... pets) {
70-
this(Arrays.asList(pets));
90+
protected PetShop() { }
91+
public PetShop(Animal... p) {
92+
pets = Arrays.asList(p);
7193
}
7294

73-
private List<Animal> pets;
95+
@Override
96+
public boolean equals(Object o) {
97+
if (o.getClass() == getClass()) {
98+
PetShop other = (PetShop) o;
99+
if (pets == null) return other.pets == null;
100+
else return pets.equals(other.pets);
101+
}
102+
return false;
103+
}
74104
}
75105

76106
@Test

avro/src/test/java/com/fasterxml/jackson/dataformat/avro/interop/arrays/ListWithComplexTest.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import java.util.List;
77
import java.util.Map;
88

9-
import org.junit.Before;
109
import org.junit.Test;
1110

1211
import com.fasterxml.jackson.dataformat.avro.interop.DummyRecord;

0 commit comments

Comments
 (0)