Skip to content
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -147,10 +147,14 @@ public class AvroUtils {
GenericData.get().addLogicalTypeConversion(new JodaTimestampConversion());
}

// Unwrap an AVRO schema into the base type an whether it is nullable.
static class TypeWithNullability {
public final org.apache.avro.Schema type;
public final boolean nullable;
/** Unwrap an AVRO schema into the base type an whether it is nullable. */
public static class TypeWithNullability {
final org.apache.avro.Schema type;
final boolean nullable;

public static TypeWithNullability create(org.apache.avro.Schema avroSchema) {
return new TypeWithNullability(avroSchema);
}

TypeWithNullability(org.apache.avro.Schema avroSchema) {
if (avroSchema.getType() == org.apache.avro.Schema.Type.UNION) {
Expand Down Expand Up @@ -182,6 +186,14 @@ static class TypeWithNullability {
nullable = false;
}
}

public Boolean isNullable() {
return nullable;
}

public org.apache.avro.Schema getType() {
return type;
}
}

/** Wrapper for fixed byte fields. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,10 +152,14 @@ public class AvroUtils {
}

// Unwrap an AVRO schema into the base type an whether it is nullable.
static class TypeWithNullability {
public static class TypeWithNullability {
public final org.apache.avro.Schema type;
public final boolean nullable;

public static TypeWithNullability create(org.apache.avro.Schema avroSchema) {
return new TypeWithNullability(avroSchema);
}

TypeWithNullability(org.apache.avro.Schema avroSchema) {
if (avroSchema.getType() == Type.UNION) {
List<org.apache.avro.Schema> types = avroSchema.getTypes();
Expand Down Expand Up @@ -184,6 +188,14 @@ static class TypeWithNullability {
nullable = false;
}
}

public Boolean isNullable() {
return nullable;
}

public org.apache.avro.Schema getType() {
return type;
}
}

/** Wrapper for fixed byte fields. */
Expand Down
Loading