It is about a Spring Boot application. I would like to check and inform the user at the beginning if someone configured false the Yaml file. I would like to ask some of you,
- is this the right way to implement it?
- is the
RuntimeExceptionthe correct choice? - did I use the
lombokannotation correctly?
Thank you
@Component
@ConfigurationProperties
@Data
@NoArgsConstructor
public class ApplicationProperties{
@Data
@NoArgsConstructor
public static class Something {
private String name;
@Setter(AccessLevel.NONE)
private int width;
@Setter(AccessLevel.NONE)
private int height;
public void setWidth(int width) throws Throwable {
if (0 > width || 100 < width) {
throw new RuntimeException("The width should be between 0 and 100.");
}
this.width = width;
}
public void setHeight(int height) throws Throwable {
if (0 > height || 250 < height) {
throw new RuntimeException("The height should be between 0 and 250.");
}
this.height = height;
}
}
}