I have a spring configuration class containing an embedded List. The object contains specification of a delimited flat file.
I wish to have optional fields for precision and scale in the SchemaAttributes class for instances where type is decimalType. These fields are not relevant to any other datatype.
How do you implement a default value for instances where precision/scales values are not supplied?
@ConfigurationProperties(prefix = "source-parameters.file_schema")
@Configuration
public class FileSchema {
private List<SchemaAttributes> schema;
public FileSchema(List<SchemaAttributes> schema) {
this.schema = schema;
}
public FileSchema(){
}
public List<SchemaAttributes> getSchema() {
return schema;
}
public void setSchema(List<SchemaAttributes> schema) {
this.schema = schema;
}
public static class SchemaAttributes {
private String name;
private String type;
private Boolean nullable;
private int precision;
private int scale;
public SchemaAttributes(String name, String type, Boolean nullable) {
this.name = name;
this.type = type;
this.nullable = nullable;
this.precision = precision;
this.scale = scale;
}
public SchemaAttributes() {
}
// getters, setters
...
}