Reformat code using Eclipse Mars
This commit is contained in:
@@ -83,8 +83,8 @@ public class ConfigurationMetadataProperty implements Serializable {
|
||||
* For consistency, the type of a primitive is specified using its wrapper
|
||||
* counterpart, i.e. {@code boolean} becomes {@code java.lang.Boolean}. If the type
|
||||
* holds generic information, these are provided as well, i.e. a {@code HashMap} of
|
||||
* String to Integer would be defined as
|
||||
* {@code java.util.HashMap<java.lang.String,java.lang.Integer>}.
|
||||
* String to Integer would be defined as {@code java.util.HashMap
|
||||
* <java.lang.String,java.lang.Integer>}.
|
||||
* <p>
|
||||
* Note that this class may be a complex type that gets converted from a String as
|
||||
* values are bound.
|
||||
|
||||
@@ -105,16 +105,17 @@ public final class ConfigurationMetadataRepositoryJsonBuilder {
|
||||
return create(metadata);
|
||||
}
|
||||
catch (IOException ex) {
|
||||
throw new IllegalArgumentException("Failed to read configuration "
|
||||
+ "metadata", ex);
|
||||
throw new IllegalArgumentException(
|
||||
"Failed to read configuration " + "metadata", ex);
|
||||
}
|
||||
catch (JSONException ex) {
|
||||
throw new IllegalArgumentException("Invalid configuration "
|
||||
+ "metadata document", ex);
|
||||
throw new IllegalArgumentException(
|
||||
"Invalid configuration " + "metadata document", ex);
|
||||
}
|
||||
}
|
||||
|
||||
private SimpleConfigurationMetadataRepository create(RawConfigurationMetadata metadata) {
|
||||
private SimpleConfigurationMetadataRepository create(
|
||||
RawConfigurationMetadata metadata) {
|
||||
SimpleConfigurationMetadataRepository repository = new SimpleConfigurationMetadataRepository();
|
||||
repository.add(metadata.getSources());
|
||||
for (ConfigurationMetadataItem item : metadata.getItems()) {
|
||||
@@ -170,7 +171,8 @@ public final class ConfigurationMetadataRepositoryJsonBuilder {
|
||||
* @param defaultCharset the default charset to use
|
||||
* @return a new {@link ConfigurationMetadataRepositoryJsonBuilder} instance.
|
||||
*/
|
||||
public static ConfigurationMetadataRepositoryJsonBuilder create(Charset defaultCharset) {
|
||||
public static ConfigurationMetadataRepositoryJsonBuilder create(
|
||||
Charset defaultCharset) {
|
||||
return new ConfigurationMetadataRepositoryJsonBuilder(defaultCharset);
|
||||
}
|
||||
|
||||
|
||||
@@ -36,8 +36,8 @@ class DescriptionExtractor {
|
||||
if (dot != -1) {
|
||||
BreakIterator breakIterator = BreakIterator.getSentenceInstance(Locale.US);
|
||||
breakIterator.setText(description);
|
||||
String text = description.substring(breakIterator.first(),
|
||||
breakIterator.next()).trim();
|
||||
String text = description
|
||||
.substring(breakIterator.first(), breakIterator.next()).trim();
|
||||
return removeSpaceBetweenLine(text);
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -93,8 +93,8 @@ class JsonReader {
|
||||
source.setType(json.optString("type", null));
|
||||
String description = json.optString("description", null);
|
||||
source.setDescription(description);
|
||||
source.setShortDescription(this.descriptionExtractor
|
||||
.getShortDescription(description));
|
||||
source.setShortDescription(
|
||||
this.descriptionExtractor.getShortDescription(description));
|
||||
source.setSourceType(json.optString("sourceType", null));
|
||||
source.setSourceMethod(json.optString("sourceMethod", null));
|
||||
return source;
|
||||
@@ -106,8 +106,8 @@ class JsonReader {
|
||||
item.setType(json.optString("type", null));
|
||||
String description = json.optString("description", null);
|
||||
item.setDescription(description);
|
||||
item.setShortDescription(this.descriptionExtractor
|
||||
.getShortDescription(description));
|
||||
item.setShortDescription(
|
||||
this.descriptionExtractor.getShortDescription(description));
|
||||
item.setDefaultValue(readItemValue(json.opt("defaultValue")));
|
||||
item.setDeprecation(parseDeprecation(json));
|
||||
item.setSourceType(json.optString("sourceType", null));
|
||||
@@ -126,8 +126,8 @@ class JsonReader {
|
||||
valueHint.setValue(readItemValue(value.get("value")));
|
||||
String description = value.optString("description", null);
|
||||
valueHint.setDescription(description);
|
||||
valueHint.setShortDescription(this.descriptionExtractor
|
||||
.getShortDescription(description));
|
||||
valueHint.setShortDescription(
|
||||
this.descriptionExtractor.getShortDescription(description));
|
||||
hint.getValueHints().add(valueHint);
|
||||
}
|
||||
}
|
||||
@@ -157,8 +157,8 @@ class JsonReader {
|
||||
JSONObject deprecationJsonObject = object.getJSONObject("deprecation");
|
||||
Deprecation deprecation = new Deprecation();
|
||||
deprecation.setReason(deprecationJsonObject.optString("reason", null));
|
||||
deprecation.setReplacement(deprecationJsonObject.optString("replacement",
|
||||
null));
|
||||
deprecation
|
||||
.setReplacement(deprecationJsonObject.optString("replacement", null));
|
||||
return deprecation;
|
||||
}
|
||||
return (object.optBoolean("deprecated") ? new Deprecation() : null);
|
||||
|
||||
@@ -34,7 +34,8 @@ class RawConfigurationMetadata {
|
||||
private final List<ConfigurationMetadataHint> hints;
|
||||
|
||||
RawConfigurationMetadata(List<ConfigurationMetadataSource> sources,
|
||||
List<ConfigurationMetadataItem> items, List<ConfigurationMetadataHint> hints) {
|
||||
List<ConfigurationMetadataItem> items,
|
||||
List<ConfigurationMetadataHint> hints) {
|
||||
this.sources = new ArrayList<ConfigurationMetadataSource>(sources);
|
||||
this.items = new ArrayList<ConfigurationMetadataItem>(items);
|
||||
this.hints = new ArrayList<ConfigurationMetadataHint>(hints);
|
||||
|
||||
@@ -29,8 +29,8 @@ import java.util.Map;
|
||||
* @since 1.3.0
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public class SimpleConfigurationMetadataRepository implements
|
||||
ConfigurationMetadataRepository, Serializable {
|
||||
public class SimpleConfigurationMetadataRepository
|
||||
implements ConfigurationMetadataRepository, Serializable {
|
||||
|
||||
private final Map<String, ConfigurationMetadataGroup> allGroups = new HashMap<String, ConfigurationMetadataGroup>();
|
||||
|
||||
|
||||
@@ -74,7 +74,7 @@ public class ValueHint implements Serializable {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ValueHint{" + "value=" + this.value + ", description='"
|
||||
+ this.description + '\'' + '}';
|
||||
return "ValueHint{" + "value=" + this.value + ", description='" + this.description
|
||||
+ '\'' + '}';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,8 +59,8 @@ public class ValueProvider implements Serializable {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ValueProvider{" + "name='" + this.name + ", parameters="
|
||||
+ this.parameters + '}';
|
||||
return "ValueProvider{" + "name='" + this.name + ", parameters=" + this.parameters
|
||||
+ '}';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -61,8 +61,8 @@ public abstract class AbstractConfigurationMetadataTests {
|
||||
}
|
||||
|
||||
protected InputStream getInputStreamFor(String name) throws IOException {
|
||||
Resource r = new ClassPathResource("metadata/configuration-metadata-" + name
|
||||
+ ".json");
|
||||
Resource r = new ClassPathResource(
|
||||
"metadata/configuration-metadata-" + name + ".json");
|
||||
return r.getInputStream();
|
||||
}
|
||||
|
||||
|
||||
@@ -31,8 +31,8 @@ import static org.junit.Assert.assertTrue;
|
||||
*
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
public class ConfigurationMetadataRepositoryJsonBuilderTests extends
|
||||
AbstractConfigurationMetadataTests {
|
||||
public class ConfigurationMetadataRepositoryJsonBuilderTests
|
||||
extends AbstractConfigurationMetadataTests {
|
||||
|
||||
@Test
|
||||
public void nullResource() throws IOException {
|
||||
@@ -48,8 +48,8 @@ public class ConfigurationMetadataRepositoryJsonBuilderTests extends
|
||||
.create(foo).build();
|
||||
validateFoo(repo);
|
||||
assertEquals(1, repo.getAllGroups().size());
|
||||
contains(repo.getAllProperties(), "spring.foo.name",
|
||||
"spring.foo.description", "spring.foo.counter");
|
||||
contains(repo.getAllProperties(), "spring.foo.name", "spring.foo.description",
|
||||
"spring.foo.counter");
|
||||
assertEquals(3, repo.getAllProperties().size());
|
||||
}
|
||||
finally {
|
||||
@@ -67,9 +67,9 @@ public class ConfigurationMetadataRepositoryJsonBuilderTests extends
|
||||
validateFoo(repo);
|
||||
validateBar(repo);
|
||||
assertEquals(2, repo.getAllGroups().size());
|
||||
contains(repo.getAllProperties(), "spring.foo.name",
|
||||
"spring.foo.description", "spring.foo.counter", "spring.bar.name",
|
||||
"spring.bar.description", "spring.bar.counter");
|
||||
contains(repo.getAllProperties(), "spring.foo.name", "spring.foo.description",
|
||||
"spring.foo.counter", "spring.bar.name", "spring.bar.description",
|
||||
"spring.bar.counter");
|
||||
assertEquals(6, repo.getAllProperties().size());
|
||||
}
|
||||
finally {
|
||||
@@ -88,9 +88,8 @@ public class ConfigurationMetadataRepositoryJsonBuilderTests extends
|
||||
validateFoo(repo);
|
||||
assertEquals(2, repo.getAllGroups().size());
|
||||
|
||||
contains(repo.getAllProperties(), "spring.foo.name",
|
||||
"spring.foo.description", "spring.foo.counter", "spring.root.name",
|
||||
"spring.root2.name");
|
||||
contains(repo.getAllProperties(), "spring.foo.name", "spring.foo.description",
|
||||
"spring.foo.counter", "spring.root.name", "spring.root2.name");
|
||||
assertEquals(5, repo.getAllProperties().size());
|
||||
}
|
||||
finally {
|
||||
@@ -114,9 +113,8 @@ public class ConfigurationMetadataRepositoryJsonBuilderTests extends
|
||||
contains(group.getProperties(), "spring.foo.name", "spring.foo.description",
|
||||
"spring.foo.counter", "spring.foo.enabled", "spring.foo.type");
|
||||
assertEquals(5, group.getProperties().size());
|
||||
contains(repo.getAllProperties(), "spring.foo.name",
|
||||
"spring.foo.description", "spring.foo.counter", "spring.foo.enabled",
|
||||
"spring.foo.type");
|
||||
contains(repo.getAllProperties(), "spring.foo.name", "spring.foo.description",
|
||||
"spring.foo.counter", "spring.foo.enabled", "spring.foo.type");
|
||||
assertEquals(5, repo.getAllProperties().size());
|
||||
}
|
||||
finally {
|
||||
@@ -159,12 +157,13 @@ public class ConfigurationMetadataRepositoryJsonBuilderTests extends
|
||||
ConfigurationMetadataSource source = group.getSources().get("org.acme.Foo");
|
||||
contains(source.getProperties(), "spring.foo.name", "spring.foo.description");
|
||||
assertEquals(2, source.getProperties().size());
|
||||
ConfigurationMetadataSource source2 = group.getSources().get(
|
||||
"org.springframework.boot.FooProperties");
|
||||
ConfigurationMetadataSource source2 = group.getSources()
|
||||
.get("org.springframework.boot.FooProperties");
|
||||
contains(source2.getProperties(), "spring.foo.name", "spring.foo.counter");
|
||||
assertEquals(2, source2.getProperties().size());
|
||||
validatePropertyHints(repo.getAllProperties().get("spring.foo.name"), 0, 0);
|
||||
validatePropertyHints(repo.getAllProperties().get("spring.foo.description"), 0, 0);
|
||||
validatePropertyHints(repo.getAllProperties().get("spring.foo.description"), 0,
|
||||
0);
|
||||
validatePropertyHints(repo.getAllProperties().get("spring.foo.counter"), 1, 1);
|
||||
}
|
||||
|
||||
@@ -175,12 +174,13 @@ public class ConfigurationMetadataRepositoryJsonBuilderTests extends
|
||||
ConfigurationMetadataSource source = group.getSources().get("org.acme.Bar");
|
||||
contains(source.getProperties(), "spring.bar.name", "spring.bar.description");
|
||||
assertEquals(2, source.getProperties().size());
|
||||
ConfigurationMetadataSource source2 = group.getSources().get(
|
||||
"org.springframework.boot.BarProperties");
|
||||
ConfigurationMetadataSource source2 = group.getSources()
|
||||
.get("org.springframework.boot.BarProperties");
|
||||
contains(source2.getProperties(), "spring.bar.name", "spring.bar.counter");
|
||||
assertEquals(2, source2.getProperties().size());
|
||||
validatePropertyHints(repo.getAllProperties().get("spring.bar.name"), 0, 0);
|
||||
validatePropertyHints(repo.getAllProperties().get("spring.bar.description"), 2, 2);
|
||||
validatePropertyHints(repo.getAllProperties().get("spring.bar.description"), 2,
|
||||
2);
|
||||
validatePropertyHints(repo.getAllProperties().get("spring.bar.counter"), 0, 0);
|
||||
}
|
||||
|
||||
|
||||
@@ -33,22 +33,22 @@ public class DescriptionExtractorTests {
|
||||
|
||||
@Test
|
||||
public void extractShortDescription() {
|
||||
String description = this.extractor.getShortDescription("My short "
|
||||
+ "description. More stuff.");
|
||||
String description = this.extractor
|
||||
.getShortDescription("My short " + "description. More stuff.");
|
||||
assertEquals("My short description.", description);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void extractShortDescriptionNewLineBeforeDot() {
|
||||
String description = this.extractor.getShortDescription("My short" + NEW_LINE
|
||||
+ "description." + NEW_LINE + "More stuff.");
|
||||
String description = this.extractor.getShortDescription(
|
||||
"My short" + NEW_LINE + "description." + NEW_LINE + "More stuff.");
|
||||
assertEquals("My short description.", description);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void extractShortDescriptionNewLineBeforeDotWithSpaces() {
|
||||
String description = this.extractor.getShortDescription("My short " + NEW_LINE
|
||||
+ " description. " + NEW_LINE + "More stuff.");
|
||||
String description = this.extractor.getShortDescription(
|
||||
"My short " + NEW_LINE + " description. " + NEW_LINE + "More stuff.");
|
||||
assertEquals("My short description.", description);
|
||||
}
|
||||
|
||||
@@ -60,8 +60,8 @@ public class DescriptionExtractorTests {
|
||||
|
||||
@Test
|
||||
public void extractShortDescriptionNoDotMultipleLines() {
|
||||
String description = this.extractor.getShortDescription("My short description "
|
||||
+ NEW_LINE + " More stuff");
|
||||
String description = this.extractor
|
||||
.getShortDescription("My short description " + NEW_LINE + " More stuff");
|
||||
assertEquals("My short description", description);
|
||||
}
|
||||
|
||||
|
||||
@@ -92,7 +92,8 @@ public class JsonReaderTests extends AbstractConfigurationMetadataTests {
|
||||
ValueProvider valueProvider = hint.getValueProviders().get(0);
|
||||
assertEquals("handle-as", valueProvider.getName());
|
||||
assertEquals(1, valueProvider.getParameters().size());
|
||||
assertEquals(Integer.class.getName(), valueProvider.getParameters().get("target"));
|
||||
assertEquals(Integer.class.getName(),
|
||||
valueProvider.getParameters().get("target"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -141,8 +142,8 @@ public class JsonReaderTests extends AbstractConfigurationMetadataTests {
|
||||
ConfigurationMetadataItem item = items.get(0);
|
||||
assertProperty(item, "server.port", "server.port", Integer.class, null);
|
||||
assertTrue(item.isDeprecated());
|
||||
assertEquals("Server namespace has moved to spring.server", item.getDeprecation()
|
||||
.getReason());
|
||||
assertEquals("Server namespace has moved to spring.server",
|
||||
item.getDeprecation().getReason());
|
||||
assertEquals("server.spring.port", item.getDeprecation().getReplacement());
|
||||
|
||||
ConfigurationMetadataItem item2 = items.get(1);
|
||||
|
||||
Reference in New Issue
Block a user