Polish
This commit is contained in:
@@ -34,7 +34,7 @@ public class SampleProperties {
|
||||
private Integer port = 8080;
|
||||
|
||||
public String getHost() {
|
||||
return host;
|
||||
return this.host;
|
||||
}
|
||||
|
||||
public void setHost(String host) {
|
||||
@@ -42,10 +42,11 @@ public class SampleProperties {
|
||||
}
|
||||
|
||||
public Integer getPort() {
|
||||
return port;
|
||||
return this.port;
|
||||
}
|
||||
|
||||
public void setPort(Integer port) {
|
||||
this.port = port;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -35,10 +35,9 @@ public class SamplePropertiesValidator implements Validator {
|
||||
public void validate(Object o, Errors errors) {
|
||||
ValidationUtils.rejectIfEmpty(errors, "host", "host.empty");
|
||||
ValidationUtils.rejectIfEmpty(errors, "port", "port.empty");
|
||||
|
||||
SampleProperties properties = (SampleProperties) o;
|
||||
if (properties.getHost() != null &&
|
||||
!pattern.matcher(properties.getHost()).matches()) {
|
||||
if (properties.getHost() != null
|
||||
&& !this.pattern.matcher(properties.getHost()).matches()) {
|
||||
errors.rejectValue("host", "Invalid host");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,8 +52,8 @@ public class SamplePropertyValidationApplication {
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
new SpringApplicationBuilder(SamplePropertyValidationApplication.class)
|
||||
.profiles("app").run(args);
|
||||
new SpringApplicationBuilder(SamplePropertyValidationApplication.class).profiles(
|
||||
"app").run(args);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user