I'm creating a Spring JPA project with the following structure:
public class Pipeline {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private long id;
private String name;
private SourceConfig sourceConfig;
private SinkConfig sinkConfig;
...
...
}
public abstract class SourceConfig {
private long id;
private String name;
}
public abstract class SinkConfig {
private long id;
private String name;
}
public KafkaSourceConfig extends SourceConfig {
private String topic;
private String messageSchema;
}
public MysqlSourceConfig extends SourceConfig {
private String databaseName;
private String tableName;
}
Now when the client passes the following JSON, how would the program know which SourceConfig subclass to add to the Pipeline object?
{
"name": "mysql_to_bq_1",
"sourceConfig": {
"source": "MYSQL",
},
"sinkConfig": {
},
"createdBy": "paul"
}