From 3e5ceefecf67a738358bea8aedcdc0dd0eb87d41 Mon Sep 17 00:00:00 2001 From: Mark Struberg Date: Thu, 28 Jun 2018 15:07:26 +0200 Subject: [PATCH] refs: #70 remove ProjectStage from doc Also includes finishing the rename from ConfigValue to ConfigAccessor --- api/src/main/java/javax/config/Config.java | 5 +++-- .../main/java/javax/config/ConfigAccessor.java | 16 ++++++++-------- spec/src/main/asciidoc/configaccessor.asciidoc | 16 ++++++++++------ 3 files changed, 21 insertions(+), 16 deletions(-) diff --git a/api/src/main/java/javax/config/Config.java b/api/src/main/java/javax/config/Config.java index b68936c..5198557 100644 --- a/api/src/main/java/javax/config/Config.java +++ b/api/src/main/java/javax/config/Config.java @@ -146,13 +146,14 @@ public interface Config { * *
      *     // get the current host value
-     *     ConfigValue<String> hostCfg config.resolve("myapp.host")
+     *     ConfigAccessor<String> hostCfg config.resolve("myapp.host")
      *              .cacheFor(60, TimeUnit.MINUTES);
      *
      *     // and right inbetween the underlying values get changed to 'newserver' and port 8082
      *
      *     // get the current port for the host
-     *     ConfigValue<Integer> portCfg config.resolve("myapp.port")
+     *     ConfigAccessor<Integer> portCfg config.resolve("myapp.port")
+     *              .as(Integer.class)
      *              .cacheFor(60, TimeUnit.MINUTES);
      * 
* diff --git a/api/src/main/java/javax/config/ConfigAccessor.java b/api/src/main/java/javax/config/ConfigAccessor.java index 7bb553a..0305f69 100644 --- a/api/src/main/java/javax/config/ConfigAccessor.java +++ b/api/src/main/java/javax/config/ConfigAccessor.java @@ -49,7 +49,7 @@ public interface ConfigAccessor { /** * Sets the type of the configuration entry to the given class and returns this builder. - * The default type of a ConfigValue is {@code String}. + * The default type of a ConfigAccessor is {@code String}. * *

Usage: *

@@ -59,31 +59,31 @@ public interface ConfigAccessor {
      * 
* * Attention: this method should always be the first to be used and might - * return a new {@code ConfigValue} for the given target clazz. + * return a new {@code ConfigAccessor} for the given target clazz. * * * @param clazz The target type * @param The target type - * @return This builder as a typed ConfigValue + * @return This builder as a typed ConfigAccessor */ ConfigAccessor as(Class clazz); /** - * Declare the ConfigValue to return a List of the given Type. + * Declare the ConfigAccessor to return a List of the given Type. * When getting value it will be split on each comma (',') character. * If a comma is contained in the values it must get escaped with a preceding backslash ("\,"). * Any backslash needs to get escaped via double-backslash ("\\"). * Note that in property files this leads to "\\\\" as properties escape themselves. * - * @return a ConfigValue for a list of configured comma separated values + * @return a ConfigAccessor for a list of configured comma separated values */ ConfigAccessor> asList(); /** - * Declare the ConfigValue to return a Set of the given Type. + * Declare the ConfigAccessor to return a Set of the given Type. * The notation and escaping rules are the same like explained in {@link #asList()} * - * @return a ConfigValue for a list of configured comma separated values + * @return a ConfigAccessor for a list of configured comma separated values */ ConfigAccessor> asSet(); @@ -91,7 +91,7 @@ public interface ConfigAccessor { * Defines a {@link Converter} to be used instead of the default Converter resolving logic. * * @param converter The converter for the target type - * @return This builder as a typed ConfigValue + * @return This builder as a typed ConfigAccessor */ ConfigAccessor useConverter(Converter converter); diff --git a/spec/src/main/asciidoc/configaccessor.asciidoc b/spec/src/main/asciidoc/configaccessor.asciidoc index 06dbe0d..1d75afc 100644 --- a/spec/src/main/asciidoc/configaccessor.asciidoc +++ b/spec/src/main/asciidoc/configaccessor.asciidoc @@ -22,27 +22,31 @@ == ConfigAccessor -The `ConfigValue` API is intended for typed configuration values and precise control over resolution. +The `ConfigAccessor` API is intended for typed configuration values and precise control over resolution. === ConfigAccessor Usage The simplest usage of the API is resolution of a String property, equivalent to a call to `Config.getValue(propertyKey, String.class)`. -This can also be handled via `ConfigValue` as shown in the following example: +This can also be handled via `ConfigAccessor` as shown in the following example: -.Simple example of ConfigValue +.Simple example of ConfigAccessor [source,java] ----------------------------------------------------------------- -String userName = config.access("user.name").getValue(); +Config config = ConfigProvider.getConfig(); +ConfigAccessor ftpPortCfg = config.access("myapp.someftp.port") + .as(Integer.class); +... +Integer port = ftpPortCfg.getValue(); ----------------------------------------------------------------- -The call to `Config.access(..)` returns a builder which has methods to refine the resolution, including the +The call to `config.access(..)` returns a builder which has methods to refine the resolution, including the following: * `as(Class clazz)` -- defines the return type of the property +* `asList()` -- * `parameterizedBy(String propertyName)` -- sets a parameter for the resolution, similarly as in <<_getpropertyawarepropertyvalue, ConfigResolver.getPropertyAwarePropertyValue>> -* `withCurrentProjectStage(boolean with)` -- indicates whether the current ProjectStage should be taken into account for the resolution * `strictly(boolean strictly)` -- indicates, whether the <<_property_value_resolution_sequence, property value resolution sequence>> should be taken into account. When set to true, the sequence is not followed.