Is there a way to define avro schema file ( .avsc file ) that generates a POJO with a 'Set' member variable?

357 Views Asked by At

So I am using Apache Avro ( version 1.11.2 ) to serialize and deserialize data.

Here's how my POJO that I want to serialize looks like

@Data
@AllArgsConstructor
@NoArgsConstructor
public class MyPojo {
  private String param1;
  private String param2;
  private Set<myEnum> param3;
}

and my .avsc file that I should be defining ( as per I got suggestions online and from Chat - GPT, but none helping )

{
  "type": "record",
  "name": "MyPojo",
  "fields": [
    {
      "name": "param1",
      "type": "string"
    },
    {
      "name": "param2",
      "type": "string"
    },
    {
      "name": "param3",
      "type": {
        "type": "array",
        "items": "string",
        "java-class": "java.util.Set"
      }
    }
  ]
}

it's rather generating a Pojo class MyPojo.java with member variable with param3 as 'List' instead of 'Set'. Can anyone who is familiar with Avro please help me figure out how I may generate a Set instead?

tried using different .avsc ( e.g tried generating using union ) None helped.

0

There are 0 best solutions below