Commit 17329e95 authored by Michael's avatar Michael

implemented Lombok

parent 8a29b77f
package demo;
import java.util.List;
import java.util.Arrays;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;
import lombok.Data;
import lombok.ToString;
import org.springframework.boot.context.properties.ConfigurationProperties;
import javax.validation.constraints.Max;
@Data
@ToString(includeFieldNames = false)
@Component
@Configuration
@ConfigurationProperties("app")
public class Properties {
private Cache cache;
private Cors cors;
public Cache getCache() {
return cache;
}
public Cors getCors() {
return cors;
}
public void setCache(Cache cache) {
this.cache = cache;
}
public void setCors(Cors cors) {
this.cors = cors;
}
@Data
@ToString(includeFieldNames = false)
public static class Cache {
@Max(1000)
private Integer ttl;
@Max(3600)
private Long maxEntries;
public Integer getTtl() {
return ttl;
}
public Long getMaxEntries() {
return maxEntries;
}
public void setTtl(Integer ttl) {
this.ttl = ttl;
}
public void setMaxEntries(Long maxEntries) {
this.maxEntries = maxEntries;
}
@Override
public String toString() {
return "Cache{" +
"ttl=" + ttl +
", maxEntries=" + maxEntries +
'}';
}
}
@Data
@ToString(includeFieldNames = true)
public static class Cors {
private List<String> allowedOrigins;
private String[] allowedMethods;
private List<String> allowedHeaders;
private Boolean allowCredentials;
private Integer maxAge;
public List<String> getAllowedOrigins() {
return allowedOrigins;
}
public Boolean getAllowCredentials() {
return allowCredentials;
}
public List<String> getAllowedHeaders() {
return allowedHeaders;
}
public String[] getAllowedMethods() {
return allowedMethods;
}
public Integer getMaxAge() {
return maxAge;
}
public void setAllowCredentials(Boolean allowCredentials) {
this.allowCredentials = allowCredentials;
}
public void setAllowedHeaders(List<String> allowedHeaders) {
this.allowedHeaders = allowedHeaders;
}
public void setAllowedMethods(String[] allowedMethods) {
this.allowedMethods = allowedMethods;
}
public void setAllowedOrigins(List<String> allowedOrigins) {
this.allowedOrigins = allowedOrigins;
}
public void setMaxAge(Integer maxAge) {
this.maxAge = maxAge;
}
@Override
public String toString() {
return "Cors{" +
"allowedOrigins=" + allowedOrigins +
", allowedMethods=" + Arrays.toString(allowedMethods) +
", allowedHeaders=" + allowedHeaders +
", allowCredentials=" + allowCredentials +
", maxAge=" + maxAge +
'}';
}
}
@Override
public String toString() {
return "Properties{" +
"cache=" + cache +
", cors=" + cors +
'}';
}
}
\ No newline at end of file
......@@ -6,63 +6,21 @@ import java.util.List;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
import lombok.Data;
import lombok.ToString;
@Data
@ToString(includeFieldNames = false)
@Component
@ConfigurationProperties("server")
public class YamlProperties {
private String email;
private List<Cluster> cluster = new ArrayList<>();
@Data
@ToString(includeFieldNames = false)
public static class Cluster {
private String ip;
private String path;
public String getIp() {
return ip;
}
public void setIp(String ip) {
this.ip = ip;
}
public String getPath() {
return path;
}
public void setPath(String path) {
this.path = path;
}
@Override
public String toString() {
return "Cluster{" +
"ip='" + ip + '\'' +
", path='" + path + '\'' +
'}';
}
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public List<Cluster> getCluster() {
return cluster;
}
public void setCluster(List<Cluster> cluster) {
this.cluster = cluster;
}
@Override
public String toString() {
return "YamlProperties{" +
"email='" + email + '\'' +
", cluster=" + cluster +
'}';
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment