Relocate projects to spring-boot-project
Move projects to better reflect the way that Spring Boot is released. The following projects are under `spring-boot-project`: - `spring-boot` - `spring-boot-autoconfigure` - `spring-boot-tools` - `spring-boot-starters` - `spring-boot-actuator` - `spring-boot-actuator-autoconfigure` - `spring-boot-test` - `spring-boot-test-autoconfigure` - `spring-boot-devtools` - `spring-boot-cli` - `spring-boot-docs` See gh-9316
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,91 @@
|
||||
/*
|
||||
* Copyright 2012-2017 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.configurationprocessor;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.annotation.processing.ProcessingEnvironment;
|
||||
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.TemporaryFolder;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
||||
/**
|
||||
* Tests for {@link MetadataStore}.
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
*/
|
||||
public class MetadataStoreTests {
|
||||
|
||||
@Rule
|
||||
public final TemporaryFolder temp = new TemporaryFolder();
|
||||
|
||||
private final MetadataStore metadataStore = new MetadataStore(
|
||||
mock(ProcessingEnvironment.class));
|
||||
|
||||
@Test
|
||||
public void additionalMetadataIsLocatedInMavenBuild() throws IOException {
|
||||
File app = this.temp.newFolder("app");
|
||||
File classesLocation = new File(app, "target/classes");
|
||||
File metaInf = new File(classesLocation, "META-INF");
|
||||
metaInf.mkdirs();
|
||||
File additionalMetadata = new File(metaInf,
|
||||
"additional-spring-configuration-metadata.json");
|
||||
additionalMetadata.createNewFile();
|
||||
assertThat(
|
||||
this.metadataStore.locateAdditionalMetadataFile(new File(classesLocation,
|
||||
"META-INF/additional-spring-configuration-metadata.json")))
|
||||
.isEqualTo(additionalMetadata);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void additionalMetadataIsLocatedInGradle3Build() throws IOException {
|
||||
File app = this.temp.newFolder("app");
|
||||
File classesLocation = new File(app, "build/classes/main");
|
||||
File resourcesLocation = new File(app, "build/resources/main");
|
||||
File metaInf = new File(resourcesLocation, "META-INF");
|
||||
metaInf.mkdirs();
|
||||
File additionalMetadata = new File(metaInf,
|
||||
"additional-spring-configuration-metadata.json");
|
||||
additionalMetadata.createNewFile();
|
||||
assertThat(
|
||||
this.metadataStore.locateAdditionalMetadataFile(new File(classesLocation,
|
||||
"META-INF/additional-spring-configuration-metadata.json")))
|
||||
.isEqualTo(additionalMetadata);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void additionalMetadataIsLocatedInGradle4Build() throws IOException {
|
||||
File app = this.temp.newFolder("app");
|
||||
File classesLocation = new File(app, "build/classes/java/main");
|
||||
File resourcesLocation = new File(app, "build/resources/main");
|
||||
File metaInf = new File(resourcesLocation, "META-INF");
|
||||
metaInf.mkdirs();
|
||||
File additionalMetadata = new File(metaInf,
|
||||
"additional-spring-configuration-metadata.json");
|
||||
additionalMetadata.createNewFile();
|
||||
assertThat(
|
||||
this.metadataStore.locateAdditionalMetadataFile(new File(classesLocation,
|
||||
"META-INF/additional-spring-configuration-metadata.json")))
|
||||
.isEqualTo(additionalMetadata);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,103 @@
|
||||
/*
|
||||
* Copyright 2012-2017 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.configurationprocessor;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.annotation.processing.SupportedAnnotationTypes;
|
||||
import javax.annotation.processing.SupportedSourceVersion;
|
||||
import javax.lang.model.SourceVersion;
|
||||
|
||||
import org.springframework.boot.configurationprocessor.metadata.ConfigurationMetadata;
|
||||
import org.springframework.boot.configurationprocessor.metadata.JsonMarshaller;
|
||||
|
||||
/**
|
||||
* Test {@link ConfigurationMetadataAnnotationProcessor}.
|
||||
*
|
||||
* @author Stephane Nicoll
|
||||
* @author Phillip Webb
|
||||
* @author Andy Wilkinson
|
||||
* @author Kris De Volder
|
||||
*/
|
||||
@SupportedAnnotationTypes({ "*" })
|
||||
@SupportedSourceVersion(SourceVersion.RELEASE_6)
|
||||
public class TestConfigurationMetadataAnnotationProcessor
|
||||
extends ConfigurationMetadataAnnotationProcessor {
|
||||
|
||||
static final String CONFIGURATION_PROPERTIES_ANNOTATION = "org.springframework.boot.configurationsample.ConfigurationProperties";
|
||||
|
||||
static final String NESTED_CONFIGURATION_PROPERTY_ANNOTATION = "org.springframework.boot.configurationsample.NestedConfigurationProperty";
|
||||
|
||||
static final String DEPRECATED_CONFIGURATION_PROPERTY_ANNOTATION = "org.springframework.boot.configurationsample.DeprecatedConfigurationProperty";
|
||||
|
||||
static final String ENDPOINT_ANNOTATION = "org.springframework.boot.configurationsample.Endpoint";
|
||||
|
||||
private ConfigurationMetadata metadata;
|
||||
|
||||
private final File outputLocation;
|
||||
|
||||
public TestConfigurationMetadataAnnotationProcessor(File outputLocation) {
|
||||
this.outputLocation = outputLocation;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String configurationPropertiesAnnotation() {
|
||||
return CONFIGURATION_PROPERTIES_ANNOTATION;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String nestedConfigurationPropertyAnnotation() {
|
||||
return NESTED_CONFIGURATION_PROPERTY_ANNOTATION;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String deprecatedConfigurationPropertyAnnotation() {
|
||||
return DEPRECATED_CONFIGURATION_PROPERTY_ANNOTATION;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String endpointAnnotation() {
|
||||
return ENDPOINT_ANNOTATION;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ConfigurationMetadata writeMetaData() throws Exception {
|
||||
super.writeMetaData();
|
||||
try {
|
||||
File metadataFile = new File(this.outputLocation,
|
||||
"META-INF/spring-configuration-metadata.json");
|
||||
if (metadataFile.isFile()) {
|
||||
this.metadata = new JsonMarshaller()
|
||||
.read(new FileInputStream(metadataFile));
|
||||
}
|
||||
else {
|
||||
this.metadata = new ConfigurationMetadata();
|
||||
}
|
||||
return this.metadata;
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw new RuntimeException("Failed to read metadata from disk", e);
|
||||
}
|
||||
}
|
||||
|
||||
public ConfigurationMetadata getMetadata() {
|
||||
return this.metadata;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,205 @@
|
||||
/*
|
||||
* Copyright 2012-2017 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.configurationprocessor;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileReader;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.StringReader;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.rules.TemporaryFolder;
|
||||
|
||||
import org.springframework.boot.configurationprocessor.metadata.ConfigurationMetadata;
|
||||
import org.springframework.boot.configurationsample.ConfigurationProperties;
|
||||
import org.springframework.boot.configurationsample.NestedConfigurationProperty;
|
||||
import org.springframework.boot.testsupport.compiler.TestCompiler;
|
||||
import org.springframework.boot.testsupport.compiler.TestCompiler.TestCompilationTask;
|
||||
import org.springframework.util.FileCopyUtils;
|
||||
import org.springframework.util.FileSystemUtils;
|
||||
|
||||
/**
|
||||
* A TestProject contains a copy of a subset of test sample code.
|
||||
* <p>
|
||||
* Why a copy? Because when doing incremental build testing, we need to make modifications
|
||||
* to the contents of the 'test project'. But we don't want to actually modify the
|
||||
* original content itself.
|
||||
*
|
||||
* @author Kris De Volder
|
||||
*/
|
||||
public class TestProject {
|
||||
|
||||
private static final Class<?>[] ALWAYS_INCLUDE = { ConfigurationProperties.class,
|
||||
NestedConfigurationProperty.class };
|
||||
|
||||
/**
|
||||
* Contains copies of the original source so we can modify it safely to test
|
||||
* incremental builds.
|
||||
*/
|
||||
private File sourceFolder;
|
||||
|
||||
private TestCompiler compiler;
|
||||
|
||||
private Set<File> sourceFiles = new LinkedHashSet<>();
|
||||
|
||||
public TestProject(TemporaryFolder tempFolder, Class<?>... classes)
|
||||
throws IOException {
|
||||
this.sourceFolder = tempFolder.newFolder();
|
||||
this.compiler = new TestCompiler(tempFolder) {
|
||||
@Override
|
||||
protected File getSourceFolder() {
|
||||
return TestProject.this.sourceFolder;
|
||||
}
|
||||
};
|
||||
Set<Class<?>> contents = new HashSet<>(Arrays.asList(classes));
|
||||
contents.addAll(Arrays.asList(ALWAYS_INCLUDE));
|
||||
copySources(contents);
|
||||
}
|
||||
|
||||
private void copySources(Set<Class<?>> contents) throws IOException {
|
||||
for (Class<?> type : contents) {
|
||||
copySources(type);
|
||||
}
|
||||
}
|
||||
|
||||
private void copySources(Class<?> type) throws IOException {
|
||||
File original = getOriginalSourceFile(type);
|
||||
File target = getSourceFile(type);
|
||||
target.getParentFile().mkdirs();
|
||||
FileCopyUtils.copy(original, target);
|
||||
this.sourceFiles.add(target);
|
||||
}
|
||||
|
||||
public File getSourceFile(Class<?> type) {
|
||||
return new File(this.sourceFolder, TestCompiler.sourcePathFor(type));
|
||||
}
|
||||
|
||||
public ConfigurationMetadata fullBuild() {
|
||||
TestConfigurationMetadataAnnotationProcessor processor = new TestConfigurationMetadataAnnotationProcessor(
|
||||
this.compiler.getOutputLocation());
|
||||
TestCompilationTask task = this.compiler.getTask(this.sourceFiles);
|
||||
deleteFolderContents(this.compiler.getOutputLocation());
|
||||
task.call(processor);
|
||||
return processor.getMetadata();
|
||||
}
|
||||
|
||||
public ConfigurationMetadata incrementalBuild(Class<?>... toRecompile) {
|
||||
TestConfigurationMetadataAnnotationProcessor processor = new TestConfigurationMetadataAnnotationProcessor(
|
||||
this.compiler.getOutputLocation());
|
||||
TestCompilationTask task = this.compiler.getTask(toRecompile);
|
||||
task.call(processor);
|
||||
return processor.getMetadata();
|
||||
}
|
||||
|
||||
private void deleteFolderContents(File outputFolder) {
|
||||
FileSystemUtils.deleteRecursively(outputFolder);
|
||||
outputFolder.mkdirs();
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve File relative to project's output folder.
|
||||
* @param relativePath the relative path
|
||||
* @return the output file
|
||||
*/
|
||||
public File getOutputFile(String relativePath) {
|
||||
Assert.assertFalse(new File(relativePath).isAbsolute());
|
||||
return new File(this.compiler.getOutputLocation(), relativePath);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add source code at the end of file, just before last '}'
|
||||
* @param target the target
|
||||
* @param snippetStream the snippet stream
|
||||
* @throws Exception if the source cannot be added
|
||||
*/
|
||||
public void addSourceCode(Class<?> target, InputStream snippetStream)
|
||||
throws Exception {
|
||||
File targetFile = getSourceFile(target);
|
||||
String contents = getContents(targetFile);
|
||||
int insertAt = contents.lastIndexOf('}');
|
||||
String additionalSource = FileCopyUtils
|
||||
.copyToString(new InputStreamReader(snippetStream));
|
||||
contents = contents.substring(0, insertAt) + additionalSource
|
||||
+ contents.substring(insertAt);
|
||||
putContents(targetFile, contents);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete source file for given class from project.
|
||||
* @param type the class to delete
|
||||
*/
|
||||
public void delete(Class<?> type) {
|
||||
File target = getSourceFile(type);
|
||||
target.delete();
|
||||
this.sourceFiles.remove(target);
|
||||
}
|
||||
|
||||
/**
|
||||
* Restore source code of given class to its original contents.
|
||||
* @param type the class to revert
|
||||
* @throws IOException on IO error
|
||||
*/
|
||||
public void revert(Class<?> type) throws IOException {
|
||||
Assert.assertTrue(getSourceFile(type).exists());
|
||||
copySources(type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add source code of given class to this project.
|
||||
* @param type the class to add
|
||||
* @throws IOException on IO error
|
||||
*/
|
||||
public void add(Class<?> type) throws IOException {
|
||||
Assert.assertFalse(getSourceFile(type).exists());
|
||||
copySources(type);
|
||||
}
|
||||
|
||||
public void replaceText(Class<?> type, String find, String replace) throws Exception {
|
||||
File target = getSourceFile(type);
|
||||
String contents = getContents(target);
|
||||
contents = contents.replace(find, replace);
|
||||
putContents(target, contents);
|
||||
}
|
||||
|
||||
/**
|
||||
* Find the 'original' source code for given test class. Clients or subclasses should
|
||||
* have no need to know about these. They should work only with the copied source
|
||||
* code.
|
||||
*/
|
||||
private File getOriginalSourceFile(Class<?> type) {
|
||||
return new File(TestCompiler.SOURCE_FOLDER, TestCompiler.sourcePathFor(type));
|
||||
}
|
||||
|
||||
private static void putContents(File targetFile, String contents)
|
||||
throws FileNotFoundException, IOException, UnsupportedEncodingException {
|
||||
FileCopyUtils.copy(new StringReader(contents), new FileWriter(targetFile));
|
||||
}
|
||||
|
||||
private static String getContents(File file) throws Exception {
|
||||
return FileCopyUtils.copyToString(new FileReader(file));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,132 @@
|
||||
/*
|
||||
* Copyright 2012-2017 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.configurationprocessor.fieldvalues;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.annotation.processing.AbstractProcessor;
|
||||
import javax.annotation.processing.ProcessingEnvironment;
|
||||
import javax.annotation.processing.RoundEnvironment;
|
||||
import javax.annotation.processing.SupportedAnnotationTypes;
|
||||
import javax.annotation.processing.SupportedSourceVersion;
|
||||
import javax.lang.model.SourceVersion;
|
||||
import javax.lang.model.element.Element;
|
||||
import javax.lang.model.element.TypeElement;
|
||||
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.TemporaryFolder;
|
||||
|
||||
import org.springframework.boot.configurationsample.fieldvalues.FieldValues;
|
||||
import org.springframework.boot.testsupport.compiler.TestCompiler;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* Abstract base class for {@link FieldValuesParser} tests.
|
||||
*
|
||||
* @author Phillip Webb
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
public abstract class AbstractFieldValuesProcessorTests {
|
||||
|
||||
@Rule
|
||||
public TemporaryFolder temporaryFolder = new TemporaryFolder();
|
||||
|
||||
protected abstract FieldValuesParser createProcessor(ProcessingEnvironment env);
|
||||
|
||||
@Test
|
||||
public void getFieldValues() throws Exception {
|
||||
TestProcessor processor = new TestProcessor();
|
||||
TestCompiler compiler = new TestCompiler(this.temporaryFolder);
|
||||
compiler.getTask(FieldValues.class).call(processor);
|
||||
Map<String, Object> values = processor.getValues();
|
||||
assertThat(values.get("string")).isEqualTo("1");
|
||||
assertThat(values.get("stringNone")).isNull();
|
||||
assertThat(values.get("stringConst")).isEqualTo("c");
|
||||
assertThat(values.get("bool")).isEqualTo(true);
|
||||
assertThat(values.get("boolNone")).isEqualTo(false);
|
||||
assertThat(values.get("boolConst")).isEqualTo(true);
|
||||
assertThat(values.get("boolObject")).isEqualTo(true);
|
||||
assertThat(values.get("boolObjectNone")).isNull();
|
||||
assertThat(values.get("boolObjectConst")).isEqualTo(true);
|
||||
assertThat(values.get("integer")).isEqualTo(1);
|
||||
assertThat(values.get("integerNone")).isEqualTo(0);
|
||||
assertThat(values.get("integerConst")).isEqualTo(2);
|
||||
assertThat(values.get("integerObject")).isEqualTo(3);
|
||||
assertThat(values.get("integerObjectNone")).isNull();
|
||||
assertThat(values.get("integerObjectConst")).isEqualTo(4);
|
||||
assertThat(values.get("charset")).isEqualTo("US-ASCII");
|
||||
assertThat(values.get("charsetConst")).isEqualTo("UTF-8");
|
||||
assertThat(values.get("mimeType")).isEqualTo("text/html");
|
||||
assertThat(values.get("mimeTypeConst")).isEqualTo("text/plain");
|
||||
assertThat(values.get("object")).isEqualTo(123);
|
||||
assertThat(values.get("objectNone")).isNull();
|
||||
assertThat(values.get("objectConst")).isEqualTo("c");
|
||||
assertThat(values.get("objectInstance")).isNull();
|
||||
assertThat(values.get("stringArray")).isEqualTo(new Object[] { "FOO", "BAR" });
|
||||
assertThat(values.get("stringArrayNone")).isNull();
|
||||
assertThat(values.get("stringEmptyArray")).isEqualTo(new Object[0]);
|
||||
assertThat(values.get("stringArrayConst")).isEqualTo(new Object[] { "OK", "KO" });
|
||||
assertThat(values.get("stringArrayConstElements"))
|
||||
.isEqualTo(new Object[] { "c" });
|
||||
assertThat(values.get("integerArray")).isEqualTo(new Object[] { 42, 24 });
|
||||
assertThat(values.get("unknownArray")).isNull();
|
||||
}
|
||||
|
||||
@SupportedAnnotationTypes({
|
||||
"org.springframework.boot.configurationsample.ConfigurationProperties" })
|
||||
@SupportedSourceVersion(SourceVersion.RELEASE_6)
|
||||
private class TestProcessor extends AbstractProcessor {
|
||||
|
||||
private FieldValuesParser processor;
|
||||
|
||||
private Map<String, Object> values = new HashMap<>();
|
||||
|
||||
@Override
|
||||
public synchronized void init(ProcessingEnvironment env) {
|
||||
this.processor = createProcessor(env);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean process(Set<? extends TypeElement> annotations,
|
||||
RoundEnvironment roundEnv) {
|
||||
for (TypeElement annotation : annotations) {
|
||||
for (Element element : roundEnv.getElementsAnnotatedWith(annotation)) {
|
||||
if (element instanceof TypeElement) {
|
||||
try {
|
||||
this.values.putAll(
|
||||
this.processor.getFieldValues((TypeElement) element));
|
||||
}
|
||||
catch (Exception ex) {
|
||||
throw new IllegalStateException(ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public Map<String, Object> getValues() {
|
||||
return this.values;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* 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.configurationprocessor.fieldvalues.javac;
|
||||
|
||||
import javax.annotation.processing.ProcessingEnvironment;
|
||||
|
||||
import org.springframework.boot.configurationprocessor.fieldvalues.AbstractFieldValuesProcessorTests;
|
||||
import org.springframework.boot.configurationprocessor.fieldvalues.FieldValuesParser;
|
||||
|
||||
import static org.junit.Assume.assumeNoException;
|
||||
|
||||
/**
|
||||
* Tests for {@link JavaCompilerFieldValuesParser}.
|
||||
*
|
||||
* @author Phillip Webb
|
||||
*/
|
||||
public class JavaCompilerFieldValuesProcessorTests
|
||||
extends AbstractFieldValuesProcessorTests {
|
||||
|
||||
@Override
|
||||
protected FieldValuesParser createProcessor(ProcessingEnvironment env) {
|
||||
try {
|
||||
return new JavaCompilerFieldValuesParser(env);
|
||||
}
|
||||
catch (Throwable ex) {
|
||||
assumeNoException(ex);
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
/*
|
||||
* Copyright 2012-2016 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.configurationprocessor.metadata;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* Tests for {@link ConfigurationMetadata}.
|
||||
*
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
public class ConfigurationMetadataTests {
|
||||
|
||||
@Test
|
||||
public void toDashedCaseCamelCase() {
|
||||
assertThat(toDashedCase("simpleCamelCase")).isEqualTo("simple-camel-case");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void toDashedCaseUpperCamelCaseSuffix() {
|
||||
assertThat(toDashedCase("myDLQ")).isEqualTo("my-d-l-q");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void toDashedCaseUpperCamelCaseMiddle() {
|
||||
assertThat(toDashedCase("someDLQKey")).isEqualTo("some-d-l-q-key");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void toDashedCaseWordsUnderscore() {
|
||||
assertThat(toDashedCase("Word_With_underscore"))
|
||||
.isEqualTo("word-with-underscore");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void toDashedCaseWordsSeveralUnderscores() {
|
||||
assertThat(toDashedCase("Word___With__underscore"))
|
||||
.isEqualTo("word---with--underscore");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void toDashedCaseLowerCaseUnderscore() {
|
||||
assertThat(toDashedCase("lower_underscore")).isEqualTo("lower-underscore");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void toDashedCaseUpperUnderscoreSuffix() {
|
||||
assertThat(toDashedCase("my_DLQ")).isEqualTo("my-d-l-q");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void toDashedCaseUpperUnderscoreMiddle() {
|
||||
assertThat(toDashedCase("some_DLQ_key")).isEqualTo("some-d-l-q-key");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void toDashedCaseMultipleUnderscores() {
|
||||
assertThat(toDashedCase("super___crazy")).isEqualTo("super---crazy");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void toDashedCaseLowercase() {
|
||||
assertThat(toDashedCase("lowercase")).isEqualTo("lowercase");
|
||||
}
|
||||
|
||||
private String toDashedCase(String name) {
|
||||
return ConfigurationMetadata.toDashedCase(name);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
/*
|
||||
* Copyright 2012-2017 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.configurationprocessor.metadata;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.InputStream;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* Tests for {@link JsonMarshaller}.
|
||||
*
|
||||
* @author Phillip Webb
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
public class JsonMarshallerTests {
|
||||
|
||||
@Test
|
||||
public void marshallAndUnmarshal() throws Exception {
|
||||
ConfigurationMetadata metadata = new ConfigurationMetadata();
|
||||
metadata.add(ItemMetadata.newProperty("a", "b", StringBuffer.class.getName(),
|
||||
InputStream.class.getName(), "sourceMethod", "desc", "x",
|
||||
new ItemDeprecation("Deprecation comment", "b.c.d")));
|
||||
metadata.add(ItemMetadata.newProperty("b.c.d", null, null, null, null, null, null,
|
||||
null));
|
||||
metadata.add(
|
||||
ItemMetadata.newProperty("c", null, null, null, null, null, 123, null));
|
||||
metadata.add(
|
||||
ItemMetadata.newProperty("d", null, null, null, null, null, true, null));
|
||||
metadata.add(ItemMetadata.newProperty("e", null, null, null, null, null,
|
||||
new String[] { "y", "n" }, null));
|
||||
metadata.add(ItemMetadata.newProperty("f", null, null, null, null, null,
|
||||
new Boolean[] { true, false }, null));
|
||||
metadata.add(ItemMetadata.newGroup("d", null, null, null));
|
||||
metadata.add(ItemHint.newHint("a.b"));
|
||||
metadata.add(ItemHint.newHint("c", new ItemHint.ValueHint(123, "hey"),
|
||||
new ItemHint.ValueHint(456, null)));
|
||||
metadata.add(new ItemHint("d", null,
|
||||
Arrays.asList(
|
||||
new ItemHint.ValueProvider("first",
|
||||
Collections.<String, Object>singletonMap("target",
|
||||
"foo")),
|
||||
new ItemHint.ValueProvider("second", null))));
|
||||
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
||||
JsonMarshaller marshaller = new JsonMarshaller();
|
||||
marshaller.write(metadata, outputStream);
|
||||
ConfigurationMetadata read = marshaller
|
||||
.read(new ByteArrayInputStream(outputStream.toByteArray()));
|
||||
assertThat(read).has(Metadata.withProperty("a.b", StringBuffer.class)
|
||||
.fromSource(InputStream.class).withDescription("desc")
|
||||
.withDefaultValue("x").withDeprecation("Deprecation comment", "b.c.d"));
|
||||
assertThat(read).has(Metadata.withProperty("b.c.d"));
|
||||
assertThat(read).has(Metadata.withProperty("c").withDefaultValue(123));
|
||||
assertThat(read).has(Metadata.withProperty("d").withDefaultValue(true));
|
||||
assertThat(read).has(
|
||||
Metadata.withProperty("e").withDefaultValue(new String[] { "y", "n" }));
|
||||
assertThat(read).has(Metadata.withProperty("f")
|
||||
.withDefaultValue(new Object[] { true, false }));
|
||||
assertThat(read).has(Metadata.withGroup("d"));
|
||||
assertThat(read).has(Metadata.withHint("a.b"));
|
||||
assertThat(read).has(
|
||||
Metadata.withHint("c").withValue(0, 123, "hey").withValue(1, 456, null));
|
||||
assertThat(read).has(Metadata.withHint("d").withProvider("first", "target", "foo")
|
||||
.withProvider("second"));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,429 @@
|
||||
/*
|
||||
* Copyright 2012-2017 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.configurationprocessor.metadata;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.assertj.core.api.Condition;
|
||||
import org.hamcrest.collection.IsMapContaining;
|
||||
|
||||
import org.springframework.boot.configurationprocessor.metadata.ItemMetadata.ItemType;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
/**
|
||||
* AssertJ {@link Condition} to help test {@link ConfigurationMetadata}.
|
||||
*
|
||||
* @author Phillip Webb
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
public final class Metadata {
|
||||
|
||||
private Metadata() {
|
||||
}
|
||||
|
||||
public static MetadataItemCondition withGroup(String name) {
|
||||
return new MetadataItemCondition(ItemType.GROUP, name);
|
||||
}
|
||||
|
||||
public static MetadataItemCondition withGroup(String name, Class<?> type) {
|
||||
return new MetadataItemCondition(ItemType.GROUP, name).ofType(type);
|
||||
}
|
||||
|
||||
public static MetadataItemCondition withGroup(String name, String type) {
|
||||
return new MetadataItemCondition(ItemType.GROUP, name).ofType(type);
|
||||
}
|
||||
|
||||
public static MetadataItemCondition withProperty(String name) {
|
||||
return new MetadataItemCondition(ItemType.PROPERTY, name);
|
||||
}
|
||||
|
||||
public static MetadataItemCondition withProperty(String name, Class<?> type) {
|
||||
return new MetadataItemCondition(ItemType.PROPERTY, name).ofType(type);
|
||||
}
|
||||
|
||||
public static MetadataItemCondition withProperty(String name, String type) {
|
||||
return new MetadataItemCondition(ItemType.PROPERTY, name).ofType(type);
|
||||
}
|
||||
|
||||
public static Metadata.MetadataItemCondition withEnabledFlag(String key) {
|
||||
return withProperty(key).ofType(Boolean.class);
|
||||
}
|
||||
|
||||
public static MetadataHintCondition withHint(String name) {
|
||||
return new MetadataHintCondition(name);
|
||||
}
|
||||
|
||||
public static class MetadataItemCondition extends Condition<ConfigurationMetadata> {
|
||||
|
||||
private final ItemType itemType;
|
||||
|
||||
private final String name;
|
||||
|
||||
private final String type;
|
||||
|
||||
private final Class<?> sourceType;
|
||||
|
||||
private final String sourceMethod;
|
||||
|
||||
private final String description;
|
||||
|
||||
private final Object defaultValue;
|
||||
|
||||
private final ItemDeprecation deprecation;
|
||||
|
||||
public MetadataItemCondition(ItemType itemType, String name) {
|
||||
this(itemType, name, null, null, null, null, null, null);
|
||||
}
|
||||
|
||||
public MetadataItemCondition(ItemType itemType, String name, String type,
|
||||
Class<?> sourceType, String sourceMethod, String description,
|
||||
Object defaultValue, ItemDeprecation deprecation) {
|
||||
this.itemType = itemType;
|
||||
this.name = name;
|
||||
this.type = type;
|
||||
this.sourceType = sourceType;
|
||||
this.sourceMethod = sourceMethod;
|
||||
this.description = description;
|
||||
this.defaultValue = defaultValue;
|
||||
this.deprecation = deprecation;
|
||||
describedAs(createDescription());
|
||||
}
|
||||
|
||||
private String createDescription() {
|
||||
StringBuilder description = new StringBuilder();
|
||||
description.append("an item named '" + this.name + "'");
|
||||
if (this.type != null) {
|
||||
description.append(" with dataType:").append(this.type);
|
||||
}
|
||||
if (this.sourceType != null) {
|
||||
description.append(" with sourceType:").append(this.sourceType);
|
||||
}
|
||||
if (this.sourceMethod != null) {
|
||||
description.append(" with sourceMethod:").append(this.sourceMethod);
|
||||
}
|
||||
if (this.defaultValue != null) {
|
||||
description.append(" with defaultValue:").append(this.defaultValue);
|
||||
}
|
||||
if (this.description != null) {
|
||||
description.append(" with description:").append(this.description);
|
||||
}
|
||||
if (this.deprecation != null) {
|
||||
description.append(" with deprecation:").append(this.deprecation);
|
||||
}
|
||||
return description.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(ConfigurationMetadata value) {
|
||||
ItemMetadata itemMetadata = getFirstItemWithName(value, this.name);
|
||||
if (itemMetadata == null) {
|
||||
return false;
|
||||
}
|
||||
if (this.type != null && !this.type.equals(itemMetadata.getType())) {
|
||||
return false;
|
||||
}
|
||||
if (this.sourceType != null
|
||||
&& !this.sourceType.getName().equals(itemMetadata.getSourceType())) {
|
||||
return false;
|
||||
}
|
||||
if (this.sourceMethod != null
|
||||
&& !this.sourceMethod.equals(itemMetadata.getSourceMethod())) {
|
||||
return false;
|
||||
}
|
||||
if (this.defaultValue != null && !ObjectUtils
|
||||
.nullSafeEquals(this.defaultValue, itemMetadata.getDefaultValue())) {
|
||||
return false;
|
||||
}
|
||||
if (this.defaultValue == null && itemMetadata.getDefaultValue() != null) {
|
||||
return false;
|
||||
}
|
||||
if (this.description != null
|
||||
&& !this.description.equals(itemMetadata.getDescription())) {
|
||||
return false;
|
||||
}
|
||||
if (this.deprecation == null && itemMetadata.getDeprecation() != null) {
|
||||
return false;
|
||||
}
|
||||
if (this.deprecation != null
|
||||
&& !this.deprecation.equals(itemMetadata.getDeprecation())) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public MetadataItemCondition ofType(Class<?> dataType) {
|
||||
return new MetadataItemCondition(this.itemType, this.name, dataType.getName(),
|
||||
this.sourceType, this.sourceMethod, this.description,
|
||||
this.defaultValue, this.deprecation);
|
||||
}
|
||||
|
||||
public MetadataItemCondition ofType(String dataType) {
|
||||
return new MetadataItemCondition(this.itemType, this.name, dataType,
|
||||
this.sourceType, this.sourceMethod, this.description,
|
||||
this.defaultValue, this.deprecation);
|
||||
}
|
||||
|
||||
public MetadataItemCondition fromSource(Class<?> sourceType) {
|
||||
return new MetadataItemCondition(this.itemType, this.name, this.type,
|
||||
sourceType, this.sourceMethod, this.description, this.defaultValue,
|
||||
this.deprecation);
|
||||
}
|
||||
|
||||
public MetadataItemCondition fromSourceMethod(String sourceMethod) {
|
||||
return new MetadataItemCondition(this.itemType, this.name, this.type,
|
||||
this.sourceType, sourceMethod, this.description, this.defaultValue,
|
||||
this.deprecation);
|
||||
}
|
||||
|
||||
public MetadataItemCondition withDescription(String description) {
|
||||
return new MetadataItemCondition(this.itemType, this.name, this.type,
|
||||
this.sourceType, this.sourceMethod, description, this.defaultValue,
|
||||
this.deprecation);
|
||||
}
|
||||
|
||||
public MetadataItemCondition withDefaultValue(Object defaultValue) {
|
||||
return new MetadataItemCondition(this.itemType, this.name, this.type,
|
||||
this.sourceType, this.sourceMethod, this.description, defaultValue,
|
||||
this.deprecation);
|
||||
}
|
||||
|
||||
public MetadataItemCondition withDeprecation(String reason, String replacement) {
|
||||
return withDeprecation(reason, replacement, null);
|
||||
}
|
||||
|
||||
public MetadataItemCondition withDeprecation(String reason, String replacement,
|
||||
String level) {
|
||||
return new MetadataItemCondition(this.itemType, this.name, this.type,
|
||||
this.sourceType, this.sourceMethod, this.description,
|
||||
this.defaultValue, new ItemDeprecation(reason, replacement, level));
|
||||
}
|
||||
|
||||
public MetadataItemCondition withNoDeprecation() {
|
||||
return new MetadataItemCondition(this.itemType, this.name, this.type,
|
||||
this.sourceType, this.sourceMethod, this.description,
|
||||
this.defaultValue, null);
|
||||
}
|
||||
|
||||
private ItemMetadata getFirstItemWithName(ConfigurationMetadata metadata,
|
||||
String name) {
|
||||
for (ItemMetadata item : metadata.getItems()) {
|
||||
if (item.isOfItemType(this.itemType) && name.equals(item.getName())) {
|
||||
return item;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static class MetadataHintCondition extends Condition<ConfigurationMetadata> {
|
||||
|
||||
private final String name;
|
||||
|
||||
private final List<ItemHintValueCondition> valueConditions;
|
||||
|
||||
private final List<ItemHintProviderCondition> providerConditions;
|
||||
|
||||
public MetadataHintCondition(String name) {
|
||||
this.name = name;
|
||||
this.valueConditions = Collections.emptyList();
|
||||
this.providerConditions = Collections.emptyList();
|
||||
}
|
||||
|
||||
public MetadataHintCondition(String name,
|
||||
List<ItemHintValueCondition> valueConditions,
|
||||
List<ItemHintProviderCondition> providerConditions) {
|
||||
this.name = name;
|
||||
this.valueConditions = valueConditions;
|
||||
this.providerConditions = providerConditions;
|
||||
describedAs(createDescription());
|
||||
}
|
||||
|
||||
private String createDescription() {
|
||||
StringBuilder description = new StringBuilder();
|
||||
description.append("a hints name '" + this.name + "'");
|
||||
if (!this.valueConditions.isEmpty()) {
|
||||
description.append(" with values:").append(this.valueConditions);
|
||||
}
|
||||
if (!this.providerConditions.isEmpty()) {
|
||||
description.append(" with providers:").append(this.providerConditions);
|
||||
}
|
||||
return description.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(ConfigurationMetadata metadata) {
|
||||
ItemHint itemHint = getFirstHintWithName(metadata, this.name);
|
||||
if (itemHint == null) {
|
||||
return false;
|
||||
}
|
||||
return matches(itemHint, this.valueConditions)
|
||||
&& matches(itemHint, this.providerConditions);
|
||||
}
|
||||
|
||||
private boolean matches(ItemHint itemHint,
|
||||
List<? extends Condition<ItemHint>> conditions) {
|
||||
for (Condition<ItemHint> condition : conditions) {
|
||||
if (!condition.matches(itemHint)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private ItemHint getFirstHintWithName(ConfigurationMetadata metadata,
|
||||
String name) {
|
||||
for (ItemHint hint : metadata.getHints()) {
|
||||
if (name.equals(hint.getName())) {
|
||||
return hint;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public MetadataHintCondition withValue(int index, Object value,
|
||||
String description) {
|
||||
return new MetadataHintCondition(this.name,
|
||||
add(this.valueConditions,
|
||||
new ItemHintValueCondition(index, value, description)),
|
||||
this.providerConditions);
|
||||
}
|
||||
|
||||
public MetadataHintCondition withProvider(String provider) {
|
||||
return withProvider(this.providerConditions.size(), provider, null);
|
||||
}
|
||||
|
||||
public MetadataHintCondition withProvider(String provider, String key,
|
||||
Object value) {
|
||||
return withProvider(this.providerConditions.size(), provider,
|
||||
Collections.singletonMap(key, value));
|
||||
}
|
||||
|
||||
public MetadataHintCondition withProvider(int index, String provider,
|
||||
Map<String, Object> parameters) {
|
||||
return new MetadataHintCondition(this.name, this.valueConditions,
|
||||
add(this.providerConditions,
|
||||
new ItemHintProviderCondition(index, provider, parameters)));
|
||||
}
|
||||
|
||||
private <T> List<T> add(List<T> items, T item) {
|
||||
List<T> result = new ArrayList<>(items);
|
||||
result.add(item);
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static class ItemHintValueCondition extends Condition<ItemHint> {
|
||||
|
||||
private final int index;
|
||||
|
||||
private final Object value;
|
||||
|
||||
private final String description;
|
||||
|
||||
ItemHintValueCondition(int index, Object value, String description) {
|
||||
this.index = index;
|
||||
this.value = value;
|
||||
this.description = description;
|
||||
describedAs(createDescription());
|
||||
}
|
||||
|
||||
private String createDescription() {
|
||||
StringBuilder description = new StringBuilder();
|
||||
description.append("value hint at index '" + this.index + "'");
|
||||
if (this.value != null) {
|
||||
description.append(" with value:").append(this.value);
|
||||
}
|
||||
if (this.description != null) {
|
||||
description.append(" with description:").append(this.description);
|
||||
}
|
||||
return description.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(ItemHint value) {
|
||||
if (this.index + 1 > value.getValues().size()) {
|
||||
return false;
|
||||
}
|
||||
ItemHint.ValueHint valueHint = value.getValues().get(this.index);
|
||||
if (this.value != null && !this.value.equals(valueHint.getValue())) {
|
||||
return false;
|
||||
}
|
||||
if (this.description != null
|
||||
&& !this.description.equals(valueHint.getDescription())) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static class ItemHintProviderCondition extends Condition<ItemHint> {
|
||||
|
||||
private final int index;
|
||||
|
||||
private final String name;
|
||||
|
||||
private final Map<String, Object> parameters;
|
||||
|
||||
ItemHintProviderCondition(int index, String name,
|
||||
Map<String, Object> parameters) {
|
||||
this.index = index;
|
||||
this.name = name;
|
||||
this.parameters = parameters;
|
||||
describedAs(createDescription());
|
||||
}
|
||||
|
||||
public String createDescription() {
|
||||
StringBuilder description = new StringBuilder();
|
||||
description.append("value provider");
|
||||
if (this.name != null) {
|
||||
description.append(" with name:").append(this.name);
|
||||
}
|
||||
if (this.parameters != null) {
|
||||
description.append(" with parameters:").append(this.parameters);
|
||||
}
|
||||
return description.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(ItemHint hint) {
|
||||
if (this.index + 1 > hint.getProviders().size()) {
|
||||
return false;
|
||||
}
|
||||
ItemHint.ValueProvider valueProvider = hint.getProviders().get(this.index);
|
||||
if (this.name != null && !this.name.equals(valueProvider.getName())) {
|
||||
return false;
|
||||
}
|
||||
if (this.parameters != null) {
|
||||
for (Map.Entry<String, Object> entry : this.parameters.entrySet()) {
|
||||
if (!IsMapContaining.hasEntry(entry.getKey(), entry.getValue())
|
||||
.matches(valueProvider.getParameters())) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Copyright 2012-2017 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.configurationprocessor.metadata;
|
||||
|
||||
/**
|
||||
* {@link JsonConverter} for use in tests.
|
||||
*
|
||||
* @author Phillip Webb
|
||||
*/
|
||||
public class TestJsonConverter extends JsonConverter {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
import java.lang.annotation.Documented;
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* Alternative to Spring Boot's {@code @ConfigurationProperties} for testing (removes the
|
||||
* need for a dependency on the real annotation).
|
||||
*
|
||||
* @author Stephane Nicoll
|
||||
* @author Phillip Webb
|
||||
*/
|
||||
@Target({ ElementType.TYPE, ElementType.METHOD })
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Documented
|
||||
public @interface ConfigurationProperties {
|
||||
|
||||
String value() default "";
|
||||
|
||||
String prefix() default "";
|
||||
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
/*
|
||||
* Copyright 2012-2017 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;
|
||||
|
||||
public enum DefaultEnablement {
|
||||
|
||||
ENABLED, DISABLED, NEUTRAL
|
||||
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* Copyright 2012-2015 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;
|
||||
|
||||
import java.lang.annotation.Documented;
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* Indicates that a getter in a {@link ConfigurationProperties} object is deprecated. This
|
||||
* annotation has no bearing on the actual binding processes, but it is used by the
|
||||
* {@code spring-boot-configuration-processor} to add deprecation meta-data.
|
||||
* <p>
|
||||
* This annotation <strong>must</strong> be used on the getter of the deprecated element.
|
||||
*
|
||||
* @author Phillip Webb
|
||||
* @since 1.3.0
|
||||
*/
|
||||
@Target(ElementType.METHOD)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Documented
|
||||
public @interface DeprecatedConfigurationProperty {
|
||||
|
||||
/**
|
||||
* The reason for the deprecation.
|
||||
* @return the deprecation reason
|
||||
*/
|
||||
String reason() default "";
|
||||
|
||||
/**
|
||||
* The field that should be used instead (if any).
|
||||
* @return the replacement field
|
||||
*/
|
||||
String replacement() default "";
|
||||
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Copyright 2012-2017 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;
|
||||
|
||||
import java.lang.annotation.Documented;
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* Alternative to Spring Boot's {@code @Endpoint} for testing (removes the need for a
|
||||
* dependency on the real annotation).
|
||||
*
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
@Target(ElementType.TYPE)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Documented
|
||||
public @interface Endpoint {
|
||||
|
||||
String id();
|
||||
|
||||
DefaultEnablement defaultEnablement() default DefaultEnablement.NEUTRAL;
|
||||
|
||||
EndpointExposure[] exposure() default {};
|
||||
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
* Copyright 2012-2017 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;
|
||||
|
||||
public enum EndpointExposure {
|
||||
|
||||
JMX,
|
||||
|
||||
WEB
|
||||
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
import java.lang.annotation.Documented;
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* Alternative to Spring Boot's {@code @NestedConfigurationProperty} for testing (removes
|
||||
* the need for a dependency on the real annotation).
|
||||
*
|
||||
* @author Stephane Nicoll
|
||||
* @author Phillip Webb
|
||||
* @since 1.2.0
|
||||
*/
|
||||
@Target(ElementType.FIELD)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Documented
|
||||
public @interface NestedConfigurationProperty {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Copyright 2012-2017 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.endpoint;
|
||||
|
||||
import org.springframework.boot.configurationsample.ConfigurationProperties;
|
||||
import org.springframework.boot.configurationsample.Endpoint;
|
||||
|
||||
/**
|
||||
* An endpoint with additional custom properties.
|
||||
*
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
@Endpoint(id = "customprops")
|
||||
@ConfigurationProperties("endpoints.customprops")
|
||||
public class CustomPropertiesEndpoint {
|
||||
|
||||
private String name = "test";
|
||||
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Copyright 2012-2017 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.endpoint;
|
||||
|
||||
import org.springframework.boot.configurationsample.DefaultEnablement;
|
||||
import org.springframework.boot.configurationsample.Endpoint;
|
||||
|
||||
/**
|
||||
* An endpoint that is disabled unless configured explicitly.
|
||||
*
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
@Endpoint(id = "disabled", defaultEnablement = DefaultEnablement.DISABLED)
|
||||
public class DisabledEndpoint {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Copyright 2012-2017 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.endpoint;
|
||||
|
||||
import org.springframework.boot.configurationsample.DefaultEnablement;
|
||||
import org.springframework.boot.configurationsample.Endpoint;
|
||||
|
||||
/**
|
||||
* An endpoint that is enabled unless configured explicitly..
|
||||
*
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
@Endpoint(id = "enabled", defaultEnablement = DefaultEnablement.ENABLED)
|
||||
public class EnabledEndpoint {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Copyright 2012-2017 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.endpoint;
|
||||
|
||||
import org.springframework.boot.configurationsample.Endpoint;
|
||||
import org.springframework.boot.configurationsample.EndpointExposure;
|
||||
|
||||
/**
|
||||
* An endpoint that only exposes a JMX MBean.
|
||||
*
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
@Endpoint(id = "jmx", exposure = EndpointExposure.JMX)
|
||||
public class OnlyJmxEndpoint {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Copyright 2012-2017 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.endpoint;
|
||||
|
||||
import org.springframework.boot.configurationsample.Endpoint;
|
||||
import org.springframework.boot.configurationsample.EndpointExposure;
|
||||
|
||||
/**
|
||||
* An endpoints that only exposes a web endpoint.
|
||||
*
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
@Endpoint(id = "web", exposure = EndpointExposure.WEB)
|
||||
public class OnlyWebEndpoint {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* Copyright 2012-2017 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.endpoint;
|
||||
|
||||
import org.springframework.boot.configurationsample.Endpoint;
|
||||
|
||||
/**
|
||||
* A simple endpoint with no default override.
|
||||
*
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
@Endpoint(id = "simple")
|
||||
public class SimpleEndpoint {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* Copyright 2012-2017 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.endpoint.incremental;
|
||||
|
||||
import org.springframework.boot.configurationsample.Endpoint;
|
||||
|
||||
/**
|
||||
* An endpoint that is enabled by default.
|
||||
*
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
@Endpoint(id = "incremental")
|
||||
public class IncrementalEndpoint {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Copyright 2012-2017 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.endpoint.incremental;
|
||||
|
||||
import org.springframework.boot.configurationsample.Endpoint;
|
||||
import org.springframework.boot.configurationsample.EndpointExposure;
|
||||
|
||||
/**
|
||||
* An endpoint that only exposes a JMX MBean.
|
||||
*
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
@Endpoint(id = "incremental", exposure = EndpointExposure.JMX)
|
||||
public class IncrementalJmxEndpoint {
|
||||
|
||||
}
|
||||
Binary file not shown.
@@ -0,0 +1,110 @@
|
||||
/*
|
||||
* Copyright 2012-2015 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.fieldvalues;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
|
||||
import org.springframework.boot.configurationsample.ConfigurationProperties;
|
||||
import org.springframework.util.MimeType;
|
||||
|
||||
/**
|
||||
* Sample object containing fields with initial values.
|
||||
*
|
||||
* @author Phillip Webb
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
@ConfigurationProperties
|
||||
public class FieldValues {
|
||||
|
||||
private static final String STRING_CONST = "c";
|
||||
|
||||
private static final boolean BOOLEAN_CONST = true;
|
||||
|
||||
private static final Boolean BOOLEAN_OBJ_CONST = true;
|
||||
|
||||
private static final int INTEGER_CONST = 2;
|
||||
|
||||
private static final Integer INTEGER_OBJ_CONST = 4;
|
||||
|
||||
private static final Charset DEFAULT_CHARSET = Charset.forName("UTF-8");
|
||||
|
||||
private static final MimeType DEFAULT_MIME_TYPE = MimeType.valueOf("text/plain");
|
||||
|
||||
private static final String[] STRING_ARRAY_CONST = new String[] { "OK", "KO" };
|
||||
|
||||
private String string = "1";
|
||||
|
||||
private String stringNone;
|
||||
|
||||
private String stringConst = STRING_CONST;
|
||||
|
||||
private boolean bool = true;
|
||||
|
||||
private boolean boolNone;
|
||||
|
||||
private boolean boolConst = BOOLEAN_CONST;
|
||||
|
||||
private Boolean boolObject = Boolean.TRUE;
|
||||
|
||||
private Boolean boolObjectNone;
|
||||
|
||||
private Boolean boolObjectConst = BOOLEAN_OBJ_CONST;
|
||||
|
||||
private int integer = 1;
|
||||
|
||||
private int integerNone;
|
||||
|
||||
private int integerConst = INTEGER_CONST;
|
||||
|
||||
private Integer integerObject = 3;
|
||||
|
||||
private Integer integerObjectNone;
|
||||
|
||||
private Integer integerObjectConst = INTEGER_OBJ_CONST;
|
||||
|
||||
private Charset charset = Charset.forName("US-ASCII");
|
||||
|
||||
private Charset charsetConst = DEFAULT_CHARSET;
|
||||
|
||||
private MimeType mimeType = MimeType.valueOf("text/html");
|
||||
|
||||
private MimeType mimeTypeConst = DEFAULT_MIME_TYPE;
|
||||
|
||||
private Object object = 123;
|
||||
|
||||
private Object objectNone;
|
||||
|
||||
private Object objectConst = STRING_CONST;
|
||||
|
||||
private Object objectInstance = new StringBuffer();
|
||||
|
||||
private String[] stringArray = new String[] { "FOO", "BAR" };
|
||||
|
||||
private String[] stringArrayNone;
|
||||
|
||||
private String[] stringEmptyArray = new String[0];
|
||||
|
||||
private String[] stringArrayConst = STRING_ARRAY_CONST;
|
||||
|
||||
private String[] stringArrayConstElements = new String[] { STRING_CONST };
|
||||
|
||||
private Integer[] integerArray = new Integer[] { 42, 24 };
|
||||
|
||||
private FieldValues[] unknownArray = new FieldValues[] { new FieldValues() };
|
||||
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* Copyright 2012-2016 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.incremental;
|
||||
|
||||
import org.springframework.boot.configurationsample.ConfigurationProperties;
|
||||
|
||||
@ConfigurationProperties("bar")
|
||||
public class BarProperties {
|
||||
|
||||
private String name;
|
||||
|
||||
private String description;
|
||||
|
||||
/**
|
||||
* A nice counter description.
|
||||
*/
|
||||
private Integer counter = 0;
|
||||
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return this.description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public Integer getCounter() {
|
||||
return this.counter;
|
||||
}
|
||||
|
||||
public void setCounter(Integer counter) {
|
||||
this.counter = counter;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* Copyright 2012-2015 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.incremental;
|
||||
|
||||
import org.springframework.boot.configurationsample.ConfigurationProperties;
|
||||
|
||||
@ConfigurationProperties("foo")
|
||||
public class FooProperties {
|
||||
|
||||
private String name;
|
||||
|
||||
private String description;
|
||||
|
||||
/**
|
||||
* A nice counter description.
|
||||
*/
|
||||
private Integer counter = 0;
|
||||
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return this.description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public Integer getCounter() {
|
||||
return this.counter;
|
||||
}
|
||||
|
||||
public void setCounter(Integer counter) {
|
||||
this.counter = counter;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* Copyright 2012-2016 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.incremental;
|
||||
|
||||
import org.springframework.boot.configurationsample.ConfigurationProperties;
|
||||
|
||||
@ConfigurationProperties("bar")
|
||||
public class RenamedBarProperties {
|
||||
|
||||
private String name;
|
||||
|
||||
private String description;
|
||||
|
||||
/**
|
||||
* A nice counter description.
|
||||
*/
|
||||
private Integer counter = 0;
|
||||
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return this.description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public Integer getCounter() {
|
||||
return this.counter;
|
||||
}
|
||||
|
||||
public void setCounter(Integer counter) {
|
||||
this.counter = counter;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* Copyright 2012-2017 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<>();
|
||||
|
||||
// Should be ignored if no annotation is set
|
||||
@SuppressWarnings("unused")
|
||||
private String ignored;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* Copyright 2012-2016 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 lombok.Data;
|
||||
|
||||
import org.springframework.boot.configurationsample.ConfigurationProperties;
|
||||
import org.springframework.boot.configurationsample.NestedConfigurationProperty;
|
||||
|
||||
/**
|
||||
* Demonstrate the auto-detection of inner config classes using Lombok.
|
||||
*
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
@Data
|
||||
@ConfigurationProperties(prefix = "config")
|
||||
@SuppressWarnings("unused")
|
||||
public class LombokInnerClassProperties {
|
||||
|
||||
private final Foo first = new Foo();
|
||||
|
||||
private Foo second = new Foo();
|
||||
|
||||
@NestedConfigurationProperty
|
||||
private final SimpleLombokPojo third = new SimpleLombokPojo();
|
||||
|
||||
private Fourth fourth;
|
||||
|
||||
@Data
|
||||
public static class Foo {
|
||||
|
||||
private String name;
|
||||
|
||||
private final Bar bar = new Bar();
|
||||
|
||||
@Data
|
||||
public static class Bar {
|
||||
|
||||
private String name;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public enum Fourth {
|
||||
|
||||
YES, NO
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Copyright 2012-2017 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 lombok.Data;
|
||||
|
||||
import org.springframework.boot.configurationsample.ConfigurationProperties;
|
||||
|
||||
@Data
|
||||
@ConfigurationProperties(prefix = "config")
|
||||
@SuppressWarnings("unused")
|
||||
public class LombokInnerClassWithGetterProperties {
|
||||
|
||||
private final Foo first = new Foo();
|
||||
|
||||
public Foo getFirst() {
|
||||
return this.first;
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class Foo {
|
||||
|
||||
private String name;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* Copyright 2012-2017 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")
|
||||
@SuppressWarnings("unused")
|
||||
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<>();
|
||||
|
||||
private final String ignored = "foo";
|
||||
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* Copyright 2012-2017 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")
|
||||
@SuppressWarnings("unused")
|
||||
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<>();
|
||||
|
||||
private final String ignored = "foo";
|
||||
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Copyright 2012-2015 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 lombok.Data;
|
||||
|
||||
/**
|
||||
* Lombok POJO for use with samples.
|
||||
*
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
@Data
|
||||
@SuppressWarnings("unused")
|
||||
public class SimpleLombokPojo {
|
||||
|
||||
private int value;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* Copyright 2012-2016 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.method;
|
||||
|
||||
import org.springframework.boot.configurationsample.ConfigurationProperties;
|
||||
|
||||
/**
|
||||
* Sample for testing method configuration with deprecated class.
|
||||
*
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
@Deprecated
|
||||
public class DeprecatedClassMethodConfig {
|
||||
|
||||
@ConfigurationProperties(prefix = "foo")
|
||||
public Foo foo() {
|
||||
return new Foo();
|
||||
}
|
||||
|
||||
public static class Foo {
|
||||
|
||||
private String name;
|
||||
|
||||
private boolean flag;
|
||||
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public boolean isFlag() {
|
||||
return this.flag;
|
||||
}
|
||||
|
||||
public void setFlag(boolean flag) {
|
||||
this.flag = flag;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* Copyright 2012-2016 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.method;
|
||||
|
||||
import org.springframework.boot.configurationsample.ConfigurationProperties;
|
||||
|
||||
/**
|
||||
* Sample for testing deprecated method configuration.
|
||||
*
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
public class DeprecatedMethodConfig {
|
||||
|
||||
@ConfigurationProperties(prefix = "foo")
|
||||
@Deprecated
|
||||
public Foo foo() {
|
||||
return new Foo();
|
||||
}
|
||||
|
||||
public static class Foo {
|
||||
|
||||
private String name;
|
||||
|
||||
private boolean flag;
|
||||
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public boolean isFlag() {
|
||||
return this.flag;
|
||||
}
|
||||
|
||||
public void setFlag(boolean flag) {
|
||||
this.flag = flag;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* 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.method;
|
||||
|
||||
import org.springframework.boot.configurationsample.ConfigurationProperties;
|
||||
|
||||
/**
|
||||
* Sample for testing method configuration.
|
||||
*
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
@ConfigurationProperties("something")
|
||||
public class EmptyTypeMethodConfig {
|
||||
|
||||
private String name;
|
||||
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@ConfigurationProperties("something")
|
||||
public Foo foo() {
|
||||
return new Foo();
|
||||
}
|
||||
|
||||
public static class Foo {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* 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.method;
|
||||
|
||||
import org.springframework.boot.configurationsample.ConfigurationProperties;
|
||||
|
||||
/**
|
||||
* Sample for testing invalid method configuration.
|
||||
*
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
@ConfigurationProperties(prefix = "something")
|
||||
public class InvalidMethodConfig {
|
||||
|
||||
private String name;
|
||||
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@ConfigurationProperties(prefix = "invalid")
|
||||
InvalidMethodConfig foo() {
|
||||
return new InvalidMethodConfig();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
* Copyright 2012-2016 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.method;
|
||||
|
||||
import org.springframework.boot.configurationsample.ConfigurationProperties;
|
||||
|
||||
/**
|
||||
* Sample for testing mixed method and class configuration.
|
||||
*
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
@ConfigurationProperties("conflict")
|
||||
public class MethodAndClassConfig {
|
||||
|
||||
private String value;
|
||||
|
||||
public String getValue() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@ConfigurationProperties(prefix = "conflict")
|
||||
public Foo foo() {
|
||||
return new Foo();
|
||||
}
|
||||
|
||||
public static class Foo {
|
||||
|
||||
private String name;
|
||||
|
||||
private boolean flag;
|
||||
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public boolean isFlag() {
|
||||
return this.flag;
|
||||
}
|
||||
|
||||
public void setFlag(boolean flag) {
|
||||
this.flag = flag;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* Copyright 2012-2016 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.method;
|
||||
|
||||
import org.springframework.boot.configurationsample.ConfigurationProperties;
|
||||
|
||||
/**
|
||||
* Sample for testing simple method configuration.
|
||||
*
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
public class SimpleMethodConfig {
|
||||
|
||||
@ConfigurationProperties(prefix = "foo")
|
||||
public Foo foo() {
|
||||
return new Foo();
|
||||
}
|
||||
|
||||
public static class Foo {
|
||||
|
||||
private String name;
|
||||
|
||||
private boolean flag;
|
||||
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public boolean isFlag() {
|
||||
return this.flag;
|
||||
}
|
||||
|
||||
public void setFlag(boolean flag) {
|
||||
this.flag = flag;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* Copyright 2012-2016 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.simple;
|
||||
|
||||
import org.springframework.boot.configurationsample.ConfigurationProperties;
|
||||
|
||||
/**
|
||||
* Class with nested configuration properties.
|
||||
*
|
||||
* @author Hrishikesh Joshi
|
||||
*/
|
||||
public class ClassWithNestedProperties {
|
||||
|
||||
public static class NestedParentClass {
|
||||
|
||||
private int parentClassProperty = 10;
|
||||
|
||||
public int getParentClassProperty() {
|
||||
return this.parentClassProperty;
|
||||
}
|
||||
|
||||
public void setParentClassProperty(int parentClassProperty) {
|
||||
this.parentClassProperty = parentClassProperty;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ConfigurationProperties(prefix = "nestedChildProps")
|
||||
public static class NestedChildClass extends NestedParentClass {
|
||||
|
||||
private int childClassProperty = 20;
|
||||
|
||||
public int getChildClassProperty() {
|
||||
return this.childClassProperty;
|
||||
}
|
||||
|
||||
public void setChildClassProperty(int childClassProperty) {
|
||||
this.childClassProperty = childClassProperty;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* 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.simple;
|
||||
|
||||
import org.springframework.boot.configurationsample.ConfigurationProperties;
|
||||
|
||||
/**
|
||||
* Deprecated configuration properties.
|
||||
*
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
@Deprecated
|
||||
@ConfigurationProperties(prefix = "deprecated")
|
||||
public class DeprecatedProperties {
|
||||
|
||||
private String name;
|
||||
|
||||
private String description;
|
||||
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return this.description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Copyright 2012-2015 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.simple;
|
||||
|
||||
import org.springframework.boot.configurationsample.ConfigurationProperties;
|
||||
import org.springframework.boot.configurationsample.DeprecatedConfigurationProperty;
|
||||
|
||||
/**
|
||||
* Configuration properties with a single deprecated element.
|
||||
*
|
||||
* @author Phillip Webb
|
||||
*/
|
||||
@ConfigurationProperties("singledeprecated")
|
||||
public class DeprecatedSingleProperty {
|
||||
|
||||
private String newName;
|
||||
|
||||
@Deprecated
|
||||
@DeprecatedConfigurationProperty(reason = "renamed", replacement = "singledeprecated.new-name")
|
||||
public String getName() {
|
||||
return getNewName();
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void setName(String name) {
|
||||
setNewName(name);
|
||||
}
|
||||
|
||||
public String getNewName() {
|
||||
return this.newName;
|
||||
}
|
||||
|
||||
public void setNewName(String newName) {
|
||||
this.newName = newName;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* 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.simple;
|
||||
|
||||
import org.springframework.boot.configurationsample.ConfigurationProperties;
|
||||
|
||||
/**
|
||||
* Configuration properties with inherited values.
|
||||
*
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
@ConfigurationProperties(prefix = "hierarchical")
|
||||
public class HierarchicalProperties extends HierarchicalPropertiesParent {
|
||||
|
||||
private String third;
|
||||
|
||||
public String getThird() {
|
||||
return this.third;
|
||||
}
|
||||
|
||||
public void setThird(String third) {
|
||||
this.third = third;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* 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.simple;
|
||||
|
||||
/**
|
||||
* Grandparent for {@link HierarchicalProperties}.
|
||||
*
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
public abstract class HierarchicalPropertiesGrandparent {
|
||||
|
||||
private String first;
|
||||
|
||||
public String getFirst() {
|
||||
return this.first;
|
||||
}
|
||||
|
||||
public void setFirst(String first) {
|
||||
this.first = first;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* 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.simple;
|
||||
|
||||
/**
|
||||
* Parent for {@link HierarchicalProperties}.
|
||||
*
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
public abstract class HierarchicalPropertiesParent
|
||||
extends HierarchicalPropertiesGrandparent {
|
||||
|
||||
private String second;
|
||||
|
||||
public String getSecond() {
|
||||
return this.second;
|
||||
}
|
||||
|
||||
public void setSecond(String second) {
|
||||
this.second = second;
|
||||
}
|
||||
|
||||
// Useless override
|
||||
|
||||
@Override
|
||||
public String getFirst() {
|
||||
return super.getFirst();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFirst(String first) {
|
||||
super.setFirst(first);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* 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.simple;
|
||||
|
||||
/**
|
||||
* This has no annotation on purpose to check that no meta-data is generated.
|
||||
*
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
public class NotAnnotated {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
/*
|
||||
* Copyright 2012-2017 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.simple;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.boot.configurationsample.ConfigurationProperties;
|
||||
|
||||
/**
|
||||
* Properties with collections.
|
||||
*
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
@ConfigurationProperties(prefix = "collection")
|
||||
public class SimpleCollectionProperties {
|
||||
|
||||
private Map<Integer, String> integersToNames;
|
||||
|
||||
private Collection<Long> longs;
|
||||
|
||||
private List<Float> floats;
|
||||
|
||||
private final Map<String, Integer> namesToIntegers = new HashMap<>();
|
||||
|
||||
private final Collection<Byte> bytes = new LinkedHashSet<>();
|
||||
|
||||
private final List<Double> doubles = new ArrayList<>();
|
||||
|
||||
public Map<Integer, String> getIntegersToNames() {
|
||||
return this.integersToNames;
|
||||
}
|
||||
|
||||
public void setIntegersToNames(Map<Integer, String> integersToNames) {
|
||||
this.integersToNames = integersToNames;
|
||||
}
|
||||
|
||||
public Collection<Long> getLongs() {
|
||||
return this.longs;
|
||||
}
|
||||
|
||||
public void setLongs(Collection<Long> longs) {
|
||||
this.longs = longs;
|
||||
}
|
||||
|
||||
public List<Float> getFloats() {
|
||||
return this.floats;
|
||||
}
|
||||
|
||||
public void setFloats(List<Float> floats) {
|
||||
this.floats = floats;
|
||||
}
|
||||
|
||||
public Map<String, Integer> getNamesToIntegers() {
|
||||
return this.namesToIntegers;
|
||||
}
|
||||
|
||||
public Collection<Byte> getBytes() {
|
||||
return this.bytes;
|
||||
}
|
||||
|
||||
public List<Double> getDoubles() {
|
||||
return this.doubles;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* 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.simple;
|
||||
|
||||
import org.springframework.boot.configurationsample.ConfigurationProperties;
|
||||
|
||||
/**
|
||||
* Properties with a simple prefix.
|
||||
*
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
@ConfigurationProperties("simple")
|
||||
public class SimplePrefixValueProperties {
|
||||
|
||||
private String name;
|
||||
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
/*
|
||||
* 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.simple;
|
||||
|
||||
import java.beans.FeatureDescriptor;
|
||||
import java.util.Comparator;
|
||||
|
||||
import org.springframework.boot.configurationsample.ConfigurationProperties;
|
||||
|
||||
/**
|
||||
* Simple properties.
|
||||
*
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
@ConfigurationProperties(prefix = "simple")
|
||||
public class SimpleProperties {
|
||||
|
||||
/**
|
||||
* The name of this simple properties.
|
||||
*/
|
||||
private String theName = "boot";
|
||||
|
||||
// isFlag is also detected
|
||||
/**
|
||||
* A simple flag.
|
||||
*/
|
||||
private boolean flag;
|
||||
|
||||
// An interface can still be injected because it might have a converter
|
||||
private Comparator<?> comparator;
|
||||
|
||||
// There is only a getter on this instance but we don't know what to do with it ->
|
||||
// ignored
|
||||
private FeatureDescriptor featureDescriptor;
|
||||
|
||||
// There is only a setter on this "simple" property --> ignored
|
||||
@SuppressWarnings("unused")
|
||||
private Long counter;
|
||||
|
||||
// There is only a getter on this "simple" property --> ignored
|
||||
private Integer size;
|
||||
|
||||
public String getTheName() {
|
||||
return this.theName;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void setTheName(String name) {
|
||||
this.theName = name;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public boolean isFlag() {
|
||||
return this.flag;
|
||||
}
|
||||
|
||||
public void setFlag(boolean flag) {
|
||||
this.flag = flag;
|
||||
}
|
||||
|
||||
public Comparator<?> getComparator() {
|
||||
return this.comparator;
|
||||
}
|
||||
|
||||
public void setComparator(Comparator<?> comparator) {
|
||||
this.comparator = comparator;
|
||||
}
|
||||
|
||||
public FeatureDescriptor getFeatureDescriptor() {
|
||||
return this.featureDescriptor;
|
||||
}
|
||||
|
||||
public void setCounter(Long counter) {
|
||||
this.counter = counter;
|
||||
}
|
||||
|
||||
public Integer getSize() {
|
||||
return this.size;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,199 @@
|
||||
/*
|
||||
* 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.simple;
|
||||
|
||||
import org.springframework.boot.configurationsample.ConfigurationProperties;
|
||||
|
||||
/**
|
||||
* Expose simple types to make sure these are detected properly.
|
||||
*
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
@ConfigurationProperties(prefix = "simple.type")
|
||||
public class SimpleTypeProperties {
|
||||
|
||||
private String myString;
|
||||
|
||||
private Byte myByte;
|
||||
|
||||
private byte myPrimitiveByte;
|
||||
|
||||
private Character myChar;
|
||||
|
||||
private char myPrimitiveChar;
|
||||
|
||||
private Boolean myBoolean;
|
||||
|
||||
private boolean myPrimitiveBoolean;
|
||||
|
||||
private Short myShort;
|
||||
|
||||
private short myPrimitiveShort;
|
||||
|
||||
private Integer myInteger;
|
||||
|
||||
private int myPrimitiveInteger;
|
||||
|
||||
private Long myLong;
|
||||
|
||||
private long myPrimitiveLong;
|
||||
|
||||
private Double myDouble;
|
||||
|
||||
private double myPrimitiveDouble;
|
||||
|
||||
private Float myFloat;
|
||||
|
||||
private float myPrimitiveFloat;
|
||||
|
||||
public String getMyString() {
|
||||
return this.myString;
|
||||
}
|
||||
|
||||
public void setMyString(String myString) {
|
||||
this.myString = myString;
|
||||
}
|
||||
|
||||
public Byte getMyByte() {
|
||||
return this.myByte;
|
||||
}
|
||||
|
||||
public void setMyByte(Byte myByte) {
|
||||
this.myByte = myByte;
|
||||
}
|
||||
|
||||
public byte getMyPrimitiveByte() {
|
||||
return this.myPrimitiveByte;
|
||||
}
|
||||
|
||||
public void setMyPrimitiveByte(byte myPrimitiveByte) {
|
||||
this.myPrimitiveByte = myPrimitiveByte;
|
||||
}
|
||||
|
||||
public Character getMyChar() {
|
||||
return this.myChar;
|
||||
}
|
||||
|
||||
public void setMyChar(Character myChar) {
|
||||
this.myChar = myChar;
|
||||
}
|
||||
|
||||
public char getMyPrimitiveChar() {
|
||||
return this.myPrimitiveChar;
|
||||
}
|
||||
|
||||
public void setMyPrimitiveChar(char myPrimitiveChar) {
|
||||
this.myPrimitiveChar = myPrimitiveChar;
|
||||
}
|
||||
|
||||
public Boolean getMyBoolean() {
|
||||
return this.myBoolean;
|
||||
}
|
||||
|
||||
public void setMyBoolean(Boolean myBoolean) {
|
||||
this.myBoolean = myBoolean;
|
||||
}
|
||||
|
||||
public boolean isMyPrimitiveBoolean() {
|
||||
return this.myPrimitiveBoolean;
|
||||
}
|
||||
|
||||
public void setMyPrimitiveBoolean(boolean myPrimitiveBoolean) {
|
||||
this.myPrimitiveBoolean = myPrimitiveBoolean;
|
||||
}
|
||||
|
||||
public Short getMyShort() {
|
||||
return this.myShort;
|
||||
}
|
||||
|
||||
public void setMyShort(Short myShort) {
|
||||
this.myShort = myShort;
|
||||
}
|
||||
|
||||
public short getMyPrimitiveShort() {
|
||||
return this.myPrimitiveShort;
|
||||
}
|
||||
|
||||
public void setMyPrimitiveShort(short myPrimitiveShort) {
|
||||
this.myPrimitiveShort = myPrimitiveShort;
|
||||
}
|
||||
|
||||
public Integer getMyInteger() {
|
||||
return this.myInteger;
|
||||
}
|
||||
|
||||
public void setMyInteger(Integer myInteger) {
|
||||
this.myInteger = myInteger;
|
||||
}
|
||||
|
||||
public int getMyPrimitiveInteger() {
|
||||
return this.myPrimitiveInteger;
|
||||
}
|
||||
|
||||
public void setMyPrimitiveInteger(int myPrimitiveInteger) {
|
||||
this.myPrimitiveInteger = myPrimitiveInteger;
|
||||
}
|
||||
|
||||
public Long getMyLong() {
|
||||
return this.myLong;
|
||||
}
|
||||
|
||||
public void setMyLong(Long myLong) {
|
||||
this.myLong = myLong;
|
||||
}
|
||||
|
||||
public long getMyPrimitiveLong() {
|
||||
return this.myPrimitiveLong;
|
||||
}
|
||||
|
||||
public void setMyPrimitiveLong(long myPrimitiveLong) {
|
||||
this.myPrimitiveLong = myPrimitiveLong;
|
||||
}
|
||||
|
||||
public Double getMyDouble() {
|
||||
return this.myDouble;
|
||||
}
|
||||
|
||||
public void setMyDouble(Double myDouble) {
|
||||
this.myDouble = myDouble;
|
||||
}
|
||||
|
||||
public double getMyPrimitiveDouble() {
|
||||
return this.myPrimitiveDouble;
|
||||
}
|
||||
|
||||
public void setMyPrimitiveDouble(double myPrimitiveDouble) {
|
||||
this.myPrimitiveDouble = myPrimitiveDouble;
|
||||
}
|
||||
|
||||
public Float getMyFloat() {
|
||||
return this.myFloat;
|
||||
}
|
||||
|
||||
public void setMyFloat(Float myFloat) {
|
||||
this.myFloat = myFloat;
|
||||
}
|
||||
|
||||
public float getMyPrimitiveFloat() {
|
||||
return this.myPrimitiveFloat;
|
||||
}
|
||||
|
||||
public void setMyPrimitiveFloat(float myPrimitiveFloat) {
|
||||
this.myPrimitiveFloat = myPrimitiveFloat;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* Copyright 2012-2015 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.specific;
|
||||
|
||||
import org.springframework.boot.configurationsample.ConfigurationProperties;
|
||||
|
||||
/**
|
||||
* Demonstrate the use of boxing/unboxing. Even if the type does not strictly match, it
|
||||
* should still be detected.
|
||||
*
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
@ConfigurationProperties("boxing")
|
||||
public class BoxingPojo {
|
||||
|
||||
private boolean flag;
|
||||
|
||||
private Integer counter;
|
||||
|
||||
public boolean isFlag() {
|
||||
return this.flag;
|
||||
}
|
||||
|
||||
// Setter use Boolean
|
||||
public void setFlag(Boolean flag) {
|
||||
this.flag = flag;
|
||||
}
|
||||
|
||||
public Integer getCounter() {
|
||||
return this.counter;
|
||||
}
|
||||
|
||||
// Setter use int
|
||||
public void setCounter(int counter) {
|
||||
this.counter = counter;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Copyright 2012-2016 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.specific;
|
||||
|
||||
import org.springframework.boot.configurationsample.ConfigurationProperties;
|
||||
|
||||
/**
|
||||
* Sample with builder style setters.
|
||||
*
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
@ConfigurationProperties(prefix = "builder")
|
||||
public class BuilderPojo {
|
||||
|
||||
private String name;
|
||||
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public BuilderPojo setName(String name) {
|
||||
this.name = name;
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* Copyright 2012-2015 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.specific;
|
||||
|
||||
import org.springframework.boot.configurationsample.ConfigurationProperties;
|
||||
|
||||
/**
|
||||
* Demonstrate that an unrelated setter is not taken into account to detect the deprecated
|
||||
* flag.
|
||||
*
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
@ConfigurationProperties("not.deprecated")
|
||||
public class DeprecatedUnrelatedMethodPojo {
|
||||
|
||||
private Integer counter;
|
||||
|
||||
private boolean flag;
|
||||
|
||||
public Integer getCounter() {
|
||||
return this.counter;
|
||||
}
|
||||
|
||||
public void setCounter(Integer counter) {
|
||||
this.counter = counter;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void setCounter(String counterAsString) {
|
||||
this.counter = Integer.valueOf(counterAsString);
|
||||
}
|
||||
|
||||
public boolean isFlag() {
|
||||
return this.flag;
|
||||
}
|
||||
|
||||
public void setFlag(boolean flag) {
|
||||
this.flag = flag;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void setFlag(Boolean flag) {
|
||||
this.flag = flag;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright 2012-2016 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.specific;
|
||||
|
||||
import org.springframework.boot.configurationsample.ConfigurationProperties;
|
||||
|
||||
/**
|
||||
* Test that the same type can be registered several times if the prefix is different.
|
||||
*
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
public class DoubleRegistrationProperties {
|
||||
|
||||
@ConfigurationProperties("one")
|
||||
public SimplePojo one() {
|
||||
return new SimplePojo();
|
||||
}
|
||||
|
||||
@ConfigurationProperties("two")
|
||||
public SimplePojo two() {
|
||||
return new SimplePojo();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
/*
|
||||
* 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.specific;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
import java.io.Writer;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import org.springframework.boot.configurationsample.ConfigurationProperties;
|
||||
|
||||
/**
|
||||
* Sample config with types that should not be added to the meta-data as we have no way to
|
||||
* bind them from simple strings.
|
||||
*
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
@ConfigurationProperties(prefix = "excluded")
|
||||
public class ExcludedTypesPojo {
|
||||
|
||||
private String name;
|
||||
|
||||
private ClassLoader classLoader;
|
||||
|
||||
private DataSource dataSource;
|
||||
|
||||
private PrintWriter printWriter;
|
||||
|
||||
private Writer writer;
|
||||
|
||||
private Writer[] writerArray;
|
||||
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public ClassLoader getClassLoader() {
|
||||
return this.classLoader;
|
||||
}
|
||||
|
||||
public void setClassLoader(ClassLoader classLoader) {
|
||||
this.classLoader = classLoader;
|
||||
}
|
||||
|
||||
public DataSource getDataSource() {
|
||||
return this.dataSource;
|
||||
}
|
||||
|
||||
public void setDataSource(DataSource dataSource) {
|
||||
this.dataSource = dataSource;
|
||||
}
|
||||
|
||||
public PrintWriter getPrintWriter() {
|
||||
return this.printWriter;
|
||||
}
|
||||
|
||||
public void setPrintWriter(PrintWriter printWriter) {
|
||||
this.printWriter = printWriter;
|
||||
}
|
||||
|
||||
public Writer getWriter() {
|
||||
return this.writer;
|
||||
}
|
||||
|
||||
public void setWriter(Writer writer) {
|
||||
this.writer = writer;
|
||||
}
|
||||
|
||||
public Writer[] getWriterArray() {
|
||||
return this.writerArray;
|
||||
}
|
||||
|
||||
public void setWriterArray(Writer[] writerArray) {
|
||||
this.writerArray = writerArray;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,108 @@
|
||||
/*
|
||||
* Copyright 2012-2017 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.specific;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.boot.configurationsample.ConfigurationProperties;
|
||||
import org.springframework.boot.configurationsample.NestedConfigurationProperty;
|
||||
|
||||
/**
|
||||
* Demonstrate that only relevant generics are stored in the metadata.
|
||||
*
|
||||
* @param <T> the type of the config
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
@ConfigurationProperties("generic")
|
||||
public class GenericConfig<T> {
|
||||
|
||||
private final Foo foo = new Foo();
|
||||
|
||||
public Foo getFoo() {
|
||||
return this.foo;
|
||||
}
|
||||
|
||||
public static class Foo {
|
||||
|
||||
private String name;
|
||||
|
||||
@NestedConfigurationProperty
|
||||
private final Bar<String> bar = new Bar<>();
|
||||
|
||||
private final Map<String, Bar<Integer>> stringToBar = new HashMap<>();
|
||||
|
||||
private final Map<String, Integer> stringToInteger = new HashMap<>();
|
||||
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public Bar<String> getBar() {
|
||||
return this.bar;
|
||||
}
|
||||
|
||||
public Map<String, Bar<Integer>> getStringToBar() {
|
||||
return this.stringToBar;
|
||||
}
|
||||
|
||||
public Map<String, Integer> getStringToInteger() {
|
||||
return this.stringToInteger;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static class Bar<U> {
|
||||
|
||||
private String name;
|
||||
|
||||
@NestedConfigurationProperty
|
||||
private final Biz<String> biz = new Biz<>();
|
||||
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public Biz<String> getBiz() {
|
||||
return this.biz;
|
||||
}
|
||||
|
||||
public static class Biz<V> {
|
||||
|
||||
private String name;
|
||||
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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.specific;
|
||||
|
||||
import org.springframework.boot.configurationsample.ConfigurationProperties;
|
||||
|
||||
/**
|
||||
* Demonstrate that a method that exposes a root group within an annotated class is
|
||||
* ignored as it should.
|
||||
*
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
@ConfigurationProperties("specific")
|
||||
public class InnerClassAnnotatedGetterConfig {
|
||||
|
||||
private String value;
|
||||
|
||||
public String getValue() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@ConfigurationProperties("foo")
|
||||
public Foo getFoo() {
|
||||
return new Foo();
|
||||
}
|
||||
|
||||
public static class Foo {
|
||||
|
||||
private String name;
|
||||
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
/*
|
||||
* Copyright 2012-2017 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.specific;
|
||||
|
||||
import org.springframework.boot.configurationsample.ConfigurationProperties;
|
||||
|
||||
/**
|
||||
* Demonstrate inner classes end up in metadata regardless of position in hierarchy and
|
||||
* without the use of
|
||||
* {@link org.springframework.boot.configurationsample.NestedConfigurationProperty}.
|
||||
*
|
||||
* @author Madhura Bhave
|
||||
*/
|
||||
@ConfigurationProperties(prefix = "config")
|
||||
public class InnerClassHierarchicalProperties {
|
||||
|
||||
private Foo foo;
|
||||
|
||||
public Foo getFoo() {
|
||||
return this.foo;
|
||||
}
|
||||
|
||||
public void setFoo(Foo foo) {
|
||||
this.foo = foo;
|
||||
}
|
||||
|
||||
public static class Foo {
|
||||
|
||||
private Bar bar;
|
||||
|
||||
public Bar getBar() {
|
||||
return this.bar;
|
||||
}
|
||||
|
||||
public void setBar(Bar bar) {
|
||||
this.bar = bar;
|
||||
}
|
||||
|
||||
public static class Baz {
|
||||
|
||||
private String blah;
|
||||
|
||||
public String getBlah() {
|
||||
return this.blah;
|
||||
}
|
||||
|
||||
public void setBlah(String blah) {
|
||||
this.blah = blah;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static class Bar {
|
||||
|
||||
private String bling;
|
||||
|
||||
private Foo.Baz baz;
|
||||
|
||||
public String getBling() {
|
||||
return this.bling;
|
||||
}
|
||||
|
||||
public void setBling(String foo) {
|
||||
this.bling = foo;
|
||||
}
|
||||
|
||||
public Foo.Baz getBaz() {
|
||||
return this.baz;
|
||||
}
|
||||
|
||||
public void setBaz(Foo.Baz baz) {
|
||||
this.baz = baz;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,103 @@
|
||||
/*
|
||||
* Copyright 2012-2016 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.specific;
|
||||
|
||||
import org.springframework.boot.configurationsample.ConfigurationProperties;
|
||||
import org.springframework.boot.configurationsample.NestedConfigurationProperty;
|
||||
|
||||
/**
|
||||
* Demonstrate the auto-detection of inner config classes.
|
||||
*
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
@ConfigurationProperties(prefix = "config")
|
||||
public class InnerClassProperties {
|
||||
|
||||
private final Foo first = new Foo();
|
||||
|
||||
private Foo second = new Foo();
|
||||
|
||||
@NestedConfigurationProperty
|
||||
private final SimplePojo third = new SimplePojo();
|
||||
|
||||
private Fourth fourth;
|
||||
|
||||
public Foo getFirst() {
|
||||
return this.first;
|
||||
}
|
||||
|
||||
public Foo getTheSecond() {
|
||||
return this.second;
|
||||
}
|
||||
|
||||
public void setTheSecond(Foo second) {
|
||||
this.second = second;
|
||||
}
|
||||
|
||||
public SimplePojo getThird() {
|
||||
return this.third;
|
||||
}
|
||||
|
||||
public Fourth getFourth() {
|
||||
return this.fourth;
|
||||
}
|
||||
|
||||
public void setFourth(Fourth fourth) {
|
||||
this.fourth = fourth;
|
||||
}
|
||||
|
||||
public static class Foo {
|
||||
|
||||
private String name;
|
||||
|
||||
private final Bar bar = new Bar();
|
||||
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public Bar getBar() {
|
||||
return this.bar;
|
||||
}
|
||||
|
||||
public static class Bar {
|
||||
|
||||
private String name;
|
||||
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public enum Fourth {
|
||||
|
||||
YES, NO
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* Copyright 2012-2016 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.specific;
|
||||
|
||||
import org.springframework.boot.configurationsample.ConfigurationProperties;
|
||||
|
||||
/**
|
||||
* Sample with a simple inner class config.
|
||||
*
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
public class InnerClassRootConfig {
|
||||
|
||||
@ConfigurationProperties(prefix = "config")
|
||||
static class Config {
|
||||
|
||||
private String name;
|
||||
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Copyright 2012-2016 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.specific;
|
||||
|
||||
import org.springframework.boot.configurationsample.ConfigurationProperties;
|
||||
|
||||
/**
|
||||
* Demonstrates that invalid accessors are ignored.
|
||||
*
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
@ConfigurationProperties(prefix = "config")
|
||||
public class InvalidAccessorProperties {
|
||||
|
||||
private String name;
|
||||
|
||||
private boolean flag;
|
||||
|
||||
public void set(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String get() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public void setFlag(boolean flag) {
|
||||
this.flag = flag;
|
||||
}
|
||||
|
||||
public boolean is() {
|
||||
return this.flag;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* Copyright 2012-2016 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.specific;
|
||||
|
||||
import org.springframework.boot.configurationsample.ConfigurationProperties;
|
||||
|
||||
/**
|
||||
* Test that compilation fails if the same type is registered twice with the same prefix.
|
||||
*
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
public class InvalidDoubleRegistrationProperties {
|
||||
|
||||
@ConfigurationProperties("foo")
|
||||
public Foo foo() {
|
||||
return new Foo();
|
||||
}
|
||||
|
||||
@ConfigurationProperties("foo")
|
||||
public static class Foo {
|
||||
|
||||
private String name;
|
||||
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* 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.specific;
|
||||
|
||||
/**
|
||||
* POJO for use with samples.
|
||||
*
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
public class SimplePojo {
|
||||
|
||||
private int value;
|
||||
|
||||
public int getValue() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
public void setValue(int value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
private String extra;
|
||||
|
||||
public String getExtra() {
|
||||
return extra;
|
||||
}
|
||||
|
||||
public void setExtra(String extra) {
|
||||
this.extra = extra;
|
||||
}
|
||||
Reference in New Issue
Block a user