TAMAYA-274 Reduced API footprint by using Java 8 features. Added some lambdas. TAMAYA-355 Enable mapping of lists and arrays into internal datastructures. TAMAYA-353 Adding support for different classloaders.
Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/commit/67ffcbf2 Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/tree/67ffcbf2 Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/diff/67ffcbf2 Branch: refs/heads/master Commit: 67ffcbf274ca838a2c7dbedf9661a389a428e68d Parents: e45effd Author: Anatole Tresch <[email protected]> Authored: Sat Nov 3 01:46:21 2018 +0100 Committer: Anatole Tresch <[email protected]> Committed: Sat Nov 3 01:46:22 2018 +0100 ---------------------------------------------------------------------- .../java/org/apache/tamaya/Configuration.java | 21 +- .../java/org/apache/tamaya/TypeLiteral.java | 4 +- .../apache/tamaya/spi/ConfigurationBuilder.java | 35 +- .../apache/tamaya/spi/ConfigurationContext.java | 29 +- .../tamaya/spi/ConfigurationContextBuilder.java | 27 +- .../apache/tamaya/spi/ConversionContext.java | 38 +- .../org/apache/tamaya/spi/FilterContext.java | 36 +- .../java/org/apache/tamaya/spi/ListValue.java | 327 ++++++++++ .../java/org/apache/tamaya/spi/ObjectValue.java | 304 ++++++++++ .../apache/tamaya/spi/PropertyConverter.java | 10 +- .../org/apache/tamaya/spi/PropertyFilter.java | 6 +- .../org/apache/tamaya/spi/PropertySource.java | 16 +- .../tamaya/spi/PropertySourceProvider.java | 2 +- .../org/apache/tamaya/spi/PropertyValue.java | 602 +++++++------------ .../apache/tamaya/spi/PropertyValueBuilder.java | 36 +- .../spi/PropertyValueCombinationPolicy.java | 16 +- .../org/apache/tamaya/spi/ServiceContext.java | 92 ++- .../tamaya/spi/ServiceContextManager.java | 1 + .../tamaya/ConfigurationProviderTest.java | 2 +- .../org/apache/tamaya/TestConfiguration.java | 2 +- .../spi/ConfigurationProviderSpiTest.java | 2 +- .../apache/tamaya/spi/FilterContextTest.java | 8 +- .../tamaya/spi/PropertyValueBuilderTest.java | 8 +- .../apache/tamaya/spi/PropertyValueTest.java | 250 ++++---- .../tamaya/spi/ServiceContextManagerTest.java | 17 +- .../apache/tamaya/spi/ServiceContextTest.java | 20 +- .../spi/TestLowerOrdinalServiceContext.java | 26 + .../apache/tamaya/spi/TestServiceContext.java | 81 ++- .../tamaya/core/internal/BannerManager.java | 2 +- .../core/internal/CoreConfigurationBuilder.java | 4 +- .../core/internal/OSGIServiceComparator.java | 4 +- .../core/internal/OSGIServiceContext.java | 112 +++- .../tamaya/core/internal/OSGIServiceLoader.java | 4 +- .../converters/BigIntegerConverter.java | 4 +- .../internal/converters/BooleanConverter.java | 2 +- .../core/internal/converters/ByteConverter.java | 16 +- .../core/internal/converters/CharConverter.java | 8 +- .../core/internal/converters/ConvertQuery.java | 2 +- .../internal/converters/CurrencyConverter.java | 2 +- .../internal/converters/DoubleConverter.java | 2 +- .../core/internal/converters/FileConverter.java | 2 +- .../internal/converters/FloatConverter.java | 4 +- .../internal/converters/IntegerConverter.java | 18 +- .../core/internal/converters/LongConverter.java | 18 +- .../internal/converters/NumberConverter.java | 2 +- .../internal/converters/OptionalConverter.java | 2 +- .../core/internal/converters/PathConverter.java | 2 +- .../internal/converters/ShortConverter.java | 16 +- .../internal/converters/SupplierConverter.java | 4 +- .../core/internal/converters/URIConverter.java | 2 +- .../core/internal/converters/URLConverter.java | 2 +- .../apache/tamaya/core/TestPropertySource.java | 2 +- .../java/org/apache/tamaya/core/internal/C.java | 4 +- .../core/internal/OSGIServiceContextTest.java | 2 +- .../converters/BigDecimalConverterTest.java | 10 +- .../converters/BigIntegerConverterTest.java | 10 +- .../converters/BooleanConverterTest.java | 6 +- .../internal/converters/ByteConverterTest.java | 8 +- .../internal/converters/CharConverterTest.java | 2 +- .../converters/DoubleConverterTest.java | 22 +- .../internal/converters/FloatConverterTest.java | 22 +- .../converters/IntegerConverterTest.java | 12 +- .../internal/converters/LongConverterTest.java | 12 +- .../converters/NumberConverterTest.java | 16 +- .../internal/converters/ShortConverterTest.java | 2 +- .../core/testdata/TestPropertyFilter.java | 5 +- .../testdata/TestRemovingPropertyFilter.java | 6 +- .../tamaya/spisupport/ConfigValueEvaluator.java | 10 +- .../tamaya/spisupport/DefaultConfiguration.java | 28 +- .../spisupport/DefaultConfigurationBuilder.java | 21 +- .../spisupport/DefaultConfigurationContext.java | 18 +- .../DefaultConfigurationContextBuilder.java | 17 + .../spisupport/DefaultMetaDataProvider.java | 109 ++++ .../spisupport/DefaultServiceContext.java | 100 ++- .../apache/tamaya/spisupport/EnumConverter.java | 7 +- .../tamaya/spisupport/MetadataProvider.java | 75 +++ .../spisupport/PriorityServiceComparator.java | 4 +- .../spisupport/PropertyConverterManager.java | 16 +- .../tamaya/spisupport/PropertyFiltering.java | 14 +- .../spisupport/PropertySourceComparator.java | 8 +- .../propertysource/BasePropertySource.java | 2 +- .../propertysource/BuildablePropertySource.java | 4 +- .../propertysource/CLIPropertySource.java | 2 +- .../EnvironmentPropertySource.java | 8 +- .../propertysource/SimplePropertySource.java | 2 +- .../propertysource/SystemPropertySource.java | 2 +- .../java/org/apache/tamaya/spisupport/C.java | 4 +- .../spisupport/DefaultConfigurationTest.java | 2 +- .../spisupport/DefaultServiceContextTest.java | 17 + .../spisupport/EmptyConfigurationContext.java | 83 --- .../EmptyConfigurationContextBuilder.java | 12 +- .../spisupport/MockedConfigurationContext.java | 12 +- .../spisupport/RegexPropertyFilterTest.java | 2 +- .../EnvironmentPropertySourceTest.java | 4 +- .../services/DefaultServiceContext.java | 86 ++- .../examples/custompropertysource/Main.java | 3 +- .../SimplePropertySource.java | 4 +- 97 files changed, 2040 insertions(+), 1029 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/67ffcbf2/code/api/src/main/java/org/apache/tamaya/Configuration.java ---------------------------------------------------------------------- diff --git a/code/api/src/main/java/org/apache/tamaya/Configuration.java b/code/api/src/main/java/org/apache/tamaya/Configuration.java index 7363a8f..e84add0 100644 --- a/code/api/src/main/java/org/apache/tamaya/Configuration.java +++ b/code/api/src/main/java/org/apache/tamaya/Configuration.java @@ -25,6 +25,7 @@ import org.apache.tamaya.spi.ServiceContextManager; import java.util.Collections; import java.util.Map; +import java.util.Objects; import java.util.Optional; import java.util.function.Function; import java.util.function.UnaryOperator; @@ -58,7 +59,7 @@ public interface Configuration { * Access a property. * * @param key the property's key, not {@code null}. - * @return the property's value. + * @return the property's createValue. */ default String get(String key){ return get(key, TypeLiteral.of(String.class)); @@ -68,7 +69,7 @@ public interface Configuration { * Access a property. * * @param key the property's key, not {@code null}. - * @param defaultValue value to be returned, if no value is present, not {@code null} + * @param defaultValue createValue to be returned, if no createValue is present, not {@code null} * @return the property's keys. */ default String getOrDefault(String key, String defaultValue){ @@ -118,8 +119,8 @@ public interface Configuration { * @param key the property's absolute, or relative path, e.g. {@code * a/b/c/d.myProperty}, not {@code null}. * @param type The target type required, not {@code null}. - * @param defaultValue value to be used, if no value is present, not {@code null} - * @return the property value, never {@code null}. + * @param defaultValue createValue to be used, if no createValue is present, not {@code null} + * @return the property createValue, never {@code null}. * @throws ConfigException if the keys could not be converted to the required target type. */ default <T> T getOrDefault(String key, Class<T> type, T defaultValue){ @@ -135,7 +136,7 @@ public interface Configuration { * @param key the property's absolute, or relative path, e.g. @code * a/b/c/d.myProperty}. * @param type The target type required, not {@code null}. - * @return the property value, never {@code null}. + * @return the property createValue, never {@code null}. * @throws ConfigException if the keys could not be converted to the required target type. */ default <T> T get(String key, Class<T> type){ @@ -151,7 +152,7 @@ public interface Configuration { * @param key the property's absolute, or relative path, e.g. @code * a/b/c/d.myProperty}, not {@code null}. * @param type The target type required, not {@code null}. - * @return the property value, never {@code null}. + * @return the property createValue, never {@code null}. * @throws ConfigException if the keys could not be converted to the required target type. */ <T> T get(String key, TypeLiteral<T> type); @@ -165,8 +166,8 @@ public interface Configuration { * @param key the property's absolute, or relative path, e.g. * {@code a/b/c/d.myProperty}, not {@code null}. * @param type The target type required, not {@code null}. - * @param defaultValue default value to be used, if no value is present. - * @return the property value, never null. + * @param defaultValue default createValue to be used, if no createValue is present. + * @return the property createValue, never null. * @throws ConfigException if the keys could not be converted to the required target type. */ <T> T getOrDefault(String key, TypeLiteral<T> type, T defaultValue); @@ -190,6 +191,7 @@ public interface Configuration { */ @Deprecated default Configuration with(ConfigOperator operator){ + Objects.requireNonNull(operator, "Operator must be given."); return operator.operate(this); } @@ -201,6 +203,7 @@ public interface Configuration { * @return the new adjusted configuration returned by the {@code operator}, never {@code null}. */ default Configuration map(UnaryOperator<Configuration> operator){ + Objects.requireNonNull(operator, "Operator must be given."); return operator.apply(this); } @@ -214,6 +217,7 @@ public interface Configuration { */ @Deprecated default <T> T query(ConfigQuery<T> query){ + Objects.requireNonNull(query, "Query must be given."); return query.query(this); } @@ -225,6 +229,7 @@ public interface Configuration { * @return the result returned by the {@code query}. */ default <T> T adapt(Function<Configuration, T> query){ + Objects.requireNonNull(query, "Adapter must be given."); return query.apply(this); } http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/67ffcbf2/code/api/src/main/java/org/apache/tamaya/TypeLiteral.java ---------------------------------------------------------------------- diff --git a/code/api/src/main/java/org/apache/tamaya/TypeLiteral.java b/code/api/src/main/java/org/apache/tamaya/TypeLiteral.java index 685509e..a3586fb 100644 --- a/code/api/src/main/java/org/apache/tamaya/TypeLiteral.java +++ b/code/api/src/main/java/org/apache/tamaya/TypeLiteral.java @@ -29,7 +29,7 @@ import java.util.Objects; * <p>Class for instantiation of objects that represent parameterized types * with current parameters.</p> * - * <p>An object that represents a parameterized type may be obtained by + * <p>An createObject that represents a parameterized type may be obtained by * subclassing {@link TypeLiteral}.</p> * * <pre> @@ -120,7 +120,7 @@ public class TypeLiteral<T> implements Serializable { /** * Returns basic raw Java type. * - * @return the actual type represented by this object + * @return the actual type represented by this createObject */ @SuppressWarnings("unchecked") public final Class<T> getRawType() { http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/67ffcbf2/code/api/src/main/java/org/apache/tamaya/spi/ConfigurationBuilder.java ---------------------------------------------------------------------- diff --git a/code/api/src/main/java/org/apache/tamaya/spi/ConfigurationBuilder.java b/code/api/src/main/java/org/apache/tamaya/spi/ConfigurationBuilder.java index 586faac..0d42cf6 100644 --- a/code/api/src/main/java/org/apache/tamaya/spi/ConfigurationBuilder.java +++ b/code/api/src/main/java/org/apache/tamaya/spi/ConfigurationBuilder.java @@ -44,10 +44,18 @@ public interface ConfigurationBuilder { * {@code setServiceContext(ServiceContextManager.getServiceContext(classLoader))}. * @param classLoader the classloader, not null. * @return the builder for chaining. + * @see #getClassLoader() */ ConfigurationBuilder setClassLoader(ClassLoader classLoader); /** + * Get the classloader used by this builder. + * @return the classloader, never null. + * @see #setClassLoader(ClassLoader) + */ + ClassLoader getClassLoader(); + + /** * Sets the ServiceContext to be used. * @param serviceContext the serviceContext, nuo null. * @return this instance for chaining. @@ -83,7 +91,7 @@ public interface ConfigurationBuilder { /** * This method can be used for adding {@link PropertySource}s. * Hereby the property source is added to the tail of property sources with - * lowest priority regardless of its current ordinal value. To sort the property + * lowest priority regardless of its current ordinal createValue. To sort the property * sources based on their ordinals call {@link #sortPropertySources}. * * @param propertySources the {@link PropertySource}s to add @@ -96,9 +104,24 @@ public interface ConfigurationBuilder { } /** + * Adds (overrides existing value) the given sources as property sources. + * @param key the key, not null. + * @param value the value, not null. + * @return the current configuration builder. + */ + ConfigurationBuilder setMeta(String key, String value); + + /** + * Adds (overrides existing value with same same keys) the given sources as property sources. + * @param metaData the metadata, not null. + * @return the current configuration builder. + */ + ConfigurationBuilder setMeta(Map<String, String> metaData); + + /** * This method can be used for programmatically adding {@link PropertySource}s. * Hereby the property source is added to the tail of property sources with - * lowest priority regardless of its current ordinal value. To sort the property + * lowest priority regardless of its current ordinal createValue. To sort the property * sources based on their ordinals call {@link #sortPropertySources}. * * @param propertySources the {@link PropertySource}s to add @@ -137,7 +160,7 @@ public interface ConfigurationBuilder { ConfigurationBuilder removePropertySources(Collection<PropertySource> propertySources); /** - * Access the current chain of property sources. Items at the end of the list have + * Access the current chain of property sources. Items at the end of the createList have * precedence/higher significance. * * @return the property source chain, never {@code null}. @@ -145,7 +168,7 @@ public interface ConfigurationBuilder { List<PropertySource> getPropertySources(); /** - * Access the current chain of property filters. Items at the end of the list have + * Access the current chain of property filters. Items at the end of the createList have * precedence/higher significance. * * @return the property filter chain, never {@code null}. @@ -211,7 +234,7 @@ public interface ConfigurationBuilder { /** * Adds the given {@link PropertyFilter} instances, hereby the instances are added - * to the end of the list with highest priority. The ordering of existing + * to the end of the createList with highest priority. The ordering of existing * property filters remains unchanged. To sort the property * filters call {@link #sortPropertyFilter}. * @@ -224,7 +247,7 @@ public interface ConfigurationBuilder { /** * Adds the given {@link PropertyFilter} instances, hereby the instances are added - * to the end of the list with highest priority. The ordering of existing + * to the end of the createList with highest priority. The ordering of existing * property filters remains unchanged. To sort the property * filters call {@link #sortPropertyFilter}. * http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/67ffcbf2/code/api/src/main/java/org/apache/tamaya/spi/ConfigurationContext.java ---------------------------------------------------------------------- diff --git a/code/api/src/main/java/org/apache/tamaya/spi/ConfigurationContext.java b/code/api/src/main/java/org/apache/tamaya/spi/ConfigurationContext.java index c85d73c..8edb13b 100644 --- a/code/api/src/main/java/org/apache/tamaya/spi/ConfigurationContext.java +++ b/code/api/src/main/java/org/apache/tamaya/spi/ConfigurationContext.java @@ -21,6 +21,7 @@ package org.apache.tamaya.spi; import org.apache.tamaya.TypeLiteral; +import java.util.Collection; import java.util.Collections; import java.util.List; import java.util.Map; @@ -32,6 +33,11 @@ import java.util.Map; */ public interface ConfigurationContext { + /** + * Get the metadata evaluated for this configuration. + * @return the metadata accessor, never null. + */ + Map<String,String> getMetadata(); /** * Access the underlying {@link ServiceContext}. @@ -44,14 +50,14 @@ public interface ConfigurationContext { * It is not needed for normal 'usage' by end users, but only for Extension Developers! * * @param propertySources the {@link PropertySource}s to add - * @deprecated Use {@link ConfigurationContextBuilder} to create a new {@link ConfigurationContext}. + * @deprecated Use {@link ConfigurationContextBuilder} to createObject a new {@link ConfigurationContext}. * @see #toBuilder() */ @Deprecated void addPropertySources(PropertySource... propertySources); /** - * This method returns the current list of registered {@link PropertySource}s ordered via their ordinal. + * This method returns the current createList of registered {@link PropertySource}s ordered via their ordinal. * {@link PropertySource}s with a lower ordinal come last. The {@link PropertySource} with the * highest ordinal comes first. * If two {@link PropertySource}s have the same ordinal number they will current sorted @@ -60,7 +66,7 @@ public interface ConfigurationContext { * {@link PropertySource}s are loaded when this method is called the first time, which basically is * when the first time configuration is accessed. * - * @return a sorted list of registered {@link PropertySource}s. The returned list need not be modifiable + * @return a sorted createList of registered {@link PropertySource}s. The returned createList need not be modifiable */ List<PropertySource> getPropertySources(); @@ -78,7 +84,7 @@ public interface ConfigurationContext { * @param <T> the type of the type literal * @param type the type which the converters is for * @param propertyConverter the PropertyConverters to add for this type - * @deprecated Use {@link ConfigurationContextBuilder} to create a new {@link ConfigurationContext}. + * @deprecated Use {@link ConfigurationContextBuilder} to createObject a new {@link ConfigurationContext}. * @see #toBuilder() */ @Deprecated @@ -102,7 +108,7 @@ public interface ConfigurationContext { * } * </pre> * - * @return map with sorted list of registered {@link PropertySource}s per type. + * @return map with sorted createList of registered {@link PropertySource}s per type. */ Map<TypeLiteral<?>, List<PropertyConverter<?>>> getPropertyConverters(); @@ -124,7 +130,7 @@ public interface ConfigurationContext { * Additionally, if a PropertyProvider is accessed which is not registered, the implementation * should try to figure out if there could be a default implementation as follows:</p> * <ol> - * <li>Look for static factory methods: {@code of(String), valueOf(String), getInstance(String), + * <li>Look for static factory methods: {@code of(String), createValue(String), getInstance(String), * instanceOf(String), fomr(String)}</li> * <li>Look for a matching constructor: {@code T(String)}.</li> * </ol> @@ -147,20 +153,20 @@ public interface ConfigurationContext { * * <p> * The converters returned for a type should be used as a chain, whereas the result of the - * first converters that is able to convert the configured value, is taken as the chain's result. + * first converters that is able to convert the configured createValue, is taken as the chain's result. * No more converters are called after a converter has successfully converted the input into * the required target type. * </p> * * @param <T> the type of the type literal * @param type type of the desired converters - * @return a sorted list of registered {@link PropertySource}s per type. + * @return a sorted createList of registered {@link PropertySource}s per type. */ <T> List<PropertyConverter<T>> getPropertyConverters(TypeLiteral<T> type); /** * Access the current {@link PropertyFilter} instances. - * @return the list of registered {@link PropertyFilter}s, never null. + * @return the createList of registered {@link PropertyFilter}s, never null. */ List<PropertyFilter> getPropertyFilters(); @@ -184,6 +190,11 @@ public interface ConfigurationContext { */ ConfigurationContext EMPTY = new ConfigurationContext() { @Override + public Map<String,String> getMetadata() { + return Collections.emptyMap(); + } + + @Override public ServiceContext getServiceContext() { return ServiceContextManager.getServiceContext(getClass().getClassLoader()); } http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/67ffcbf2/code/api/src/main/java/org/apache/tamaya/spi/ConfigurationContextBuilder.java ---------------------------------------------------------------------- diff --git a/code/api/src/main/java/org/apache/tamaya/spi/ConfigurationContextBuilder.java b/code/api/src/main/java/org/apache/tamaya/spi/ConfigurationContextBuilder.java index e3b73cb..5e7ad49 100644 --- a/code/api/src/main/java/org/apache/tamaya/spi/ConfigurationContextBuilder.java +++ b/code/api/src/main/java/org/apache/tamaya/spi/ConfigurationContextBuilder.java @@ -69,9 +69,22 @@ public interface ConfigurationContextBuilder { ConfigurationContextBuilder setContext(ConfigurationContext context); /** + * Adds the metadata map to be used. + * @param metaData the metadata map, not null. + */ + ConfigurationContextBuilder addMetaData(Map<String,String> metaData); + + /** + * Adds the metadata map to be used. + * @param key the key, not null. + * @param value the value, not null. + */ + ConfigurationContextBuilder addMetaData(String key, String value); + + /** * This method can be used for adding {@link PropertySource}s. * Hereby the property source is added to the tail of property sources with - * lowest priority regardless of its current ordinal value. To sort the property + * lowest priority regardless of its current ordinal createValue. To sort the property * sources based on their ordinals call {@link #sortPropertySources}. * * @param propertySources the PropertySources to add @@ -84,7 +97,7 @@ public interface ConfigurationContextBuilder { /** * This method can be used for programmatically adding {@link PropertySource}s. * Hereby the property source is added to the tail of property sources with - * lowest priority regardless of its current ordinal value. To sort the property + * lowest priority regardless of its current ordinal createValue. To sort the property * sources based on their ordinals call {@link #sortPropertySources}. * * @param propertySources the PropertySources to add @@ -121,7 +134,7 @@ public interface ConfigurationContextBuilder { ConfigurationContextBuilder removePropertySources(Collection<PropertySource> propertySources); /** - * Access the current chain of property sources. Items at the end of the list have + * Access the current chain of property sources. Items at the end of the createList have * precedence/more significance. * * @return the property source chain, never {@code null}. @@ -129,7 +142,7 @@ public interface ConfigurationContextBuilder { List<PropertySource> getPropertySources(); /** - * Access the current chain of property filters. Items at the end of the list have + * Access the current chain of property filters. Items at the end of the createList have * precedence/more significance. * * @return the property source chain, never {@code null}. @@ -195,7 +208,7 @@ public interface ConfigurationContextBuilder { /** * Adds the given PropertyFilter instances, hereby the instances are added - * to the end of the list with highest priority. The ordering of existing + * to the end of the createList with highest priority. The ordering of existing * property filters remains unchanged. To sort the property * filters call {@link #sortPropertyFilter}. * @@ -206,7 +219,7 @@ public interface ConfigurationContextBuilder { /** * Adds the given PropertyFilter instances, hereby the instances are added - * to the end of the list with highest priority. The ordering of existing + * to the end of the createList with highest priority. The ordering of existing * property filters remains unchanged. To sort the property * filters call {@link #sortPropertyFilter}. * @@ -348,7 +361,7 @@ public interface ConfigurationContextBuilder { * ordering/significance call {@link #sortPropertyFilter(Comparator)} and/or {@link #sortPropertySources(Comparator)} * before building the context. * - * @return the final context to be used to create a configuration. + * @return the final context to be used to createObject a configuration. * @see org.apache.tamaya.ConfigurationProvider#createConfiguration(ConfigurationContext) */ ConfigurationContext build(); http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/67ffcbf2/code/api/src/main/java/org/apache/tamaya/spi/ConversionContext.java ---------------------------------------------------------------------- diff --git a/code/api/src/main/java/org/apache/tamaya/spi/ConversionContext.java b/code/api/src/main/java/org/apache/tamaya/spi/ConversionContext.java index 1c5f626..3631d5a 100644 --- a/code/api/src/main/java/org/apache/tamaya/spi/ConversionContext.java +++ b/code/api/src/main/java/org/apache/tamaya/spi/ConversionContext.java @@ -93,8 +93,8 @@ public class ConversionContext { /** * Get the key accessed. This information is very useful to evaluate additional metadata needed to determine/ * control further aspects of the conversion. - * @return the key. This may be null in case where a default value has to be converted and no unique underlying - * key/value configuration is present. + * @return the key. This may be null in case where a default createValue has to be converted and no unique underlying + * key/createValue configuration is present. */ public String getKey(){ return key; @@ -133,9 +133,29 @@ public class ConversionContext { return configuration; } + + /** + * Evaluate the current metadata from the given values. Later values hereby are more significant. + * @return the evaluated meta data map. + */ + public Map<String, String> getMeta() { + Map<String, String> metaMap = new HashMap<>(); + if(values.size()>0){ + String baseKey = values.get(0).getQualifiedKey()+"."; + + values.forEach(val -> this.getConfiguration().getContext().getMetadata().entrySet().forEach( + en -> { + if(en.getKey().startsWith(baseKey)) { + metaMap.put(en.getKey().substring(baseKey.length()), en.getValue()); + } + })); + } + return metaMap; + } + /** * Allows to add information on the supported/tried formats, which can be shown to the user, especially when - * conversion failed. Adding of formats is synchronized, all formats are added in order to the overall list. + * conversion failed. Adding of formats is synchronized, all formats are added in order to the overall createList. * This means formats should be passed in order of precedence. * @param converterType the converters, which implements the formats provided. * @param formatDescriptors the format descriptions in a human readable form, e.g. as regular expressions. @@ -181,7 +201,7 @@ public class ConversionContext { } /** - * Builder to create new instances of {@link ConversionContext}. + * Builder to createObject new instances of {@link ConversionContext}. */ public static final class Builder{ /** The backing configuration. */ @@ -249,6 +269,16 @@ public class ConversionContext { } /** + * Sets the underlying values evaluated. + * @param values the values, not {@code null}. + * @return the builder instance, for chaining + */ + public Builder setValues(PropertyValue... values){ + this.values.addAll(Arrays.asList(values)); + return this; + } + + /** * Sets the configuration. * @param configuration the configuration, not {@code null} * @return the builder instance, for chaining http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/67ffcbf2/code/api/src/main/java/org/apache/tamaya/spi/FilterContext.java ---------------------------------------------------------------------- diff --git a/code/api/src/main/java/org/apache/tamaya/spi/FilterContext.java b/code/api/src/main/java/org/apache/tamaya/spi/FilterContext.java index 2d3f155..49af39d 100644 --- a/code/api/src/main/java/org/apache/tamaya/spi/FilterContext.java +++ b/code/api/src/main/java/org/apache/tamaya/spi/FilterContext.java @@ -76,10 +76,10 @@ public class FilterContext { /** - * Creates a new FilterContext, for filtering of a multi value access + * Creates a new FilterContext, for filtering of a multi createValue access * using {@link Configuration#getProperties()}. * - * @param value the value under evaluation, not {@code null}. + * @param value the createValue under evaluation, not {@code null}. * @param configEntries the raw configuration data available in the * current evaluation context, not {@code null}. * @param context the current context, not {@code null}. @@ -97,9 +97,9 @@ public class FilterContext { } /** - * Creates a new FilterContext, for filtering of a single value access + * Creates a new FilterContext, for filtering of a single createValue access * using {@link Configuration#getProperties()}. - * @param value the value under evaluation, not {@code null}. + * @param value the createValue under evaluation, not {@code null}. * @param context the current context, not {@code null}. */ public FilterContext(PropertyValue value, ConfigurationContext context) { @@ -113,9 +113,9 @@ public class FilterContext { } /** - * Creates a new FilterContext, for filtering of a single value access + * Creates a new FilterContext, for filtering of a single createValue access * using {@link Configuration#getProperties()}. - * @param values the value under evaluation, not {@code null}. + * @param values the createValue under evaluation, not {@code null}. * @param context the current context, not {@code null}. */ public FilterContext(List<PropertyValue> values, ConfigurationContext context) { @@ -137,22 +137,22 @@ public class FilterContext { } /** - * Get the property value under evaluation. This information is very useful to evaluate additional metadata needed to determine/ + * Get the property createValue under evaluation. This information is very useful to evaluate additional metadata needed to determine/ * control further aspects of the conversion. * - * @return the key. This may be null in case where a default value has to be converted and no unique underlying - * key/value configuration is present. + * @return the key. This may be null in case where a default createValue has to be converted and no unique underlying + * key/createValue configuration is present. */ public PropertyValue getProperty() { return values.get(0); } /** - * Get the property value under evaluation. This information is very useful to evaluate additional metadata needed to determine/ + * Get the property createValue under evaluation. This information is very useful to evaluate additional metadata needed to determine/ * control further aspects of the conversion. * - * @return the key. This may be null in case where a default value has to be converted and no unique underlying - * key/value configuration is present. + * @return the key. This may be null in case where a default createValue has to be converted and no unique underlying + * key/createValue configuration is present. */ public List<PropertyValue> getAllValues() { return values; @@ -171,16 +171,16 @@ public class FilterContext { /** * This map contains the following keys: * <ul> - * <li>the original value <b>before</b> any filters were applied on it.</li> - * <li>all values starting with an {@code _<key>.}, for example {@code a.value} - * may have a map setCurrent with {@code a.value} (oringinal value), {@code _a.value.origin, - * _a.value.type, etc}. The exact contents is determine by the {@link PropertySource}s + * <li>the original createValue <b>before</b> any filters were applied on it.</li> + * <li>all values starting with an {@code _<key>.}, for example {@code a.createValue} + * may have a map setCurrent with {@code a.createValue} (oringinal createValue), {@code _a.createValue.origin, + * _a.createValue.type, etc}. The exact contents is determine by the {@link PropertySource}s * active.</li> * </ul> * Also important to know is that this map given contains all the evaluated raw entries, regardless * of the filters that are later applied. This ensures that met-information required by one filter is * not hidden by another filter, because of an invalid filter ordering. In other words filters may remove - * key/value pairs, e.g. fir security reasons, by returning {@code null}, but the values in the raw map + * key/createValue pairs, e.g. fir security reasons, by returning {@code null}, but the values in the raw map * passed as input to the filter process will not be affected by any such removal (but the final properties * returned are affected, of course). * @@ -195,7 +195,7 @@ public class FilterContext { @Override public String toString() { - return "FilterContext{value='" + values + "', configEntries=" + configEntries.keySet() + '}'; + return "FilterContext{createValue='" + values + "', configEntries=" + configEntries.keySet() + '}'; } } http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/67ffcbf2/code/api/src/main/java/org/apache/tamaya/spi/ListValue.java ---------------------------------------------------------------------- diff --git a/code/api/src/main/java/org/apache/tamaya/spi/ListValue.java b/code/api/src/main/java/org/apache/tamaya/spi/ListValue.java new file mode 100644 index 0000000..7150d78 --- /dev/null +++ b/code/api/src/main/java/org/apache/tamaya/spi/ListValue.java @@ -0,0 +1,327 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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.apache.tamaya.spi; + +import java.util.*; +import java.util.function.Predicate; +import java.util.logging.Logger; + +/** + * Class modelling the result of a request for a property createValue. A property createValue is basically identified by its key. + * There might be reasons, where one want to further analyze, which PropertySources provided a createValue and which not, so + * it is possible to createObject a PropertyValue with a null createValue. + * + * A PropertyValue represents an abstract data point in a configuration structure read. PropertyValues actually + * represent a tree, with additional functionality for representing data lists/arrays using indexed children + * names. This allows to support a full mapping of common document based configuration formats, such as JSON, YAML, + * XML and more. + */ +public final class ListValue extends PropertyValue{ + + private static final long serialVersionUID = 1L; + + private static final Logger LOG = Logger.getLogger(ListValue.class.getName()); + /** List of child properties. */ + private List<PropertyValue> list = new ArrayList<>(); + + /** + * Creates a new instance + * @param key the key, not {@code null}. + * @param parent the parent. + */ + ListValue(PropertyValue parent, String key){ + super(parent, key, ValueType.ARRAY); + } + + public int getIndex(PropertyValue member) { + return this.list.indexOf(member); + } + + /** + * Get the createValue's number of elements. + * @return the getNumChilds of this multi createValue. + */ + @Override + public int getSize() { + return this.list.size(); + } + + /** + * The createValue. + * @return the createValue, in case a createValue is null it is valid to return {#code null} as result for + * {@link PropertySource#get(String)}. + */ + public List<PropertyValue> getList() { + return Collections.unmodifiableList(this.list); + } + + @Override + public Iterator<PropertyValue> iterator() { + return Collections.unmodifiableList(this.list).iterator(); + } + + /** + * Adds a createValue to the array. + * @param value the createValue, not null + * @return this instance, for chaining. + * @throws IllegalStateException if the instance is immutable. + * @see #isImmutable() + */ + public <T extends PropertyValue> T add(T value) { + checkImmutable(); + value.setParent(this); + this.list.add(value); + return value; + } + + /** + * Adds an named text createValue to the array. + * @param value the child's createValue, not null. + * @return the created createValue, not null. + * @throws IllegalStateException if the instance is immutable. + * @see #isImmutable() + */ + public PropertyValue addValue(String key, String value) { + return add(new PropertyValue(this,key, ValueType.VALUE, value)); + } + + /** + * Adds an anonymous text createValue to the array. + * @param value the child's createValue, not null. + * @return the created createValue, not null. + * @throws IllegalStateException if the instance is immutable. + * @see #isImmutable() + */ + public PropertyValue addValue(String value) { + return add(new PropertyValue(this,"", + ValueType.VALUE, value)); + } + + /** + * Adds text values to the array. + * @param values the child's values, not null. + * @return the created values, not null. + * @throws IllegalStateException if the instance is immutable. + * @see #isImmutable() + */ + public List<PropertyValue> addValues(String... values) { + List<PropertyValue> result = new ArrayList<>(); + for(String val:values) { + result.add(add(new PropertyValue(this, "", ValueType.VALUE, val))); + } + return result; + } + + /** + * Adds an anonymous child createObject to the array. + * @return the created createObject, not null. + * @throws IllegalStateException if the instance is immutable. + * @see #isImmutable() + */ + public ObjectValue addObject() { + return add(new ObjectValue(this, "")); + } + + /** + * Adds a child createObject to the array. + * @param name the child's name, not null. + * @return the created createObject, not null. + * @throws IllegalStateException if the instance is immutable. + * @see #isImmutable() + */ + public ObjectValue addObject(String name) { + return add(new ObjectValue(this,name)); + } + + /** + * Adds an anonymous array. + * @return this instance, for chaining. + * @throws IllegalStateException if the instance is immutable. + * @see #isImmutable() + */ + public ListValue addList() { + return add(new ListValue(this, "")); + } + + /** + * Adds a named array. + * @param name the child's name, not null. + * @return this instance, for chaining. + * @throws IllegalStateException if the instance is immutable. + * @see #isImmutable() + */ + public ListValue addList(String name) { + return add(new ListValue(this,name)); + } + + /** + * Get the array elements, filtered by the given predicate. + * @param filter the filter predicate, null selects all elements. + * @return this values matching, never null. + */ + public List<PropertyValue> getList(Predicate<PropertyValue> filter) { + List<PropertyValue> result = new ArrayList<>(); + if(filter==null){ + result.addAll(this.list); + }else { + this.list.forEach(el -> { + if (filter.test(el)) result.add(el); + }); + } + return result; + } + + /** + * Get the array elements, filtered by the given predicate. + * @param name the name of the objects, null selects all. + * @return this values matching, never null. + */ + public List<ObjectValue> getObjects(String name) { + List<ObjectValue> result = new ArrayList<>(); + if (name == null) { + this.list.forEach(el -> { + if (el instanceof ObjectValue) { + result.add((ObjectValue) el); + } + }); + } else { + this.list.forEach(el -> { + if (el instanceof ObjectValue && name.equals(el.getKey())) { + result.add((ObjectValue) el); + } + }); + } + return result; + } + + /** + * Get the array elements, filtered by the given name. + * @param name the name of the objects, null selects all. + * @return this values matching, never null. + */ + public List<ListValue> getLists(String name) { + List<ListValue> result = new ArrayList<>(); + if (name == null) { + this.list.forEach(el -> { + if (el instanceof ListValue) { + result.add((ListValue) el); + } + }); + } else { + this.list.forEach(el -> { + if (el instanceof ListValue && name.equals(el.getKey())) { + result.add((ListValue) el); + } + }); + } + return result; + } + + /** + * Get the text elements, filtered by the given name. + * @param name the name of the objects, null selects all. + * @return this values matching, never null. + */ + public List<PropertyValue> getValues(String name) { + List<PropertyValue> result = new ArrayList<>(); + if (name == null) { + result.addAll(this.list); + } else { + this.list.forEach(el -> { + if (name.equals(el.getKey())) { + result.add(el); + } + }); + } + return result; + } + + @Override + public PropertyValue toPropertyValue(){ + PropertyValue value = new PropertyValue(getParent(), getKey(), getValueType(), getValue()); + value.setMeta(getMeta()); + value.setVersion(getVersion()); + return value; + } + + @Override + public ObjectValue toObjectValue(){ + ObjectValue object = new ObjectValue(getParent(), getKey()); + object.setMeta(getMeta()); + object.setVersion(getVersion()); + int index = 0; + for(PropertyValue val: list){ + object.set(val.deepClone().setKey("["+index+"]")); + index++; + } + return object; + } + + @Override + public ListValue toListValue(){ + return this; + } + + /** + * Clones this instance and all it's children, marking as mutable createValue. + * @return the new createValue clone. + */ + @Override + public ListValue mutable(){ + return (ListValue)super.mutable(); + } + + @Override + protected ListValue deepClone(){ + ListValue newProp = new ListValue(getParent(), getKey()); + newProp.setMeta(getMeta()); + list.forEach(c -> newProp.add(c.mutable())); + newProp.setVersion(getVersion()); + return newProp; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (!(o instanceof ListValue)) return false; + ListValue dataNode = (ListValue) o; + return getParent() == dataNode.getParent() && + Objects.equals(getKey(), dataNode.getKey()) && + Objects.equals(getValue(), dataNode.getValue()) && + Objects.equals(list, dataNode.list) && + Objects.equals(getMeta(), dataNode.getMeta()); + } + + @Override + public int hashCode() { + return Objects.hash(getParent(), getKey(), list, getValue(), getMeta()); + } + + + @Override + public String toString() { + return "PropertyValue[ARRAY]{" + + '\'' +getQualifiedKey() + '\'' + + (getValue()!=null?", createValue='" + getValue() + '\'':"") + + ", size='" + getSize() + '\'' + + (getMeta().isEmpty()?"":", metaData=" + getMeta()) + + '}'; + } + +} http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/67ffcbf2/code/api/src/main/java/org/apache/tamaya/spi/ObjectValue.java ---------------------------------------------------------------------- diff --git a/code/api/src/main/java/org/apache/tamaya/spi/ObjectValue.java b/code/api/src/main/java/org/apache/tamaya/spi/ObjectValue.java new file mode 100644 index 0000000..b1bff87 --- /dev/null +++ b/code/api/src/main/java/org/apache/tamaya/spi/ObjectValue.java @@ -0,0 +1,304 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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.apache.tamaya.spi; + +import java.util.*; +import java.util.function.Supplier; +import java.util.logging.Logger; + +/** + * Class modelling the result of a request for a property createValue. A property createValue is basically identified by its key. + * There might be reasons, where one want to further analyze, which PropertySources provided a createValue and which not, so + * it is possible to createObject a PropertyValue with a null createValue. + * + * A PropertyValue represents an abstract data point in a configuration structure read. PropertyValues actually + * represent a tree, with additional functionality for representing data lists/arrays using indexed children + * names. This allows to support a full mapping of common document based configuration formats, such as JSON, YAML, + * XML and more. + */ +public final class ObjectValue extends PropertyValue{ + + private static final long serialVersionUID = 1L; + + private static final Logger LOG = Logger.getLogger(ObjectValue.class.getName()); + + /** List of child properties. */ + private Map<String, PropertyValue> fields = new HashMap<>(); + + + /** + * Creates a new instance + * @param key the key, not {@code null}. + * @param parent the parent. + */ + ObjectValue(PropertyValue parent, String key){ + super(parent, key, ValueType.OBJECT); + } + + /** + * Get the fields of this instance. + * @return the current fields, never null. + */ + public Map<String, PropertyValue> getFields(){ + return Collections.unmodifiableMap(this.fields); + } + + /** + * Get a single child getField by name. + * @param name the child's name, not null. + * @return the child found, or null. + * @throws IllegalArgumentException if multiple getList with the given name are existing (ambigous). + */ + public PropertyValue getField(String name){ + return this.fields.get(name); + } + + /** + * Get a single child getField with the given name, creates it if not existing. + * @param name the child's name, not null. + * @return the child found or created, never null. + * @throws IllegalArgumentException if multiple getList with the given name are existing (ambigous). + * @throws IllegalStateException if the instance is immutable. + * @see #isImmutable() + */ + public <T extends PropertyValue> T getOrSetField(String name, Supplier<T> valueSupplier){ + T field = (T)this.fields.get(name); + if(field==null){ + checkImmutable(); + field = valueSupplier.get(); + this.fields.put(name, field); + incrementVersion(); + } + return field; + } + + /** + * Get the createValue's number of elements. + * @return the getNumChilds of this multi createValue. + */ + @Override + public int getSize() { + return this.fields.size(); + } + + @Override + public PropertyValue toPropertyValue(){ + PropertyValue value = new PropertyValue(getParent(), getKey(), getValueType(), getValue()); + value.setMeta(getMeta()); + value.setVersion(getVersion()); + return value; + } + + @Override + public ObjectValue toObjectValue(){ + return this; + } + + @Override + public ListValue toListValue(){ + ListValue array = new ListValue(getParent(), getKey()); + array.setValue(getValue()); + array.setMeta(getMeta()); + array.setVersion(getVersion()); + int index = 0; + for(PropertyValue val:fields.values()){ + array.add(val.deepClone()); + } + return array; + } + + + @Override + public Iterator<PropertyValue> iterator() { + return Collections.unmodifiableCollection(this.fields.values()).iterator(); + } + + /** + * Adds a new nvalue child. + * @param name the child's name, not null. + * @return the createValue added, not null. + * @throws IllegalStateException if the instance is immutable. + * @see #isImmutable() + */ + public PropertyValue setField(String name, String value){ + return set(new PropertyValue(this, name, ValueType.VALUE, value)); + } + + /** + * Adds text values to the createObject. + * @param values the child's values, not null. + * @return the created values, not null. + * @throws IllegalStateException if the instance is immutable. + * @see #isImmutable() + */ + public Collection<PropertyValue> setFields(Map<String, String> values) { + checkImmutable(); + List<PropertyValue> result = new ArrayList<>(); + for(Map.Entry<String, String> en:values.entrySet()) { + result.add(new PropertyValue(this, en.getKey(), ValueType.VALUE, en.getValue())); + } + return result; + } + + /** + * Adds a new non-indexed child getField. + * @param name the child's name, not null. + * @return the createValue added, not null. + * @throws IllegalStateException if the instance is immutable. + * @see #isImmutable() + */ + public ListValue setFieldList(String name){ + return set(new ListValue(this, name)); + } + + /** + * Adds a new non-indexed child getField. + * @param name the child's name, not null. + * @return the createValue added, not null. + * @throws IllegalStateException if the instance is immutable. + * @see #isImmutable() + */ + public ObjectValue setFieldObject(String name){ + return set(new ObjectValue(this, name)); + } + + + /** + * Adds another existing node, hereby setting the corresponding parent node. + * @param value the createValue, not null + * @return the createValue added, not null. + * @throws IllegalStateException if the instance is immutable. + * @see #isImmutable() + */ + public <T extends PropertyValue> T set(T value) { + checkImmutable(); + value.setParent(this); + this.fields.put(value.getKey(), value); + return value; + } + + /** + * Adds a new child getField, where the getField is given in '.'-separated property notation, + * e.g. {@code a.b.c}. + * @param key the property key, e.g. {@code a.b.c} + * @param value the property createValue + * @return the new leaf-getField created. + * @throws IllegalStateException if the instance is immutable. + * @see #isImmutable() + */ + public PropertyValue setFieldWithCompositeKey(String key, String value) { + checkImmutable(); + ObjectValue node = this; + StringTokenizer tokenizer = new StringTokenizer(key, "\\.", false); + while(tokenizer.hasMoreTokens()){ + String token = tokenizer.nextToken().trim(); + if(tokenizer.hasMoreTokens()) { + node = node.getOrSetField(token, () -> PropertyValue.createObject(token)); + }else{ + return node.set(PropertyValue.createValue(token, value)); + } + } + return null; + } + + /** + * Adds multiple values, where the keys are given in '.'-separated property notation, + * e.g. {@code a.b.c}. + * @param values the values, not null. + * @return the createValue instances created. + * @throws IllegalStateException if the instance is immutable. + * @see #isImmutable() + */ + public Collection<PropertyValue> setFielsWithCompositeKey(Map<String,String> values) { + checkImmutable(); + List<PropertyValue> result = new ArrayList<>(); + for(Map.Entry<String,String> en:values.entrySet()){ + result.add(setFieldWithCompositeKey(en.getKey(), en.getValue())); + } + return result; + } + + /** + * Convert the getField tree to a property map. + * @return the corresponding property map, not null. + */ + @Override + public Map<String,String> toMap(){ + Map<String, String> map = new TreeMap<>(); + for (PropertyValue n : fields.values()) { + switch(n.getValueType()){ + case VALUE: + map.put(n.getQualifiedKey(), n.getValue()); + break; + default: + for(PropertyValue val:n) { + map.putAll(val.toMap()); + } + } + } + return map; + } + + + /** + * Clones this instance and all it's children, marking as mutable createValue. + * @return the new createValue clone. + */ + @Override + public ObjectValue mutable(){ + return (ObjectValue)super.mutable(); + } + + @Override + protected ObjectValue deepClone(){ + ObjectValue newProp = new ObjectValue(getParent(), getKey()); + newProp.setMeta(getMeta()); + fields.values().forEach(c -> newProp.set(c.mutable())); + newProp.setVersion(getVersion()); + return newProp; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (!(o instanceof ObjectValue)) return false; + ObjectValue dataNode = (ObjectValue) o; + return getParent() == dataNode.getParent() && + Objects.equals(getKey(), dataNode.getKey()) && + Objects.equals(fields, dataNode.fields) && + Objects.equals(getMeta(), dataNode.getMeta()); + } + + @Override + public int hashCode() { + return Objects.hash(getParent(), getKey(), fields, getMeta()); + } + + + @Override + public String toString() { + return "PropertyValue[OBJECT]{" + + '\'' +getQualifiedKey() + '\'' + + (getValue()!=null?", createValue='" + getValue() + '\'':"") + + ", size='" + getSize() + '\'' + + (getMeta().isEmpty()?"":", metaData=" + getMeta()) + + '}'; + } + +} http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/67ffcbf2/code/api/src/main/java/org/apache/tamaya/spi/PropertyConverter.java ---------------------------------------------------------------------- diff --git a/code/api/src/main/java/org/apache/tamaya/spi/PropertyConverter.java b/code/api/src/main/java/org/apache/tamaya/spi/PropertyConverter.java index e89e3b6..c1f93f4 100644 --- a/code/api/src/main/java/org/apache/tamaya/spi/PropertyConverter.java +++ b/code/api/src/main/java/org/apache/tamaya/spi/PropertyConverter.java @@ -23,7 +23,7 @@ import java.util.List; /** * Interface for an property that converts a configured String into something else. * This is used for implementing type conversion from a property (String) to a certain target - * type. Hereby the target type can be multi-value (e.g. collections) or complex if needed. + * type. Hereby the target type can be multi-createValue (e.g. collections) or complex if needed. * * @param <T> the type of the type literal */ @@ -32,13 +32,13 @@ public interface PropertyConverter<T>{ /** * Convert the given configuration keys from its String representation into the required target type. - * Additional context can be obtained from {@link ConversionContext}, this also allows to add a list + * Additional context can be obtained from {@link ConversionContext}, this also allows to add a createList * of supported formats, which is very handy in case a - * value could not be converted. This list of supported formats can then shown to the user to give some hints - * how a value could be configured. + * createValue could not be converted. This createList of supported formats can then shown to the user to give some hints + * how a createValue could be configured. * * @param value configuration key that needs to be converted - * @return the converted value + * @return the converted createValue * @see ConversionContext */ T convert(String value); http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/67ffcbf2/code/api/src/main/java/org/apache/tamaya/spi/PropertyFilter.java ---------------------------------------------------------------------- diff --git a/code/api/src/main/java/org/apache/tamaya/spi/PropertyFilter.java b/code/api/src/main/java/org/apache/tamaya/spi/PropertyFilter.java index 9be6ce8..c157069 100644 --- a/code/api/src/main/java/org/apache/tamaya/spi/PropertyFilter.java +++ b/code/api/src/main/java/org/apache/tamaya/spi/PropertyFilter.java @@ -29,7 +29,7 @@ package org.apache.tamaya.spi; public interface PropertyFilter{ /** - * <p>Maps the current {@code valueToBeFiltered} value to a new value. The resulting value will be used as the result + * <p>Maps the current {@code valueToBeFiltered} createValue to a new createValue. The resulting createValue will be used as the result * passed to the user.</p> * <p>If a filter is currently not available, it should just pass the input map to the method's * output.</p> @@ -40,8 +40,8 @@ public interface PropertyFilter{ * <li>reentrant</li> * <li>thread-safe</li> * </ul> - * @param value the value to be filtered, which also can be {@code null} if removed by another filter. - * @return the filtered value, or {@code null} if the value should be removed alltogether. + * @param value the createValue to be filtered, which also can be {@code null} if removed by another filter. + * @return the filtered createValue, or {@code null} if the createValue should be removed alltogether. * @see PropertyValue * @see FilterContext */ http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/67ffcbf2/code/api/src/main/java/org/apache/tamaya/spi/PropertySource.java ---------------------------------------------------------------------- diff --git a/code/api/src/main/java/org/apache/tamaya/spi/PropertySource.java b/code/api/src/main/java/org/apache/tamaya/spi/PropertySource.java index 23d42a5..8fb5480 100644 --- a/code/api/src/main/java/org/apache/tamaya/spi/PropertySource.java +++ b/code/api/src/main/java/org/apache/tamaya/spi/PropertySource.java @@ -90,7 +90,7 @@ public interface PropertySource{ /** - * The ordinal value is the default ordering parameter which definines the default order of + * The ordinal createValue is the default ordering parameter which definines the default order of * auto-discovered property sources. Ordering of property sources is important since values * from property sources with higher ordinal values override values from less significant * property sources. @@ -105,10 +105,10 @@ public interface PropertySource{ * * <p><b>Important Hints for custom implementations</b>:</p> * <p> - * If a custom implementation should be invoked <b>before</b> the default implementations, use a value > 1000 + * If a custom implementation should be invoked <b>before</b> the default implementations, use a createValue > 1000 * </p> * <p> - * If a custom implementation should be invoked <b>after</b> the default implementations, use a value < 100 + * If a custom implementation should be invoked <b>after</b> the default implementations, use a createValue < 100 * </p> * * <p>Reordering of the default order of the config-sources:</p> @@ -117,7 +117,7 @@ public interface PropertySource{ * /META-INF/javaconfiguration.properties . Hint: In case of property files every file is handled as independent * config-source, but all of them have ordinal 400 by default (and can be reordered in a fine-grained manner.</p> * - * In cases where it is not possible to change a config sources ordinal value, you may have several options: + * In cases where it is not possible to change a config sources ordinal createValue, you may have several options: * <ul> * <li>you can register an alternate implementation of {@link PropertyValueCombinationPolicy}.</li> * <li>you can use a {@link ConfigurationContextBuilder} to redefine the source order and finally use @@ -142,8 +142,8 @@ public interface PropertySource{ * Access a property. * * @param key the property's key, not {@code null}. - * @return the property value map, where {@code map.current(key) == value}, including also any metadata. In case a - * value is null, simply return {@code null}. + * @return the property createValue map, where {@code map.current(key) == createValue}, including also any metadata. In case a + * createValue is null, simply return {@code null}. */ PropertyValue get(String key); @@ -156,7 +156,7 @@ public interface PropertySource{ Map<String, PropertyValue> getProperties(); /** - * Determines if this config source can be scanned for its list of properties. + * Determines if this config source can be scanned for its createList of properties. * * <p> * PropertySources which are not scannable might not be able to find all the @@ -164,7 +164,7 @@ public interface PropertySource{ * if the underlying storage doesn't support listing. * </p> * - * @return {@code true} if this PropertySource can be scanned for its list of properties, + * @return {@code true} if this PropertySource can be scanned for its createList of properties, * {@code false} if it cannot/should not be scanned. * @deprecated will be removed. */ http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/67ffcbf2/code/api/src/main/java/org/apache/tamaya/spi/PropertySourceProvider.java ---------------------------------------------------------------------- diff --git a/code/api/src/main/java/org/apache/tamaya/spi/PropertySourceProvider.java b/code/api/src/main/java/org/apache/tamaya/spi/PropertySourceProvider.java index 1e46daa..7bf4c69 100644 --- a/code/api/src/main/java/org/apache/tamaya/spi/PropertySourceProvider.java +++ b/code/api/src/main/java/org/apache/tamaya/spi/PropertySourceProvider.java @@ -55,7 +55,7 @@ public interface PropertySourceProvider { /** * @return For each e.g. property file, we return a single PropertySource - * or an empty list if no PropertySource exists. + * or an empty createList if no PropertySource exists. */ Collection<PropertySource> getPropertySources(); }
