Browse Source
Previously, no configuration properties were discovered on a class using lombok instead of regular getters/setters. This commit adds a support for some of the lombok annotations, specifically that is @Data, @Getter and @Setter. Provides the same semantic as what lombok is generating. Closes gh-2114pull/2166/head
8 changed files with 286 additions and 12 deletions
@ -0,0 +1,59 @@
@@ -0,0 +1,59 @@
|
||||
/* |
||||
* Copyright 2012-2014 the original author or authors. |
||||
* |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
|
||||
package org.springframework.boot.configurationsample.lombok; |
||||
|
||||
import java.util.ArrayList; |
||||
import java.util.List; |
||||
|
||||
import lombok.Getter; |
||||
import lombok.Setter; |
||||
|
||||
import org.springframework.boot.configurationsample.ConfigurationProperties; |
||||
|
||||
/** |
||||
* Configuration properties using lombok @Getter/@Setter at field level. |
||||
* |
||||
* @author Stephane Nicoll |
||||
*/ |
||||
@ConfigurationProperties(prefix = "explicit") |
||||
public class LombokExplicitProperties { |
||||
|
||||
@Getter |
||||
private final String id = "super-id"; |
||||
|
||||
/** |
||||
* Name description. |
||||
*/ |
||||
@Getter @Setter |
||||
private String name; |
||||
|
||||
@Getter @Setter |
||||
private String description; |
||||
|
||||
@Getter @Setter |
||||
private Integer counter; |
||||
|
||||
@Deprecated @Getter @Setter |
||||
private Integer number = 0; |
||||
|
||||
@Getter |
||||
private final List<String> items = new ArrayList<String>(); |
||||
|
||||
// Should be ignored if no annotation is set
|
||||
private String ignored; |
||||
|
||||
} |
||||
@ -0,0 +1,53 @@
@@ -0,0 +1,53 @@
|
||||
/* |
||||
* Copyright 2012-2014 the original author or authors. |
||||
* |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
|
||||
package org.springframework.boot.configurationsample.lombok; |
||||
|
||||
import java.util.ArrayList; |
||||
import java.util.List; |
||||
|
||||
import lombok.Data; |
||||
|
||||
import org.springframework.boot.configurationsample.ConfigurationProperties; |
||||
|
||||
/** |
||||
* Configuration properties using lombok @Data. |
||||
* |
||||
* @author Stephane Nicoll |
||||
*/ |
||||
@Data |
||||
@ConfigurationProperties(prefix = "data") |
||||
public class LombokSimpleDataProperties { |
||||
|
||||
private final String id = "super-id"; |
||||
|
||||
/** |
||||
* Name description. |
||||
*/ |
||||
private String name; |
||||
|
||||
private String description; |
||||
|
||||
private Integer counter; |
||||
|
||||
@Deprecated |
||||
private Integer number = 0; |
||||
|
||||
private final List<String> items = new ArrayList<String>(); |
||||
|
||||
private final String ignored = "foo"; |
||||
|
||||
} |
||||
@ -0,0 +1,55 @@
@@ -0,0 +1,55 @@
|
||||
/* |
||||
* Copyright 2012-2014 the original author or authors. |
||||
* |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
|
||||
package org.springframework.boot.configurationsample.lombok; |
||||
|
||||
import java.util.ArrayList; |
||||
import java.util.List; |
||||
|
||||
import lombok.Getter; |
||||
import lombok.Setter; |
||||
|
||||
import org.springframework.boot.configurationsample.ConfigurationProperties; |
||||
|
||||
/** |
||||
* Configuration properties using lombok @Getter/@Setter at class level. |
||||
* |
||||
* @author Stephane Nicoll |
||||
*/ |
||||
@Getter |
||||
@Setter |
||||
@ConfigurationProperties(prefix = "simple") |
||||
public class LombokSimpleProperties { |
||||
|
||||
private final String id = "super-id"; |
||||
|
||||
/** |
||||
* Name description. |
||||
*/ |
||||
private String name; |
||||
|
||||
private String description; |
||||
|
||||
private Integer counter; |
||||
|
||||
@Deprecated |
||||
private Integer number = 0; |
||||
|
||||
private final List<String> items = new ArrayList<String>(); |
||||
|
||||
private final String ignored = "foo"; |
||||
|
||||
} |
||||
Loading…
Reference in new issue