Skip to content

Commit 0e9f562

Browse files
committed
Minor streamlining
1 parent ade59fc commit 0e9f562

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

avro/src/main/java/com/fasterxml/jackson/dataformat/avro/schema/RecordVisitor.java

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import java.util.List;
55
import java.util.Map;
66

7-
import com.fasterxml.jackson.dataformat.avro.annotation.Decimal;
87
import org.apache.avro.LogicalTypes;
98
import org.apache.avro.Schema;
109
import org.apache.avro.Schema.Type;
@@ -17,6 +16,7 @@
1716
import com.fasterxml.jackson.databind.jsontype.NamedType;
1817
import com.fasterxml.jackson.databind.ser.BeanPropertyWriter;
1918
import com.fasterxml.jackson.dataformat.avro.AvroFixedSize;
19+
import com.fasterxml.jackson.dataformat.avro.annotation.Decimal;
2020
import com.fasterxml.jackson.dataformat.avro.ser.CustomEncodingSerializer;
2121

2222
public class RecordVisitor
@@ -150,17 +150,19 @@ protected Schema.Field schemaFieldForWriter(BeanProperty prop, boolean optional)
150150
Schema.Parser parser = new Schema.Parser();
151151
writerSchema = parser.parse(schemaOverride.value());
152152
} else {
153-
if (prop.getAnnotation(AvroFixedSize.class) != null) {
154-
AvroFixedSize fixedSize = prop.getAnnotation(AvroFixedSize.class);
153+
AvroFixedSize fixedSize = prop.getAnnotation(AvroFixedSize.class);
154+
if (fixedSize != null) {
155155
writerSchema = Schema.createFixed(fixedSize.typeName(), null, fixedSize.typeNamespace(), fixedSize.size());
156156
}
157-
if (_visitorWrapper.isLogicalTypesEnabled() && prop.getAnnotation(Decimal.class) != null) {
158-
if (writerSchema == null) {
159-
writerSchema = Schema.create(Type.BYTES);
160-
}
157+
if (_visitorWrapper.isLogicalTypesEnabled()) {
161158
Decimal decimal = prop.getAnnotation(Decimal.class);
162-
writerSchema = LogicalTypes.decimal(decimal.precision(), decimal.scale())
163-
.addToSchema(writerSchema);
159+
if (decimal != null) {
160+
if (writerSchema == null) {
161+
writerSchema = Schema.create(Type.BYTES);
162+
}
163+
writerSchema = LogicalTypes.decimal(decimal.precision(), decimal.scale())
164+
.addToSchema(writerSchema);
165+
}
164166
}
165167
if (writerSchema == null) {
166168
JsonSerializer<?> ser = null;
@@ -169,9 +171,7 @@ protected Schema.Field schemaFieldForWriter(BeanProperty prop, boolean optional)
169171
if (prop instanceof BeanPropertyWriter) {
170172
BeanPropertyWriter bpw = (BeanPropertyWriter) prop;
171173
ser = bpw.getSerializer();
172-
/*
173-
* 2-Mar-2017, bryan: AvroEncode annotation expects to have the schema used directly
174-
*/
174+
// 2-Mar-2017, bryan: AvroEncode annotation expects to have the schema used directly
175175
optional = optional && !(ser instanceof CustomEncodingSerializer); // Don't modify schema
176176
}
177177
final SerializerProvider prov = getProvider();

0 commit comments

Comments
 (0)