Skip to content

Commit

Permalink
refactor(avro schema): rename Avro* to AvroSchema*
Browse files Browse the repository at this point in the history
  • Loading branch information
Pakisan committed Apr 18, 2024
1 parent 6caac9c commit 26a8d99
Show file tree
Hide file tree
Showing 22 changed files with 733 additions and 589 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,31 +23,31 @@
use = JsonTypeInfo.Id.NAME,
include = JsonTypeInfo.As.EXISTING_PROPERTY,
property = "type",
defaultImpl = AvroUnion.class,
defaultImpl = AvroSchemaUnion.class,
visible = true
)
@JsonSubTypes({
@JsonSubTypes.Type(value = Avro.class, names = {
AvroType.NULL, AvroType.BOOLEAN, AvroType.INT, AvroType.LONG,
AvroType.FLOAT, AvroType.DOUBLE, AvroType.BYTES, AvroType.STRING
@JsonSubTypes.Type(value = AvroSchema.class, names = {
AvroSchemaType.NULL, AvroSchemaType.BOOLEAN, AvroSchemaType.INT, AvroSchemaType.LONG,
AvroSchemaType.FLOAT, AvroSchemaType.DOUBLE, AvroSchemaType.BYTES, AvroSchemaType.STRING
}),
@JsonSubTypes.Type(value = AvroRecord.class, names = {AvroType.RECORD, AvroType.ERROR}),
@JsonSubTypes.Type(value = AvroArray.class, name = AvroType.ARRAY),
@JsonSubTypes.Type(value = AvroMap.class, name = AvroType.MAP),
@JsonSubTypes.Type(value = AvroEnum.class, name = AvroType.ENUM),
@JsonSubTypes.Type(value = AvroFixed.class, name = AvroType.FIXED),
@JsonSubTypes.Type(value = AvroSchemaRecord.class, names = {AvroSchemaType.RECORD, AvroSchemaType.ERROR}),
@JsonSubTypes.Type(value = AvroSchemaArray.class, name = AvroSchemaType.ARRAY),
@JsonSubTypes.Type(value = AvroSchemaMap.class, name = AvroSchemaType.MAP),
@JsonSubTypes.Type(value = AvroSchemaEnum.class, name = AvroSchemaType.ENUM),
@JsonSubTypes.Type(value = AvroSchemaFixed.class, name = AvroSchemaType.FIXED),
})
public class Avro extends AvroMetadata {
public class AvroSchema extends AvroSchemaMetadata {

public Avro() {
this.type = AvroType.NULL;
public AvroSchema() {
this.type = AvroSchemaType.NULL;
}

public Avro(@NotNull String avroType) {
public AvroSchema(@NotNull String avroType) {
this.type = avroType;
}

public Avro(@NotNull Builder<?, ?> builder) {
public AvroSchema(@NotNull Builder<?, ?> builder) {
this.type = builder.type;
this.scale = builder.scale;
this.precision = builder.precision;
Expand Down Expand Up @@ -86,18 +86,18 @@ protected Builder getThis() {

@NotNull
@Override
public Avro build() {
return new Avro(this);
public AvroSchema build() {
return new AvroSchema(this);
}

};

}

public static abstract class Builder<AvroSchemaVariant extends Avro, BuilderVariant extends Builder<AvroSchemaVariant, BuilderVariant>> {
public static abstract class Builder<AvroSchemaVariant extends AvroSchema, BuilderVariant extends Builder<AvroSchemaVariant, BuilderVariant>> {

@NotNull
protected String type = AvroType.NULL;
protected String type = AvroSchemaType.NULL;

@Nullable
private Integer scale;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,30 +17,30 @@
*/
@Data
@EqualsAndHashCode(callSuper = true)
public class AvroArray extends Avro {
public class AvroSchemaArray extends AvroSchema {

public AvroArray() {
super(AvroType.ARRAY);
public AvroSchemaArray() {
super(AvroSchemaType.ARRAY);
}

public AvroArray(@NotNull Object items) {
super(AvroType.ARRAY);
public AvroSchemaArray(@NotNull Object items) {
super(AvroSchemaType.ARRAY);
this.items = items;
}

public AvroArray(
public AvroSchemaArray(
@NotNull Object items,
@Nullable List<Object> defaultValue,
@Nullable Map<String, Object> metadata
) {
super(AvroType.ARRAY);
super(AvroSchemaType.ARRAY);
this.items = items;
this.defaultValue = defaultValue;
this.metadata = metadata;
}

public AvroArray(@NotNull Builder builder) {
super(AvroType.ARRAY);
public AvroSchemaArray(@NotNull Builder builder) {
super(AvroSchemaType.ARRAY);

this.items = builder.items;
this.defaultValue = builder.defaultValue;
Expand All @@ -59,18 +59,18 @@ public AvroArray(@NotNull Builder builder) {
@NotNull
@Override
public String getType() {
return AvroType.ARRAY;
return AvroSchemaType.ARRAY;
}

public void setType(@NotNull String type) {
super.setType(AvroType.ARRAY);
super.setType(AvroSchemaType.ARRAY);
}

public static Builder builder() {
return new Builder();
}

public static class Builder extends Avro.Builder<AvroArray, Builder> {
public static class Builder extends AvroSchema.Builder<AvroSchemaArray, Builder> {

@NotNull
private Object items = Collections.emptyList();
Expand Down Expand Up @@ -98,8 +98,8 @@ protected Builder getThis() {

@NotNull
@Override
public AvroArray build() {
return new AvroArray(this);
public AvroSchemaArray build() {
return new AvroSchemaArray(this);
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@
*/
@Data
@EqualsAndHashCode(callSuper = true)
public class AvroEnum extends Avro {
public class AvroSchemaEnum extends AvroSchema {

public AvroEnum() {
super(AvroType.ENUM);
public AvroSchemaEnum() {
super(AvroSchemaType.ENUM);
}

public AvroEnum(
public AvroSchemaEnum(
@NotNull String name,
@Nullable String namespace,
@Nullable String doc,
Expand All @@ -34,7 +34,7 @@ public AvroEnum(
@Nullable Object defaultValue,
@Nullable Map<String, Object> metadata
) {
super(AvroType.ENUM);
super(AvroSchemaType.ENUM);

this.name = name;
this.namespace = namespace;
Expand All @@ -45,8 +45,8 @@ public AvroEnum(
this.metadata = metadata;
}

public AvroEnum(@NotNull Builder builder) {
super(AvroType.ENUM);
public AvroSchemaEnum(@NotNull Builder builder) {
super(AvroSchemaType.ENUM);

this.name = builder.name;
this.namespace = builder.namespace;
Expand Down Expand Up @@ -104,18 +104,18 @@ public AvroEnum(@NotNull Builder builder) {
@NotNull
@Override
public String getType() {
return AvroType.ENUM;
return AvroSchemaType.ENUM;
}

public void setType(@NotNull String type) {
super.setType(AvroType.ENUM);
super.setType(AvroSchemaType.ENUM);
}

public static Builder builder() {
return new Builder();
}

public static class Builder extends Avro.Builder<AvroEnum, Builder> {
public static class Builder extends AvroSchema.Builder<AvroSchemaEnum, Builder> {

@NotNull
private String name = "";
Expand Down Expand Up @@ -179,8 +179,8 @@ protected Builder getThis() {

@NotNull
@Override
public AvroEnum build() {
return new AvroEnum(this);
public AvroSchemaEnum build() {
return new AvroSchemaEnum(this);
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,20 @@
*/
@Data
@EqualsAndHashCode(callSuper = true)
public class AvroFixed extends Avro {
public class AvroSchemaFixed extends AvroSchema {

public AvroFixed() {
super(AvroType.FIXED);
public AvroSchemaFixed() {
super(AvroSchemaType.FIXED);
}

public AvroFixed(
public AvroSchemaFixed(
@NotNull String name,
@Nullable String namespace,
@Nullable List<@NotNull String> aliases,
@NotNull Integer size,
@Nullable Map<String, Object> metadata
) {
super(AvroType.FIXED);
super(AvroSchemaType.FIXED);

this.name = name;
this.namespace = namespace;
Expand All @@ -36,8 +36,8 @@ public AvroFixed(
this.metadata = metadata;
}

public AvroFixed(@NotNull Builder builder) {
super(AvroType.FIXED);
public AvroSchemaFixed(@NotNull Builder builder) {
super(AvroSchemaType.FIXED);

this.name = builder.name;
this.namespace = builder.namespace;
Expand Down Expand Up @@ -72,18 +72,18 @@ public AvroFixed(@NotNull Builder builder) {
@NotNull
@Override
public String getType() {
return AvroType.FIXED;
return AvroSchemaType.FIXED;
}

public void setType(@NotNull String type) {
super.setType(AvroType.FIXED);
super.setType(AvroSchemaType.FIXED);
}

public static Builder builder() {
return new Builder();
}

public static class Builder extends Avro.Builder<AvroFixed, Builder> {
public static class Builder extends AvroSchema.Builder<AvroSchemaFixed, Builder> {

@NotNull
private String name = "";
Expand Down Expand Up @@ -129,8 +129,8 @@ protected Builder getThis() {

@NotNull
@Override
public AvroFixed build() {
return new AvroFixed(this);
public AvroSchemaFixed build() {
return new AvroSchemaFixed(this);
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.SuperBuilder;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

Expand All @@ -17,32 +16,32 @@
*/
@Data
@EqualsAndHashCode(callSuper = true)
public class AvroMap extends Avro {
public class AvroSchemaMap extends AvroSchema {

public AvroMap() {
super(AvroType.MAP);
public AvroSchemaMap() {
super(AvroSchemaType.MAP);
}

public AvroMap(@NotNull Object values) {
super(AvroType.MAP);
public AvroSchemaMap(@NotNull Object values) {
super(AvroSchemaType.MAP);

this.values = values;
}

public AvroMap(
public AvroSchemaMap(
@NotNull Object values,
@Nullable Map<String, Object> defaultValue,
@Nullable Map<String, Object> metadata
) {
super(AvroType.MAP);
super(AvroSchemaType.MAP);

this.values = values;
this.defaultValue = defaultValue;
this.metadata = metadata;
}

public AvroMap(@NotNull Builder builder) {
super(AvroType.MAP);
public AvroSchemaMap(@NotNull Builder builder) {
super(AvroSchemaType.MAP);

this.values = builder.values;
this.defaultValue = builder.defaultValue;
Expand All @@ -61,18 +60,18 @@ public AvroMap(@NotNull Builder builder) {
@NotNull
@Override
public String getType() {
return AvroType.MAP;
return AvroSchemaType.MAP;
}

public void setType(@NotNull String type) {
super.setType(AvroType.MAP);
super.setType(AvroSchemaType.MAP);
}

public static Builder builder() {
return new Builder();
}

public static class Builder extends Avro.Builder<AvroMap, Builder> {
public static class Builder extends AvroSchema.Builder<AvroSchemaMap, Builder> {

@NotNull
private Object values = Collections.<String, Object>emptyMap();
Expand Down Expand Up @@ -100,8 +99,8 @@ protected Builder getThis() {

@NotNull
@Override
public AvroMap build() {
return new AvroMap(this);
public AvroSchemaMap build() {
return new AvroSchemaMap(this);
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@

@Data
@JsonIgnoreProperties({"metadata"})
public class AvroMetadata {
public class AvroSchemaMetadata {

public AvroMetadata() {}
public AvroSchemaMetadata() {}

public AvroMetadata(@Nullable Map<String, Object> metadata) {
public AvroSchemaMetadata(@Nullable Map<String, Object> metadata) {
this.metadata = metadata;
}

Expand Down
Loading

0 comments on commit 26a8d99

Please sign in to comment.