From 3664895f04c116dd11e17d65dd3c79c61aba7451 Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Sun, 12 Jul 2015 09:20:12 +0200 Subject: [PATCH] Polish --- .../appendix-configuration-metadata.adoc | 12 +++++----- .../metadata/ItemHint.java | 16 ++++++------- .../metadata/JsonMarshaller.java | 24 +++++++++---------- ...ationMetadataAnnotationProcessorTests.java | 4 ++-- .../ConfigurationMetadataMatchers.java | 24 +++++++++---------- .../metadata/JsonMarshallerTests.java | 4 ++-- 6 files changed, 42 insertions(+), 42 deletions(-) diff --git a/spring-boot-docs/src/main/asciidoc/appendix-configuration-metadata.adoc b/spring-boot-docs/src/main/asciidoc/appendix-configuration-metadata.adoc index be2d9747b0..c41c6c0655 100644 --- a/spring-boot-docs/src/main/asciidoc/appendix-configuration-metadata.adoc +++ b/spring-boot-docs/src/main/asciidoc/appendix-configuration-metadata.adoc @@ -217,8 +217,8 @@ The JSON object contained in the `hints` array can contain the following attribu the value and may have a description |`providers` -| ProviderHint[] -| A list of providers as defined by the `ValueHint` object (see below). Each entry defines +| ValueProvider[] +| A list of providers as defined by the `ValueProvider` object (see below). Each entry defines the name of the provider and its parameters, if any. |=== @@ -283,7 +283,7 @@ property, you can provide additional meta-data that: can discover the list of potential values based on the project's context. -==== Value hints +==== Value hint The `name` attribute of each hint refers to the `name` of a property. In the initial example above, we provide 3 values for the `server.tomcat.compression` property: `on`, `off` and `force`. @@ -330,7 +330,7 @@ the most effective approach to auto-completion if your IDE supports it. -==== Provider hints +==== Value provider Providers are a powerful way of attaching semantics to a property. We define in the section below the official providers that you can use for your own hints. Bare in mind however that your favorite IDE may implement some of these or none of them. It could eventually provide @@ -345,7 +345,7 @@ The table below summarizes the list of supported providers: |Name | Description |`any` -|Permit any additional values to be provided. +|Permit any additional value to be provided. |`class-reference` |Auto-complete the classes available in the project. Usually constrained by a base @@ -363,7 +363,7 @@ The table below summarizes the list of supported providers: by a base class that is specified via the `target` parameter. |`spring-profile-name` -|Auto-complete the available profile names in the project. +|Auto-complete the available Spring profile names in the project. |=== diff --git a/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/metadata/ItemHint.java b/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/metadata/ItemHint.java index 26478c9ea7..25eb93a665 100644 --- a/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/metadata/ItemHint.java +++ b/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/metadata/ItemHint.java @@ -40,14 +40,14 @@ public class ItemHint implements Comparable { private final List values; - private final List providers; + private final List providers; - public ItemHint(String name, List values, List providers) { + public ItemHint(String name, List values, List providers) { this.name = toCanonicalName(name); this.values = (values != null ? new ArrayList(values) : new ArrayList()); - this.providers = (providers != null ? new ArrayList(providers) - : new ArrayList()); + this.providers = (providers != null ? new ArrayList(providers) + : new ArrayList()); } private String toCanonicalName(String name) { @@ -68,7 +68,7 @@ public class ItemHint implements Comparable { return Collections.unmodifiableList(this.values); } - public List getProviders() { + public List getProviders() { return Collections.unmodifiableList(this.providers); } @@ -79,7 +79,7 @@ public class ItemHint implements Comparable { public static ItemHint newHint(String name, ValueHint... values) { return new ItemHint(name, Arrays.asList(values), - Collections. emptyList()); + Collections. emptyList()); } @Override @@ -115,13 +115,13 @@ public class ItemHint implements Comparable { } - public static class ProviderHint { + public static class ValueProvider { private final String name; private final Map parameters; - public ProviderHint(String name, Map parameters) { + public ValueProvider(String name, Map parameters) { this.name = name; this.parameters = parameters; } diff --git a/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/metadata/JsonMarshaller.java b/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/metadata/JsonMarshaller.java index c39945b8f1..c76c1c3eac 100644 --- a/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/metadata/JsonMarshaller.java +++ b/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/metadata/JsonMarshaller.java @@ -107,20 +107,20 @@ public class JsonMarshaller { } if (!hint.getProviders().isEmpty()) { JSONArray providersArray = new JSONArray(); - for (ItemHint.ProviderHint providerHint : hint.getProviders()) { - JSONObject providerHintObject = new JSONOrderedObject(); - providerHintObject.put("name", providerHint.getName()); - if (providerHint.getParameters() != null - && !providerHint.getParameters().isEmpty()) { + for (ItemHint.ValueProvider valueProvider : hint.getProviders()) { + JSONObject valueProviderObject = new JSONOrderedObject(); + valueProviderObject.put("name", valueProvider.getName()); + if (valueProvider.getParameters() != null + && !valueProvider.getParameters().isEmpty()) { JSONObject parametersObject = new JSONOrderedObject(); - for (Map.Entry entry : providerHint.getParameters() + for (Map.Entry entry : valueProvider.getParameters() .entrySet()) { parametersObject.put(entry.getKey(), extractItemValue(entry.getValue())); } - providerHintObject.put("parameters", parametersObject); + valueProviderObject.put("parameters", parametersObject); } - providersArray.put(providerHintObject); + providersArray.put(valueProviderObject); } jsonObject.put("providers", providersArray); } @@ -203,11 +203,11 @@ public class JsonMarshaller { values.add(toValueHint((JSONObject) valuesArray.get(i))); } } - List providers = new ArrayList(); + List providers = new ArrayList(); if (object.has("providers")) { JSONArray providersObject = object.getJSONArray("providers"); for (int i = 0; i < providersObject.length(); i++) { - providers.add(toProviderHint((JSONObject) providersObject.get(i))); + providers.add(toValueProvider((JSONObject) providersObject.get(i))); } } return new ItemHint(name, values, providers); @@ -219,7 +219,7 @@ public class JsonMarshaller { return new ItemHint.ValueHint(value, description); } - private ItemHint.ProviderHint toProviderHint(JSONObject object) { + private ItemHint.ValueProvider toValueProvider(JSONObject object) { String name = object.getString("name"); Map parameters = new HashMap(); if (object.has("parameters")) { @@ -230,7 +230,7 @@ public class JsonMarshaller { parameters.put(key, value); } } - return new ItemHint.ProviderHint(name, parameters); + return new ItemHint.ValueProvider(name, parameters); } private Object readItemValue(Object value) { diff --git a/spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationprocessor/ConfigurationMetadataAnnotationProcessorTests.java b/spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationprocessor/ConfigurationMetadataAnnotationProcessorTests.java index 8b791a117b..5730836f6b 100644 --- a/spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationprocessor/ConfigurationMetadataAnnotationProcessorTests.java +++ b/spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationprocessor/ConfigurationMetadataAnnotationProcessorTests.java @@ -384,9 +384,9 @@ public class ConfigurationMetadataAnnotationProcessorTests { public void mergingOfHintWithProvider() throws Exception { writeAdditionalHints(new ItemHint("simple.theName", Collections. emptyList(), Arrays.asList( - new ItemHint.ProviderHint("first", Collections + new ItemHint.ValueProvider("first", Collections . singletonMap("target", "org.foo")), - new ItemHint.ProviderHint("second", null)))); + new ItemHint.ValueProvider("second", null)))); ConfigurationMetadata metadata = compile(SimpleProperties.class); assertThat(metadata, containsHint("simple.the-name") diff --git a/spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationprocessor/ConfigurationMetadataMatchers.java b/spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationprocessor/ConfigurationMetadataMatchers.java index 38808dbe8b..0acc7f2bba 100644 --- a/spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationprocessor/ConfigurationMetadataMatchers.java +++ b/spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationprocessor/ConfigurationMetadataMatchers.java @@ -209,15 +209,15 @@ public class ConfigurationMetadataMatchers { private final List values; - private final List providers; + private final List providers; public ContainsHintMatcher(String name) { this(name, new ArrayList(), - new ArrayList()); + new ArrayList()); } public ContainsHintMatcher(String name, List values, - List providers) { + List providers) { this.name = name; this.values = values; this.providers = providers; @@ -238,7 +238,7 @@ public class ConfigurationMetadataMatchers { return false; } } - for (ProviderHintMatcher provider : this.providers) { + for (ValueProviderMatcher provider : this.providers) { if (!provider.matches(itemHint)) { return false; } @@ -277,9 +277,9 @@ public class ConfigurationMetadataMatchers { public ContainsHintMatcher withProvider(int index, String provider, Map parameters) { - List providers = new ArrayList( + List providers = new ArrayList( this.providers); - providers.add(new ProviderHintMatcher(index, provider, parameters)); + providers.add(new ValueProviderMatcher(index, provider, parameters)); return new ContainsHintMatcher(this.name, this.values, providers); } @@ -347,12 +347,12 @@ public class ConfigurationMetadataMatchers { } - public static class ProviderHintMatcher extends BaseMatcher { + public static class ValueProviderMatcher extends BaseMatcher { private final int index; private final String name; private final Map parameters; - public ProviderHintMatcher(int index, String name, Map parameters) { + public ValueProviderMatcher(int index, String name, Map parameters) { this.index = index; this.name = name; this.parameters = parameters; @@ -364,14 +364,14 @@ public class ConfigurationMetadataMatchers { if (this.index + 1 > hint.getProviders().size()) { return false; } - ItemHint.ProviderHint providerHint = hint.getProviders().get(this.index); - if (this.name != null && !this.name.equals(providerHint.getName())) { + 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 entry : this.parameters.entrySet()) { if (!IsMapContaining.hasEntry(entry.getKey(), entry.getValue()) - .matches(providerHint.getParameters())) { + .matches(valueProvider.getParameters())) { return false; } } @@ -381,7 +381,7 @@ public class ConfigurationMetadataMatchers { @Override public void describeTo(Description description) { - description.appendText("provider hint "); + description.appendText("value provider "); if (this.name != null) { description.appendText(" name ").appendValue(this.name); } diff --git a/spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationprocessor/metadata/JsonMarshallerTests.java b/spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationprocessor/metadata/JsonMarshallerTests.java index 1243646495..7a9bc9ffbb 100644 --- a/spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationprocessor/metadata/JsonMarshallerTests.java +++ b/spring-boot-tools/spring-boot-configuration-processor/src/test/java/org/springframework/boot/configurationprocessor/metadata/JsonMarshallerTests.java @@ -58,9 +58,9 @@ public class JsonMarshallerTests { 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.ProviderHint( + metadata.add(new ItemHint("d", null, Arrays.asList(new ItemHint.ValueProvider( "first", Collections. singletonMap("target", "foo")), - new ItemHint.ProviderHint("second", null)))); + new ItemHint.ValueProvider("second", null)))); ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); JsonMarshaller marshaller = new JsonMarshaller(); marshaller.write(metadata, outputStream);