You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tamaya.apache.org by an...@apache.org on 2018/11/18 21:21:21 UTC
[17/22] incubator-tamaya git commit: TAMAYA-274/353 Added revapi
reports to control/report backward compatibility breaks. Removed deprecated
artifacts (ConfigurationContextBuilder) and implementations/deps. TAMAYA-355
Removed PropertyValueC
TAMAYA-274/353 Added revapi reports to control/report backward compatibility breaks.
Removed deprecated artifacts (ConfigurationContextBuilder) and implementations/deps.
TAMAYA-355 Removed PropertyValueCombinationPolicy (not needed anymore).
Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/commit/606f8ec6
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/tree/606f8ec6
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/diff/606f8ec6
Branch: refs/heads/master
Commit: 606f8ec6fe5daa47756351b345acc2722281a2b4
Parents: bd9901b
Author: Anatole Tresch <at...@gmail.com>
Authored: Tue Nov 6 18:47:53 2018 +0100
Committer: Anatole Tresch <at...@gmail.com>
Committed: Tue Nov 6 18:47:53 2018 +0100
----------------------------------------------------------------------
code/api/pom.xml | 17 +
.../apache/tamaya/ConfigurationProvider.java | 53 +-
.../apache/tamaya/spi/ConfigurationBuilder.java | 11 -
.../apache/tamaya/spi/ConfigurationContext.java | 65 +-
.../tamaya/spi/ConfigurationContextBuilder.java | 370 -------
.../tamaya/spi/ConfigurationProviderSpi.java | 69 --
.../apache/tamaya/spi/ConversionContext.java | 9 +-
.../java/org/apache/tamaya/spi/ListValue.java | 45 +-
.../java/org/apache/tamaya/spi/ObjectValue.java | 20 +-
.../org/apache/tamaya/spi/PropertySource.java | 5 +-
.../org/apache/tamaya/spi/PropertyValue.java | 212 ++--
.../apache/tamaya/spi/PropertyValueBuilder.java | 59 +-
.../spi/PropertyValueCombinationPolicy.java | 74 --
.../org/apache/tamaya/spi/ServiceContext.java | 1 +
.../tamaya/ConfigurationProviderTest.java | 33 +-
.../tamaya/TestConfigurationProvider.java | 21 -
.../spi/ConfigurationProviderSpiTest.java | 26 +-
.../tamaya/spi/ConversionContextTest.java | 4 -
.../apache/tamaya/spi/PropertySourceTest.java | 10 -
.../spi/PropertyValueCombinationPolicyTest.java | 87 --
.../apache/tamaya/spi/PropertyValueTest.java | 34 +-
code/core/pom.xml | 12 +
.../tamaya/core/internal/CoreConfiguration.java | 2 -
.../core/internal/CoreConfigurationBuilder.java | 3 -
.../internal/CoreConfigurationProvider.java | 26 -
.../core/propertysource/BasePropertySource.java | 174 ++++
.../tamaya/core/ConfigurationBuilderTest.java | 10 -
.../core/ConfigurationContextBuilderTest.java | 424 --------
.../internal/CoreConfigurationBuilderTest.java | 10 -
.../internal/CoreConfigurationProviderTest.java | 27 -
.../core/internal/CoreConfigurationTest.java | 23 +-
code/spi-support/pom.xml | 17 +
.../spisupport/DefaultConfigValueEvaluator.java | 30 +-
.../tamaya/spisupport/DefaultConfiguration.java | 15 +-
.../spisupport/DefaultConfigurationBuilder.java | 12 -
.../spisupport/DefaultConfigurationContext.java | 66 +-
.../DefaultConfigurationContextBuilder.java | 956 +++++++++----------
.../tamaya/spisupport/MetadataProvider.java | 2 +-
.../DefaultConfigurationBuilderTest.java | 10 -
.../DefaultConfigurationContextBuilderTest.java | 671 -------------
.../DefaultConfigurationContextTest.java | 25 +-
.../EmptyConfigurationContextBuilder.java | 198 ----
.../spisupport/MockedConfigurationContext.java | 21 +-
.../tamaya/spisupport/MockedPropertySource.java | 5 -
.../spisupport/TestConfigurationProvider.java | 24 -
pom.xml | 41 +
46 files changed, 975 insertions(+), 3054 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/606f8ec6/code/api/pom.xml
----------------------------------------------------------------------
diff --git a/code/api/pom.xml b/code/api/pom.xml
index 73cfc71..f3f4534 100644
--- a/code/api/pom.xml
+++ b/code/api/pom.xml
@@ -32,6 +32,23 @@ under the License.
<description>
The API for accessing configuration data.
</description>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.revapi</groupId>
+ <artifactId>revapi-maven-plugin</artifactId>
+ <configuration>
+ <oldArtifacts>
+ <artifact>${project.groupId}:${project.artifactId}:0.3-incubating</artifact>
+ </oldArtifacts>
+ <newArtifacts>
+ <artifact>${project.groupId}:${project.artifactId}:${project.version}</artifact>
+ </newArtifacts>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
<url>http://tamaya.incubator.apache.org</url>
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/606f8ec6/code/api/src/main/java/org/apache/tamaya/ConfigurationProvider.java
----------------------------------------------------------------------
diff --git a/code/api/src/main/java/org/apache/tamaya/ConfigurationProvider.java b/code/api/src/main/java/org/apache/tamaya/ConfigurationProvider.java
index 54d82f4..cbe1e50 100644
--- a/code/api/src/main/java/org/apache/tamaya/ConfigurationProvider.java
+++ b/code/api/src/main/java/org/apache/tamaya/ConfigurationProvider.java
@@ -75,34 +75,6 @@ public final class ConfigurationProvider {
}
/**
- * Get access to the current ConfigurationContext.
- *
- * @return the current ConfigurationContext, never null.
- * @deprecated Use {@link Configuration#getContext()} instead.
- */
- @Deprecated
- public static ConfigurationContext getConfigurationContext() {
- return spi().getConfigurationContext();
- }
-
- /**
- * This method allows replacement of the current {@link org.apache.tamaya.spi.ConfigurationContext} with a new
- * instance. This can be used to update the context with a new one, e.g. because some of the configuration
- * data has changed and should be updated. It is the responsibility of the ConfigurationProvider to trigger
- * corresponding update events for the current {@link org.apache.tamaya.Configuration}, so observing
- * listeners can do whatever is appropriate to react to any given configuration changes.
- *
- * @param context the new ConfigurationContext to be applied.
- * @throws java.lang.UnsupportedOperationException if the current provider is read-only and does not support
- * applying a new ConfigurationContext.
- * @deprecated Use #setConfiguration(Configuration) instead of.
- */
- @Deprecated
- public static void setConfigurationContext(ConfigurationContext context) {
- spi().setConfigurationContext(context);
- }
-
- /**
* This method allows replacement of the current default {@link org.apache.tamaya.Configuration} with a new
* instance. It is the responsibility of the ConfigurationProvider to trigger
* corresponding update events for the current {@link org.apache.tamaya.Configuration}, so observing
@@ -136,28 +108,13 @@ public final class ConfigurationProvider {
/**
* Create a new {@link ConfigurationBuilder} instance. This method creates
- * a new builder instance that is not related to any concrete {@link org.apache.tamaya.spi.ConfigurationContext}.
- * You can use {@link #setConfigurationContext(org.apache.tamaya.spi.ConfigurationContext)} to change the
- * current configuration context.
- *
- * @return a new, empty {@link ConfigurationBuilder}, never null.
- * @see #setConfigurationContext(org.apache.tamaya.spi.ConfigurationContext)
- * @see org.apache.tamaya.spi.ConfigurationContext
- * @deprecated Will be removed.
- */
- @Deprecated
- public static ConfigurationContextBuilder getConfigurationContextBuilder() {
- return spi().getConfigurationContextBuilder();
- }
-
- /**
- * Create a new {@link ConfigurationBuilder} instance. This method creates
- * a new builder instance that is not related to any concrete {@link org.apache.tamaya.spi.ConfigurationContext}.
- * You can use {@link #setConfigurationContext(org.apache.tamaya.spi.ConfigurationContext)} to change the
- * current configuration context.
+ * a new builder instance that is not related to any concrete {@link org.apache.tamaya.Configuration}.
+ * You can use {@link Configuration#setCurrent(Configuration, ClassLoader)} to change the
+ * current configuration.
*
* @return a new, empty {@link ConfigurationBuilder}, never null.
- * @see #setConfigurationContext(org.apache.tamaya.spi.ConfigurationContext)
+ * @see Configuration#setCurrent(Configuration)
+ * @see Configuration#setCurrent(Configuration, ClassLoader)
* @see org.apache.tamaya.spi.ConfigurationContext
*/
public static ConfigurationBuilder getConfigurationBuilder() {
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/606f8ec6/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 0d42cf6..7ce4547 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
@@ -375,17 +375,6 @@ public interface ConfigurationBuilder {
ConfigurationBuilder sortPropertyFilter(Comparator<PropertyFilter> comparator);
/**
- * Sets the {@link PropertyValueCombinationPolicy} used to evaluate the final
- * property values.
- *
- * @param policy the {@link PropertyValueCombinationPolicy} used, not {@code null}.
- * @return this builder, for chaining, never null.
- * @deprecated Will be removed.
- */
- @Deprecated
- ConfigurationBuilder setPropertyValueCombinationPolicy(PropertyValueCombinationPolicy policy);
-
- /**
* Builds a new {@link Configuration} based on the data in this builder. The ordering of property
* sources and property filters is not changed, regardless of their ordinals. For ensure a certain
* ordering/significance use {@link #sortPropertyFilter(Comparator)} and/or {@link #sortPropertySources(Comparator)}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/606f8ec6/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 8edb13b..a9ecda1 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,7 +21,6 @@ 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;
@@ -37,7 +36,7 @@ public interface ConfigurationContext {
* Get the metadata evaluated for this configuration.
* @return the metadata accessor, never null.
*/
- Map<String,String> getMetadata();
+ Map<String,String> getMetaData();
/**
* Access the underlying {@link ServiceContext}.
@@ -46,17 +45,6 @@ public interface ConfigurationContext {
ServiceContext getServiceContext();
/**
- * This method can be used for programmatically adding {@link PropertySource}s.
- * 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 createObject a new {@link ConfigurationContext}.
- * @see #toBuilder()
- */
- @Deprecated
- void addPropertySources(PropertySource... propertySources);
-
- /**
* 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.
@@ -78,20 +66,6 @@ public interface ConfigurationContext {
PropertySource getPropertySource(String name);
/**
- * This method can be used for programmatically adding {@link PropertyConverter}s.
- * It is not needed for normal 'usage' by end users, but only for Extension Developers!
- *
- * @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 createObject a new {@link ConfigurationContext}.
- * @see #toBuilder()
- */
- @Deprecated
- <T> void addPropertyConverter(TypeLiteral<T> type, PropertyConverter<T> propertyConverter);
-
-
- /**
* <p>
* This method returns the Map of registered {@link PropertyConverter}s
* per type.
@@ -171,26 +145,11 @@ public interface ConfigurationContext {
List<PropertyFilter> getPropertyFilters();
/**
- * Access the {@link PropertyValueCombinationPolicy} used to evaluate the final
- * property values.
- * @return the {@link PropertyValueCombinationPolicy} used, never null.
- */
- PropertyValueCombinationPolicy getPropertyValueCombinationPolicy();
-
- /**
- * Creates a {@link ConfigurationContextBuilder} preinitialized with the data from this instance.
- * @return a new builder instance, never null.
- * @deprecated Will be removed.
- */
- @Deprecated
- ConfigurationContextBuilder toBuilder();
-
- /**
* An empty configuration context. The implementation can be shared and is thread safe.
*/
ConfigurationContext EMPTY = new ConfigurationContext() {
@Override
- public Map<String,String> getMetadata() {
+ public Map<String,String> getMetaData() {
return Collections.emptyMap();
}
@@ -200,11 +159,6 @@ public interface ConfigurationContext {
}
@Override
- public void addPropertySources(PropertySource... propertySourcesToAdd) {
- // ignore
- }
-
- @Override
public List<PropertySource> getPropertySources() {
return Collections.emptyList();
}
@@ -215,11 +169,6 @@ public interface ConfigurationContext {
}
@Override
- public <T> void addPropertyConverter(TypeLiteral<T> typeToConvert, PropertyConverter<T> propertyConverter) {
- // ignore
- }
-
- @Override
public Map<TypeLiteral<?>, List<PropertyConverter<?>>> getPropertyConverters() {
return Collections.emptyMap();
}
@@ -235,16 +184,6 @@ public interface ConfigurationContext {
}
@Override
- public PropertyValueCombinationPolicy getPropertyValueCombinationPolicy() {
- return PropertyValueCombinationPolicy.DEFAULT_OVERRIDING_COLLECTOR;
- }
-
- @Override
- public ConfigurationContextBuilder toBuilder() {
- throw new UnsupportedOperationException("Cannot build from ConfigurationContext.EMPTY.");
- }
-
- @Override
public String toString(){
return "ConfigurationContext.EMPTY";
}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/606f8ec6/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
deleted file mode 100644
index 5e7ad49..0000000
--- a/code/api/src/main/java/org/apache/tamaya/spi/ConfigurationContextBuilder.java
+++ /dev/null
@@ -1,370 +0,0 @@
-/*
- * 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 org.apache.tamaya.TypeLiteral;
-
-import java.util.Collection;
-import java.util.Comparator;
-import java.util.List;
-import java.util.Map;
-
-/**
- * A builder for creating new or adapting instances of {@link ConfigurationContext}.
- * Builders can be obtained in exactly two ways:
- * <ol>
- * <li>By accessing a preinitialized builder from an existing {@link ConfigurationContext},
- * by calling {@link org.apache.tamaya.spi.ConfigurationContext#toBuilder()}.</li>
- * <li>By accessing an empty builder instance from
- * {@link org.apache.tamaya.ConfigurationProvider#getConfigurationContextBuilder()}.</li>
- * </ol>
- * After all changes are applied to a builder a new {@link ConfigurationContext} instance can
- * be created and can be applied by calling
- * {@link org.apache.tamaya.ConfigurationProvider#setConfigurationContext(org.apache.tamaya.spi.ConfigurationContext)}.
- * @deprecated Use {@link ConfigurationBuilder} instead.
- */
-@Deprecated
-public interface ConfigurationContextBuilder {
-
- /**
- * Set the classloader to be used for loading of configuration resources, equals to
- * {@code setServiceContext(ServiceContextManager.getServiceContext(classLoader))}.
- * @param classLoader the classloader, not null.
- * @return the builder for chaining.
- */
- ConfigurationContextBuilder setClassLoader(ClassLoader classLoader);
-
- /**
- * Sets the ServiceContext to be used.
- * @param serviceContext the serviceContext, nuo null.
- * @return this instance for chaining.
- */
- ConfigurationContextBuilder setServiceContext(ServiceContext serviceContext);
-
- /**
- * Init this builder instance with the given {@link ConfigurationContext} instance. This
- * method will use any existing property sources, filters, converters and the combination
- * policy of the given {@link ConfigurationContext} and initialize the current builder
- * with them.
- *
- * @param context the {@link ConfigurationContext} instance to be used, not {@code null}.
- * @return this builder, for chaining, never null.
- */
- 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 createValue. To sort the property
- * sources based on their ordinals call {@link #sortPropertySources}.
- *
- * @param propertySources the PropertySources to add
- * @return this builder, for chaining, never null.
- * @throws IllegalArgumentException If a property source with a given name already
- * exists.
- */
- ConfigurationContextBuilder addPropertySources(PropertySource... propertySources);
-
- /**
- * 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 createValue. To sort the property
- * sources based on their ordinals call {@link #sortPropertySources}.
- *
- * @param propertySources the PropertySources to add
- * @return this builder, for chaining, never null.
- * @throws IllegalArgumentException If a property source with a given name already
- * exists.
- */
- ConfigurationContextBuilder addPropertySources(Collection<PropertySource> propertySources);
-
- /**
- * Add all registered (default) property sources to the context built. The sources are ordered
- * based on their ordinal values and added to the chain of property sources with
- * higher priority.
- * @return this builder, for chaining, never null.
- */
- ConfigurationContextBuilder addDefaultPropertySources();
-
- /**
- * Removes the given property sources, if existing. The existing order of property
- * sources is preserved.
- *
- * @param propertySources the property sources to remove, not {@code null}.
- * @return the builder for chaining.
- */
- ConfigurationContextBuilder removePropertySources(PropertySource... propertySources);
-
- /**
- * Removes the given property sources, if existing. The existing order of property
- * sources is preserved.
- *
- * @param propertySources the property sources to remove, not {@code null}.
- * @return the builder for chaining.
- */
- ConfigurationContextBuilder removePropertySources(Collection<PropertySource> propertySources);
-
- /**
- * 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}.
- */
- List<PropertySource> getPropertySources();
-
- /**
- * 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}.
- */
- List<PropertyFilter> getPropertyFilters();
-
- /**
- * Access the current registered property converters.
- *
- * @return the current registered property converters.
- */
- Map<TypeLiteral<?>, Collection<PropertyConverter<?>>> getPropertyConverter();
-
- /**
- * Increases the priority of the given property source, by moving it towards the end
- * of the chain of property sources. If the property source given is already at the end
- * this method has no effect. This operation does not change any ordinal values.
- *
- * @param propertySource the property source to be incresed regarding its significance.
- * @return the builder for chaining.
- * @throws IllegalArgumentException If no such property source exists in the current
- * chain.
- */
- ConfigurationContextBuilder increasePriority(PropertySource propertySource);
-
- /**
- * Decreases the priority of the given property source, by moving it towards the start
- * of the chain of property sources. If the property source given is already the first
- * this method has no effect. This operation does not change any ordinal values.
- *
- * @param propertySource the property source to be decresed regarding its significance.
- * @return the builder for chaining.
- * @throws IllegalArgumentException If no such property source exists in the current
- * chain.
- */
- ConfigurationContextBuilder decreasePriority(PropertySource propertySource);
-
- /**
- * Increases the priority of the given property source to be maximal, by moving it to
- * the tail of the of property source chain. If the property source given is
- * already the last item this method has no effect. This operation does not change
- * any ordinal values.
- *
- * @param propertySource the property source to be maximized regarding its significance.
- * @return the builder for chaining.
- * @throws IllegalArgumentException If no such property source exists in the current
- * chain.
- */
- ConfigurationContextBuilder highestPriority(PropertySource propertySource);
-
- /**
- * Decreases the priority of the given property source to be minimal, by moving it to
- * the start of the chain of property source chain. If the property source given is
- * already the first item this method has no effect. This operation does not change
- * any ordinal values.
- *
- * @param propertySource the property source to be minimized regarding its significance.
- * @return the builder for chaining.
- * @throws IllegalArgumentException If no such property source exists in the current
- * chain.
- */
- ConfigurationContextBuilder lowestPriority(PropertySource propertySource);
-
- /**
- * Adds the given PropertyFilter instances, hereby the instances are added
- * 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}.
- *
- * @param filters the filters to add
- * @return this builder, for chaining, never null.
- */
- ConfigurationContextBuilder addPropertyFilters(PropertyFilter... filters);
-
- /**
- * Adds the given PropertyFilter instances, hereby the instances are added
- * 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}.
- *
- * @param filters the filters to add
- * @return this builder, for chaining, never null.
- */
- ConfigurationContextBuilder addPropertyFilters(Collection<PropertyFilter> filters);
-
- /**
- * Add all registered (default) property filters to the context built.
- * @return this builder, for chaining, never null.
- */
- ConfigurationContextBuilder addDefaultPropertyFilters();
-
-
- /**
- * Removes the given PropertyFilter instances, if existing. The order of the remaining
- * filters is preserved.
- *
- * @param filters the filter to remove
- * @return this builder, for chaining, never null.
- */
- ConfigurationContextBuilder removePropertyFilters(PropertyFilter... filters);
-
- /**
- * Removes the given PropertyFilter instances, if existing. The order of the remaining
- * filters is preserved.
- *
- * @param filters the filter to remove
- * @return this builder, for chaining, never null.
- */
- ConfigurationContextBuilder removePropertyFilters(Collection<PropertyFilter> filters);
-
- /**
- * This method can be used for adding {@link PropertyConverter}s.
- * Converters are added at the end after any existing converters.
- * For converters already registered for the current target type the
- * method has no effect.
- *
- * @param typeToConvert the type for which the converters is for
- * @param propertyConverters the PropertyConverters to add for this type
- * @param <T> the target type.
- * @return this builder, for chaining, never null.
- */
- <T> ConfigurationContextBuilder addPropertyConverters(TypeLiteral<T> typeToConvert,
- @SuppressWarnings("unchecked") PropertyConverter<T>... propertyConverters);
-
- /**
- * This method can be used for adding {@link PropertyConverter}s.
- * Converters are added at the end after any existing converters.
- * For converters already registered for the current target type the
- * method has no effect.
- *
- * @param typeToConvert the type for which the converters is for
- * @param propertyConverters the PropertyConverters to add for this type
- * @param <T> the target type.
- * @return this builder, for chaining, never null.
- */
- <T> ConfigurationContextBuilder addPropertyConverters(TypeLiteral<T> typeToConvert,
- Collection<PropertyConverter<T>> propertyConverters);
-
- /**
- * Add all registered (default) property converters to the context built.
- * @return this builder, for chaining, never null.
- */
- ConfigurationContextBuilder addDefaultPropertyConverters();
-
- /**
- * Removes the given PropertyConverter instances for the given type,
- * if existing.
- *
- * @param typeToConvert the type which the converters is for
- * @param propertyConverters the converters to remove
- * @param <T> the target type.
- * @return this builder, for chaining, never null.
- */
- <T> ConfigurationContextBuilder removePropertyConverters(TypeLiteral<T> typeToConvert,
- @SuppressWarnings("unchecked") PropertyConverter<T>... propertyConverters);
-
- /**
- * Removes the given PropertyConverter instances for the given type,
- * if existing.
- *
- * @param typeToConvert the type which the converters is for
- * @param propertyConverters the converters to remove
- * @param <T> the target type.
- * @return this builder, for chaining, never null.
- */
- <T> ConfigurationContextBuilder removePropertyConverters(TypeLiteral<T> typeToConvert,
- Collection<PropertyConverter<T>> propertyConverters);
-
- /**
- * Removes all converters for the given type, which actually renders a given type
- * unsupported for type conversion.
- *
- * @param typeToConvert the type which the converters is for
- * @return this builder, for chaining, never null.
- */
- ConfigurationContextBuilder removePropertyConverters(TypeLiteral<?> typeToConvert);
-
- /**
- * Sorts the current registered property sources using the given comparator.
- *
- * NOTE: property sources at the beginning have minimal significance.
- *
- * @param comparator the comparator to be used, not {@code null}.
- * @return this instance for chaining.
- */
- ConfigurationContextBuilder sortPropertySources(Comparator<PropertySource> comparator);
-
- /**
- * Sorts the current registered property filters using the given comparator.
- *
- * NOTE: property filters at the beginning have minimal significance.
- *
- * @param comparator the comparator to be used, not {@code null}.
- * @return this instance for chaining.
- */
- ConfigurationContextBuilder sortPropertyFilter(Comparator<PropertyFilter> comparator);
-
- /**
- * Sets the {@link PropertyValueCombinationPolicy} used to evaluate the final
- * property values.
- *
- * @param policy the {@link PropertyValueCombinationPolicy} used, not {@code null}.
- * @return this builder, for chaining, never null.
- */
- ConfigurationContextBuilder setPropertyValueCombinationPolicy(PropertyValueCombinationPolicy policy);
-
- /**
- * Access the serviceContext used by the builder.
- * @return the serviceContext, never null.
- */
- ServiceContext getServiceContext();
-
- /**
- * Builds a new {@link ConfigurationContext} based on the data in this builder. The ordering of property
- * sources and property filters is not changed, regardless of their ordinals. For ensure a certain
- * ordering/significance call {@link #sortPropertyFilter(Comparator)} and/or {@link #sortPropertySources(Comparator)}
- * before building the context.
- *
- * @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/606f8ec6/code/api/src/main/java/org/apache/tamaya/spi/ConfigurationProviderSpi.java
----------------------------------------------------------------------
diff --git a/code/api/src/main/java/org/apache/tamaya/spi/ConfigurationProviderSpi.java b/code/api/src/main/java/org/apache/tamaya/spi/ConfigurationProviderSpi.java
index 9c35e4c..337e397 100644
--- a/code/api/src/main/java/org/apache/tamaya/spi/ConfigurationProviderSpi.java
+++ b/code/api/src/main/java/org/apache/tamaya/spi/ConfigurationProviderSpi.java
@@ -55,15 +55,6 @@ public interface ConfigurationProviderSpi {
Configuration createConfiguration(ConfigurationContext context);
/**
- * Creates a new {@link org.apache.tamaya.spi.ConfigurationContextBuilder} instance.
- *
- * @return a new {@link org.apache.tamaya.spi.ConfigurationContextBuilder}, never null.
- * @deprecated Will be removed
- */
- @Deprecated
- ConfigurationContextBuilder getConfigurationContextBuilder();
-
- /**
* Creates a new {@link org.apache.tamaya.spi.ConfigurationBuilder} instance.
*
* @return a new {@link org.apache.tamaya.spi.ConfigurationBuilder}, never null.
@@ -83,21 +74,6 @@ public interface ConfigurationProviderSpi {
void setConfiguration(Configuration config, ClassLoader classloader);
/**
- * This method allows to replace the current {@link org.apache.tamaya.Configuration} with a new
- * instance. This can be used to update the configuration with a new one, e.g. because some of the
- * data has changed and must be updated. It is the responsibility of the ConfigurationProvider to trigger
- * corresponding update events for the current {@link org.apache.tamaya.Configuration}.
- *
- * @param config the new Configuration to be applied.
- * @throws java.lang.UnsupportedOperationException if the current provider is read-only.
- * @deprecated Use {@link #setConfiguration(Configuration, ClassLoader)} instead of.
- */
- @Deprecated
- default void setConfiguration(Configuration config){
- setConfiguration(config, Thread.currentThread().getContextClassLoader());
- }
-
- /**
* Method that allows to determine if a new {@link org.apache.tamaya.Configuration} can be applied
* programmatically.
*
@@ -110,49 +86,4 @@ public interface ConfigurationProviderSpi {
return true;
}
- /**
- * Get access to the current {@link ConfigurationContext}.
- *
- * @return the current {@link ConfigurationContext}, never null.
- * @deprecated Will be removed in favour of {@link Configuration#getContext()}.
- */
- @Deprecated
- default ConfigurationContext getConfigurationContext(){
- return getConfiguration(
- Thread.currentThread().getContextClassLoader()
- ).getContext();
- }
-
- /**
- * This method allows to replace the current {@link org.apache.tamaya.spi.ConfigurationContext} with a new
- * instance. This can be used to update the context with a new one, e.g. because some of the configuration
- * data has changed and must be updated. It is the responsibility of the ConfigurationProvider to trigger
- * corresponding update event for the current {@link org.apache.tamaya.spi.ConfigurationContext} or
- * {@link org.apache.tamaya.Configuration}.
- *
- * @param context the new ConfigurationContext to be applied.
- * @throws java.lang.UnsupportedOperationException if the current provider is read-only.
- * @deprecated use {@link #setConfiguration(Configuration, ClassLoader)}
- */
- @Deprecated
- default void setConfigurationContext(ConfigurationContext context){
- setConfiguration(createConfiguration(context), Thread.currentThread().getContextClassLoader());
- }
-
- /**
- * Method that allows to determine if a new {@link org.apache.tamaya.spi.ConfigurationContext} can be applied
- * programmatically.
- *
- * @return true, if {@link #setConfigurationContext(org.apache.tamaya.spi.ConfigurationContext)} is supported
- * by the current implementation.
- * @see #setConfigurationContext(org.apache.tamaya.spi.ConfigurationContext)
- * @deprecated use {@link #isConfigurationSettable(ClassLoader)}
- */
- @Deprecated
- default boolean isConfigurationContextSettable(){
- return isConfigurationSettable(Thread.currentThread()
- .getContextClassLoader());
- }
-
-
}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/606f8ec6/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 d4c2601..ff321dc 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
@@ -23,7 +23,6 @@ import org.apache.tamaya.TypeLiteral;
import java.lang.reflect.AnnotatedElement;
import java.util.*;
-import java.util.function.Consumer;
/**
* A conversion context containing all the required values for implementing conversion. Use the included #Builder
@@ -58,8 +57,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 createValue has to be converted and no unique underlying
- * key/createValue configuration is present.
+ * @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.
*/
public String getKey(){
return key;
@@ -108,7 +107,7 @@ public class ConversionContext {
if(values.size()>0){
String baseKey = values.get(0).getQualifiedKey()+".";
- values.forEach(val -> this.getConfiguration().getContext().getMetadata().entrySet().forEach(
+ values.forEach(val -> this.getConfiguration().getContext().getMetaData().entrySet().forEach(
en -> {
if(en.getKey().startsWith(baseKey)) {
metaMap.put(en.getKey().substring(baseKey.length()), en.getValue());
@@ -166,7 +165,7 @@ public class ConversionContext {
}
/**
- * Builder to createObject new instances of {@link ConversionContext}.
+ * Builder to create new instances of {@link ConversionContext}.
*/
public static final class Builder{
/** The backing configuration. */
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/606f8ec6/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
index 7150d78..1e7b493 100644
--- a/code/api/src/main/java/org/apache/tamaya/spi/ListValue.java
+++ b/code/api/src/main/java/org/apache/tamaya/spi/ListValue.java
@@ -36,7 +36,6 @@ 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<>();
@@ -46,9 +45,22 @@ public final class ListValue extends PropertyValue{
* @param parent the parent.
*/
ListValue(PropertyValue parent, String key){
- super(parent, key, ValueType.ARRAY);
+ super(parent, key);
}
+ /**
+ * Get the item's current createValue type.
+ * @return the createValue type, never null.
+ */
+ public ValueType getValueType() {
+ return ValueType.ARRAY;
+ }
+
+ /**
+ * Get the index of the given member value.
+ * @param member the member, not null.
+ * @return the index, or -1.
+ */
public int getIndex(PropertyValue member) {
return this.list.indexOf(member);
}
@@ -79,6 +91,7 @@ public final class ListValue extends PropertyValue{
/**
* Adds a createValue to the array.
* @param value the createValue, not null
+ * @param <T> the instance type.
* @return this instance, for chaining.
* @throws IllegalStateException if the instance is immutable.
* @see #isImmutable()
@@ -91,26 +104,26 @@ public final class ListValue extends PropertyValue{
}
/**
- * Adds an named text createValue to the array.
- * @param value the child's createValue, not null.
- * @return the created createValue, not null.
+ * Adds an named text value to the array.
+ * @param key the child's key, not null.
+ * @param value the child's value, not null.
+ * @return the created value, 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));
+ return add(new PropertyValue(this,key, value));
}
/**
- * Adds an anonymous text createValue to the array.
- * @param value the child's createValue, not null.
- * @return the created createValue, not null.
+ * Adds an anonymous text value to the array.
+ * @param value the child's value, not null.
+ * @return the created value, not null.
* @throws IllegalStateException if the instance is immutable.
* @see #isImmutable()
*/
public PropertyValue addValue(String value) {
- return add(new PropertyValue(this,"",
- ValueType.VALUE, value));
+ return add(new PropertyValue(this,"", value));
}
/**
@@ -123,7 +136,7 @@ public final class ListValue extends PropertyValue{
public List<PropertyValue> addValues(String... values) {
List<PropertyValue> result = new ArrayList<>();
for(String val:values) {
- result.add(add(new PropertyValue(this, "", ValueType.VALUE, val)));
+ result.add(add(new PropertyValue(this, "", val)));
}
return result;
}
@@ -254,7 +267,7 @@ public final class ListValue extends PropertyValue{
@Override
public PropertyValue toPropertyValue(){
- PropertyValue value = new PropertyValue(getParent(), getKey(), getValueType(), getValue());
+ PropertyValue value = new PropertyValue(getParent(), getKey(), getValue());
value.setMeta(getMeta());
value.setVersion(getVersion());
return value;
@@ -279,8 +292,8 @@ public final class ListValue extends PropertyValue{
}
/**
- * Clones this instance and all it's children, marking as mutable createValue.
- * @return the new createValue clone.
+ * Clones this instance and all it's children, marking as mutable value.
+ * @return the new value clone.
*/
@Override
public ListValue mutable(){
@@ -318,7 +331,7 @@ public final class ListValue extends PropertyValue{
public String toString() {
return "PropertyValue[ARRAY]{" +
'\'' +getQualifiedKey() + '\'' +
- (getValue()!=null?", createValue='" + getValue() + '\'':"") +
+ (getValue()!=null?", value='" + getValue() + '\'':"") +
", size='" + getSize() + '\'' +
(getMeta().isEmpty()?"":", metaData=" + getMeta()) +
'}';
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/606f8ec6/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
index b1bff87..f7f6330 100644
--- a/code/api/src/main/java/org/apache/tamaya/spi/ObjectValue.java
+++ b/code/api/src/main/java/org/apache/tamaya/spi/ObjectValue.java
@@ -48,7 +48,15 @@ public final class ObjectValue extends PropertyValue{
* @param parent the parent.
*/
ObjectValue(PropertyValue parent, String key){
- super(parent, key, ValueType.OBJECT);
+ super(parent, key);
+ }
+
+ /**
+ * Get the item's current createValue type.
+ * @return the createValue type, never null.
+ */
+ public ValueType getValueType() {
+ return ValueType.OBJECT;
}
/**
@@ -72,6 +80,8 @@ public final class ObjectValue extends PropertyValue{
/**
* Get a single child getField with the given name, creates it if not existing.
* @param name the child's name, not null.
+ * @param valueSupplier the supplier to create a new instance, if no value is present, not null.
+ * @param <T> the target type.
* @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.
@@ -99,7 +109,7 @@ public final class ObjectValue extends PropertyValue{
@Override
public PropertyValue toPropertyValue(){
- PropertyValue value = new PropertyValue(getParent(), getKey(), getValueType(), getValue());
+ PropertyValue value = new PropertyValue(getParent(), getKey(), getValue());
value.setMeta(getMeta());
value.setVersion(getVersion());
return value;
@@ -132,12 +142,13 @@ public final class ObjectValue extends PropertyValue{
/**
* Adds a new nvalue child.
* @param name the child's name, not null.
+ * @param value the value
* @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));
+ return set(new PropertyValue(this, name, value));
}
/**
@@ -151,7 +162,7 @@ public final class ObjectValue extends PropertyValue{
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()));
+ result.add(new PropertyValue(this, en.getKey(), en.getValue()));
}
return result;
}
@@ -182,6 +193,7 @@ public final class ObjectValue extends PropertyValue{
/**
* Adds another existing node, hereby setting the corresponding parent node.
* @param value the createValue, not null
+ * @param <T> the value type.
* @return the createValue added, not null.
* @throws IllegalStateException if the instance is immutable.
* @see #isImmutable()
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/606f8ec6/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 8fb5480..9ede6ce 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
@@ -119,11 +119,10 @@ public interface PropertySource{
*
* 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
+ * <li>you can use a {@link ConfigurationBuilder} to redefine the source order and finally use
* {@link org.apache.tamaya.ConfigurationProvider#setConfiguration(Configuration)} to
* change the current default {@link Configuration}.</li>
- * <li>finally, the imeplementor of this API may define alternate mechanism to reconfigure an ordinal
+ * <li>finally, the implementor of this API may define alternate mechanism to reconfigure an ordinal
* in a vendor specific way.</li>
* </ul>
* @return the 'importance' aka ordinal of the configured values. The higher, the more important.
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/606f8ec6/code/api/src/main/java/org/apache/tamaya/spi/PropertyValue.java
----------------------------------------------------------------------
diff --git a/code/api/src/main/java/org/apache/tamaya/spi/PropertyValue.java b/code/api/src/main/java/org/apache/tamaya/spi/PropertyValue.java
index 9f66b24..b0fd2ff 100644
--- a/code/api/src/main/java/org/apache/tamaya/spi/PropertyValue.java
+++ b/code/api/src/main/java/org/apache/tamaya/spi/PropertyValue.java
@@ -34,9 +34,7 @@ import java.util.concurrent.atomic.AtomicInteger;
*/
public class PropertyValue implements Serializable, Iterable<PropertyValue>{
- private static final long serialVersionUID = 1L;
- /** The type of node. */
- private ValueType valueType;
+ private static final long serialVersionUID = 2L;
/** The requested key. */
private String key;
/** The createValue. */
@@ -48,7 +46,7 @@ public class PropertyValue implements Serializable, Iterable<PropertyValue>{
/** Flag to mark a createValue as immutable. */
private boolean immutable;
/** Additional metadata provided by the provider. */
- private final transient Map<String,Object> metaData = new HashMap<>();
+ private final Map<String,String> metaEntries = new HashMap<>();
/**
* Enum of the different supported value types.
@@ -102,7 +100,7 @@ public class PropertyValue implements Serializable, Iterable<PropertyValue>{
* @return a new createValue instance.
*/
public static PropertyValue createValue(String key, String value){
- return new PropertyValue(null, key, ValueType.VALUE, value);
+ return new PropertyValue(null, key, value);
}
/**
@@ -135,9 +133,9 @@ public class PropertyValue implements Serializable, Iterable<PropertyValue>{
public static PropertyValue of(String key, String value, String source) {
Objects.requireNonNull(key);
if(source!=null) {
- return new PropertyValue(null, key, ValueType.VALUE, value).setMeta("source", source);
+ return new PropertyValue(null, key, value).setMeta("source", source);
}
- return new PropertyValue(null, key, ValueType.VALUE, value);
+ return new PropertyValue(null, key, value);
}
/**
@@ -184,22 +182,19 @@ public class PropertyValue implements Serializable, Iterable<PropertyValue>{
* Creates a new instance
* @param key the key, not {@code null}.
* @param parent the parent.
- * @param valueType the createValue type, not null.
*/
- protected PropertyValue(PropertyValue parent, String key, ValueType valueType){
- this(parent, key, valueType, null);
+ protected PropertyValue(PropertyValue parent, String key){
+ this(parent, key, null);
}
/**
* Creates a new instance
* @param key the key, not {@code null}.
* @param parent the parent.
- * @param valueType the createValue type, not null.
* @param value the initial text createValue.
*/
- protected PropertyValue(PropertyValue parent, String key, ValueType valueType, String value){
+ protected PropertyValue(PropertyValue parent, String key, String value){
this.parent = parent;
- this.valueType = Objects.requireNonNull(valueType, "ValueType is required.");
this.key = Objects.requireNonNull(key);
this.value = value;
}
@@ -237,8 +232,8 @@ public class PropertyValue implements Serializable, Iterable<PropertyValue>{
* Get the item's current createValue type.
* @return the createValue type, never null.
*/
- public final ValueType getValueType() {
- return valueType;
+ public ValueType getValueType() {
+ return ValueType.VALUE;
}
/**
@@ -258,6 +253,17 @@ public class PropertyValue implements Serializable, Iterable<PropertyValue>{
}
/**
+ * Get the source.
+ * @return the source, or null.
+ * @deprecated Use {@code getMeta("source")}.
+ */
+ @Deprecated
+ public String getSource() {
+ return this.metaEntries.get("source");
+ }
+
+
+ /**
* Sets the createValue.
* @param value the createValue
* @return this getField for chaining.
@@ -323,16 +329,6 @@ public class PropertyValue implements Serializable, Iterable<PropertyValue>{
return version.get();
}
- /**
- * Get the source.
- * @return the source, or null.
- * @deprecated Use {@code getMeta("source")}.
- */
- @Deprecated
- public final String getSource() {
- return (String)this.metaData.get("source");
- }
-
/**
* Checks if the getField is a root getField.
@@ -355,8 +351,8 @@ public class PropertyValue implements Serializable, Iterable<PropertyValue>{
* is also used for subsequent processing, like createValue filtering.
* @return the property createValue entry map.
*/
- public final Map<String, Object> getMeta() {
- return Collections.unmodifiableMap(metaData);
+ public final Map<String, String> getMeta() {
+ return Collections.unmodifiableMap(metaEntries);
}
/**
@@ -366,8 +362,8 @@ public class PropertyValue implements Serializable, Iterable<PropertyValue>{
* @deprecated Use {@link #getMeta(String)} instead of.
*/
@Deprecated
- public final String getMetaEntry(String key) {
- return (String)this.metaData.get(Objects.requireNonNull(key));
+ public String getMetaEntry(String key) {
+ return (String)this.metaEntries.get(Objects.requireNonNull(key));
}
/**
@@ -377,21 +373,10 @@ public class PropertyValue implements Serializable, Iterable<PropertyValue>{
* @return the createValue found, or {@code null}.
*/
public final <T> T getMeta(String key) {
- return (T)this.metaData.get(Objects.requireNonNull(key));
+ return (T)this.metaEntries.get(Objects.requireNonNull(key));
}
/**
- * Access the given metadata.
- * @param type the type, not {@code null}.
- * @param <T> the target type.
- * @return the createValue found, or {@code null}.
- */
- public final <T> T getMeta(Class<T> type) {
- return (T)this.metaData.get(type.getName());
- }
-
-
- /**
* Get the createValue's number of elements.
* @return the getNumChilds of this multi createValue.
*/
@@ -429,11 +414,11 @@ public class PropertyValue implements Serializable, Iterable<PropertyValue>{
* @throws IllegalStateException if the instance is immutable.
* @see #isImmutable()
*/
- public final PropertyValue setMeta(Map<String, Object> metaEntries) {
+ public final PropertyValue setMeta(Map<String, String> metaEntries) {
checkImmutable();
- if(!Objects.equals(this.metaData, metaEntries)) {
- this.metaData.clear();
- this.metaData.putAll(metaEntries);
+ if(!Objects.equals(this.metaEntries, metaEntries)) {
+ this.metaEntries.clear();
+ this.metaEntries.putAll(metaEntries);
version.incrementAndGet();
}
return this;
@@ -451,46 +436,8 @@ public class PropertyValue implements Serializable, Iterable<PropertyValue>{
checkImmutable();
Objects.requireNonNull(key, "Meta key must be given.");
Objects.requireNonNull(value, "Meta createValue must be given.");
- if(!Objects.equals(this.metaData.get(key), value)) {
- this.metaData.put(key, value);
- version.incrementAndGet();
- }
- return this;
- }
-
- /**
- * Add an additional context data information.
- * @param type the context data type, used as key, not {@code null}.
- * @param value the context createValue, not {@code null}.
- * @param <T> the target type.
- * @return the builder for chaining.
- * @throws IllegalStateException if the instance is immutable.
- * @see #isImmutable()
- */
- public final <T> PropertyValue setMeta(Class<T> type, T value) {
- checkImmutable();
- Objects.requireNonNull(type, "Meta key must be given.");
- Objects.requireNonNull(value, "Meta createValue must be given.");
- if(!Objects.equals(this.metaData.get(type.toString()), value)) {
- this.metaData.put(type.toString(), value);
- version.incrementAndGet();
- }
- return this;
- }
-
- /**
- * Add an additional context data information, using the data's class name as key.
- * @param value the context createValue, not {@code null}.
- * @param <T> the target type.
- * @return the builder for chaining.
- * @throws IllegalStateException if the instance is immutable.
- * @see #isImmutable()
- */
- public final <T> PropertyValue setMeta(T value) {
- checkImmutable();
- Objects.requireNonNull(value, "Meta createValue must be given.");
- if(!Objects.equals(this.metaData.get(value.getClass().toString()), value)) {
- this.metaData.put(value.getClass().toString(), value);
+ if(!Objects.equals(this.metaEntries.get(key), value.toString())) {
+ this.metaEntries.put(key, value.toString());
version.incrementAndGet();
}
return this;
@@ -506,29 +453,13 @@ public class PropertyValue implements Serializable, Iterable<PropertyValue>{
public final PropertyValue removeMeta(String key) {
checkImmutable();
Objects.requireNonNull(key, "Key must be given.");
- if(this.metaData.containsKey(key)) {
- this.metaData.remove(key);
+ if(this.metaEntries.containsKey(key)) {
+ this.metaEntries.remove(key);
version.incrementAndGet();
}
return this;
}
- /**
- * Removes a getMeta entry.
- * @param type the entry's type, not {@code null}.
- * @return the builder for chaining.
- * @throws IllegalStateException if the instance is immutable.
- * @see #isImmutable()
- */
- public final PropertyValue removeMeta(Class type) {
- checkImmutable();
- Objects.requireNonNull(key, "Key must be given.");
- if(this.metaData.containsKey(type.getName())) {
- this.metaData.remove(type.getName());
- version.incrementAndGet();
- }
- return this;
- }
/**
* Convert the getField tree to a property map.
@@ -564,19 +495,32 @@ public class PropertyValue implements Serializable, Iterable<PropertyValue>{
@Deprecated
public PropertyValueBuilder toBuilder() {
return new PropertyValueBuilder(this.getKey(), this.getValue())
- .setMeta(this.metaData);
+ .setMeta(this.metaEntries);
}
+ /**
+ * Convert an instance to a simple PropertyValue. Note, that in case
+ * of object/list values, data loss can occur.
+ * @return the simple value, never null.
+ */
public PropertyValue toPropertyValue(){
return this;
}
+ /**
+ * Convert an instance to a Object PropertyValue.
+ * @return the list value, never null.
+ */
public ObjectValue toObjectValue(){
ObjectValue ov = new ObjectValue(getParent(),getKey());
ov.setField("createValue", value);
return ov;
}
+ /**
+ * Convert an instance to a List PropertyValue.
+ * @return the list value, never null.
+ */
public ListValue toListValue(){
ListValue lv = new ListValue(getParent(),getKey());
lv.addValue("createValue", value);
@@ -584,13 +528,51 @@ public class PropertyValue implements Serializable, Iterable<PropertyValue>{
}
+ /**
+ * Creates a deep clone of this intance.
+ * @return a clone, never null.
+ */
protected PropertyValue deepClone() {
- PropertyValue newProp = new PropertyValue(getParent(), getKey(), ValueType.VALUE, this.value);
+ PropertyValue newProp = new PropertyValue(getParent(), getKey(), this.value);
newProp.setMeta(getMeta());
newProp.setVersion(getVersion());
return newProp;
}
+ /**
+ * @throws IllegalStateException if the instance is immutable.
+ */
+ protected final void checkImmutable(){
+ if(immutable){
+ throw new IllegalStateException("Instance is immutable.");
+ }
+ }
+
+ /**
+ * Called to mark a change on this instance.
+ * @return the new version.
+ */
+ protected final int incrementVersion(){
+ checkImmutable();
+ return version.incrementAndGet();
+ }
+
+ /**
+ * Sets the new version, used iternally when cloning.
+ * @param version the new version.
+ */
+ protected final void setVersion(int version) {
+ this.version.set(version);
+ }
+
+ /**
+ * Sets the new parent, used iternally when converting between value types.
+ * @param parent the parent value.
+ */
+ protected final void setParent(PropertyValue parent){
+ this.parent = parent;
+ }
+
@Override
public boolean equals(Object o) {
@@ -618,24 +600,4 @@ public class PropertyValue implements Serializable, Iterable<PropertyValue>{
'}';
}
- protected final void checkImmutable(){
- if(immutable){
- throw new IllegalStateException("Instance is immutable.");
- }
- }
-
- protected final int incrementVersion(){
- checkImmutable();
- return version.incrementAndGet();
- }
-
- protected final void setVersion(int version) {
- this.version.set(version);
- }
-
- protected final void setParent(PropertyValue parent){
- this.parent = parent;
- }
-
-
}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/606f8ec6/code/api/src/main/java/org/apache/tamaya/spi/PropertyValueBuilder.java
----------------------------------------------------------------------
diff --git a/code/api/src/main/java/org/apache/tamaya/spi/PropertyValueBuilder.java b/code/api/src/main/java/org/apache/tamaya/spi/PropertyValueBuilder.java
index 57bd058..c9dfcc5 100644
--- a/code/api/src/main/java/org/apache/tamaya/spi/PropertyValueBuilder.java
+++ b/code/api/src/main/java/org/apache/tamaya/spi/PropertyValueBuilder.java
@@ -18,7 +18,10 @@
*/
package org.apache.tamaya.spi;
-import java.util.*;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Objects;
import java.util.concurrent.atomic.AtomicInteger;
/**
@@ -26,7 +29,7 @@ import java.util.concurrent.atomic.AtomicInteger;
* @deprecated Use {@link PropertyValue} directly.
*/
@Deprecated
-public final class PropertyValueBuilder {
+public class PropertyValueBuilder {
/** The key accessed. */
protected String key;
/** The property createValue. */
@@ -34,7 +37,7 @@ public final class PropertyValueBuilder {
/** The property createValue. */
protected String source;
/** additional metadata entries (optional). */
- protected Map<String,Object> metaEntries = new HashMap<>();
+ protected Map<String,String> metaEntries = new HashMap<>();
/** The getParent getField, null if it's a root getField. */
protected PropertyValue parent;
/** The getField's getIndex, if the getField is participating in a createList structure. */
@@ -57,7 +60,7 @@ public final class PropertyValueBuilder {
* @param metaEntries the context data to be applied, not {@code null}.
* @return the builder for chaining.
*/
- public PropertyValueBuilder setMeta(Map<String, Object> metaEntries) {
+ public PropertyValueBuilder setMeta(Map<String, String> metaEntries) {
this.metaEntries.clear();
this.metaEntries.putAll(metaEntries);
return this;
@@ -69,7 +72,7 @@ public final class PropertyValueBuilder {
* @param value the context createValue, not {@code null} (will be converted to String).
* @return the builder for chaining.
*/
- public PropertyValueBuilder addMetaEntry(String key, Object value) {
+ public PropertyValueBuilder addMetaEntry(String key, String value) {
Objects.requireNonNull(key, "Meta key must be given.");
Objects.requireNonNull(value, "Meta createValue must be given.");
@@ -78,39 +81,11 @@ public final class PropertyValueBuilder {
}
/**
- * Add an additional context data information.
- * @param type the context data type, used as key, not {@code null}.
- * @param value the context createValue, not {@code null}.
- * @param <T> the type of the class modeled by the type parameter
- * @return the builder for chaining.
- */
- public <T> PropertyValueBuilder addMetaEntry(Class<T> type, T value) {
- Objects.requireNonNull(type, "Meta key must be given.");
- Objects.requireNonNull(value, "Meta createValue must be given.");
-
- this.metaEntries.put(type.toString(), value);
- return this;
- }
-
- /**
- * Add an additional context data information, using the data's class name as key.
- * @param value the context createValue, not {@code null}.
- * @param <T> the type of the class modeled by the type parameter
- * @return the builder for chaining.
- */
- public <T> PropertyValueBuilder addMetaEntry(T value) {
- Objects.requireNonNull(value, "Meta createValue must be given.");
-
- this.metaEntries.put(value.getClass().toString(), value);
- return this;
- }
-
- /**
* Adds the context data given.
* @param metaEntries the context data to be applied, not {@code null}.
* @return the builder for chaining.
*/
- public PropertyValueBuilder addMetaEntries(Map<String, Object> metaEntries) {
+ public PropertyValueBuilder setMetaEntries(Map<String, String> metaEntries) {
this.metaEntries.putAll(metaEntries);
return this;
}
@@ -120,7 +95,7 @@ public final class PropertyValueBuilder {
* @param key the entry's key, not {@code null}.
* @return the builder for chaining.
*/
- public PropertyValueBuilder removeMeta(String key) {
+ public PropertyValueBuilder removeMetaEntry(String key) {
Objects.requireNonNull(key, "Key must be given.");
this.metaEntries.remove(key);
@@ -131,17 +106,17 @@ public final class PropertyValueBuilder {
* Get the createValue's context data.
* @return the context data, not {@code null}.
*/
- public Map<String,Object> getMetaEntries() {
+ public Map<String,String> getMetaEntries() {
return Collections.unmodifiableMap(this.metaEntries);
}
/**
* Get the createValue's context data.
- * @param <T> the type of the class modeled by the type parameter
+ * @param key the key, not null.
* @return the context data, not {@code null}.
*/
- public <T> T getMeta(String key) {
- return (T)this.metaEntries.get(key);
+ public String getMeta(String key) {
+ return this.metaEntries.get(key);
}
/**
@@ -161,8 +136,8 @@ public final class PropertyValueBuilder {
*/
public PropertyValueBuilder mapKey(String key) {
// todo obf if (1==1) throw new RuntimeException("No tests written.");
- Map<String,Object> newContext = new HashMap<>();
- for(Map.Entry<String,Object> en:this.metaEntries.entrySet()){
+ Map<String,String> newContext = new HashMap<>();
+ for(Map.Entry<String,String> en:this.metaEntries.entrySet()){
if(en.getKey().startsWith("_"+this.key)){
newContext.put("_"+key+'.'+ en.getKey().substring(this.key.length()+1), en.getValue());
}else{
@@ -199,7 +174,7 @@ public final class PropertyValueBuilder {
* Sets a new source.
* @param source the new source, not {@code null}.
* @return the builder for chaining.
- * @deprecated Use {@link #addMetaEntry(String, Object)} (String, Object)}
+ * @deprecated Use {@link #addMetaEntry(String, String)}
*/
@Deprecated
public PropertyValueBuilder setSource(String source) {
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/606f8ec6/code/api/src/main/java/org/apache/tamaya/spi/PropertyValueCombinationPolicy.java
----------------------------------------------------------------------
diff --git a/code/api/src/main/java/org/apache/tamaya/spi/PropertyValueCombinationPolicy.java b/code/api/src/main/java/org/apache/tamaya/spi/PropertyValueCombinationPolicy.java
deleted file mode 100644
index 59f0f7a..0000000
--- a/code/api/src/main/java/org/apache/tamaya/spi/PropertyValueCombinationPolicy.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * 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;
-
-
-
-/**
- * Policy that determines how the final createValue of a configuration entry is evaluated. An instances of this
- * interface can be registered to current control how multiple PropertySources are combined. This is useful in cases
- * where the default overriding policy as implemented in {@link #DEFAULT_OVERRIDING_POLICY} is not matching
- * the need of the current application, e.g. then entries containing multiple values should be combined to new
- * values instead of overridden.
- * @deprecated Will be implemented through implementation specific mechanisms.
- */
-@Deprecated
-public interface PropertyValueCombinationPolicy {
-
- /**
- * Default overriding collector, where each existing entry ({@code current} is overridden by a subsequent non-null
- * entry evaluated by {@code propertySource.current(key)}.
- */
- PropertyValueCombinationPolicy DEFAULT_OVERRIDING_POLICY = new PropertyValueCombinationPolicy(){
-
- @Override
- public PropertyValue collect(PropertyValue currentValue, String key, PropertySource propertySource) {
- PropertyValue value = propertySource.get(key);
- return value!=null?value:currentValue;
- }
- };
-
- /**
- * @deprecated Use {@linkplain #DEFAULT_OVERRIDING_POLICY} instead. Will be removed in 1.0.
- */
- @Deprecated
- PropertyValueCombinationPolicy DEFAULT_OVERRIDING_COLLECTOR = DEFAULT_OVERRIDING_POLICY;
-
-
- /**
- * Method that is called for each createValue evaluated by a PropertySource for the given key. This method is called
- * either when a single key is accessed, e.g. by calling {@code org.apache.tamaya.Configuration.getXXX}, but also
- * when the full configuration property map is accessed by calling
- * {@link org.apache.tamaya.Configuration#getProperties()}.
- *
- * @param currentValue the current createValue, including metadata entries. If no such key is present the current createValue
- * is null.
- * The collector should either combine the existing createValue with createValue from {@code currentValue}
- * or replace the createValue in {@code currentValue} with {@code valueRead}, hereby returning the
- * result to be used as new {@code currentValue}.
- * @param key The current key to be evaluated.
- * @param propertySource The PropertySource that may return an createValue for the given key. The PropertySource given
- * may be evaluated for additional getMeta-data, how the given values are to be combined.
- * Note that the createValue returned by a PropertySource can be null. In that case
- * {@code currentValue} should be returned in almost all cases.
- * @return the createValue to be used for future evaluation, including metadata entries.
- */
- PropertyValue collect(PropertyValue currentValue, String key, PropertySource propertySource);
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/606f8ec6/code/api/src/main/java/org/apache/tamaya/spi/ServiceContext.java
----------------------------------------------------------------------
diff --git a/code/api/src/main/java/org/apache/tamaya/spi/ServiceContext.java b/code/api/src/main/java/org/apache/tamaya/spi/ServiceContext.java
index 0576196..1f346b7 100644
--- a/code/api/src/main/java/org/apache/tamaya/spi/ServiceContext.java
+++ b/code/api/src/main/java/org/apache/tamaya/spi/ServiceContext.java
@@ -108,6 +108,7 @@ public interface ServiceContext extends ClassloaderAware{
* the one with the highest {@link javax.annotation.Priority} will be used as the base
* for creating subsequent instances.
*
+ * @param supplier the supplier to create a new service, if no service could be autodetected.
* @param <T> the type of the service type.
* @param serviceType the service type.
* @return The new instance to be used, or {@code null}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/606f8ec6/code/api/src/test/java/org/apache/tamaya/ConfigurationProviderTest.java
----------------------------------------------------------------------
diff --git a/code/api/src/test/java/org/apache/tamaya/ConfigurationProviderTest.java b/code/api/src/test/java/org/apache/tamaya/ConfigurationProviderTest.java
index 787e04f..473c637 100644
--- a/code/api/src/test/java/org/apache/tamaya/ConfigurationProviderTest.java
+++ b/code/api/src/test/java/org/apache/tamaya/ConfigurationProviderTest.java
@@ -19,16 +19,14 @@
package org.apache.tamaya;
import org.apache.tamaya.spi.ConfigurationBuilder;
-import org.apache.tamaya.spi.ConfigurationContext;
-import org.apache.tamaya.spi.ConfigurationContextBuilder;
import org.junit.Test;
import static org.assertj.core.api.Assertions.*;
import org.mockito.Mockito;
/**
*
- * Test the {@link ConfigurationProivder} class. The tests end up being tests of
- * the default methods in the {@link ConfigurationProivder} interface as they
+ * Test the {@link ConfigurationProvider} class. The tests end up being tests of
+ * the default methods in the {@link ConfigurationProvider} interface as they
* pass through to the {@link TestConfigurationProvider} mocked createObject.
*/
public class ConfigurationProviderTest {
@@ -44,24 +42,6 @@ public class ConfigurationProviderTest {
}
/**
- * Test of getConfigurationContext and setConfigurationContext method, of
- * class ConfigurationProvider.
- */
- @Test
- public void testGetSetConfigurationContext() {
- ConfigurationContext currentContext = ConfigurationProvider.getConfigurationContext();
- assertThat(currentContext instanceof ConfigurationContext).isTrue();
- ConfigurationContext newContext = Mockito.mock(ConfigurationContext.class);
- try{
- ConfigurationProvider.setConfigurationContext(newContext);
- assertThat(ConfigurationProvider.getConfigurationContext()).isEqualTo(newContext);
- }finally{
- ConfigurationProvider.setConfigurationContext(currentContext);
- }
- assertThat(ConfigurationProvider.getConfigurationContext()).isEqualTo(currentContext);
- }
-
- /**
* Test of getConfiguration method, of class ConfigurationProvider.
*/
@Test
@@ -87,15 +67,6 @@ public class ConfigurationProviderTest {
assertThat(result instanceof ConfigurationBuilder).isTrue();
}
- /**
- * Test of getConfigurationContextBuilder method, of class ConfigurationProvider.
- */
- @Test
- public void testGetConfigurationContextBuilder() {
- ConfigurationContextBuilder result = ConfigurationProvider.getConfigurationContextBuilder();
- assertThat(result instanceof ConfigurationContextBuilder).isTrue();
- }
-
@Test
public void testConstructorFails(){
assertThat(ConfigurationProvider.class.getConstructors().length == 0).isTrue();
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/606f8ec6/code/api/src/test/java/org/apache/tamaya/TestConfigurationProvider.java
----------------------------------------------------------------------
diff --git a/code/api/src/test/java/org/apache/tamaya/TestConfigurationProvider.java b/code/api/src/test/java/org/apache/tamaya/TestConfigurationProvider.java
index b4660f8..e83045f 100644
--- a/code/api/src/test/java/org/apache/tamaya/TestConfigurationProvider.java
+++ b/code/api/src/test/java/org/apache/tamaya/TestConfigurationProvider.java
@@ -22,7 +22,6 @@ import javax.annotation.Priority;
import org.apache.tamaya.spi.ConfigurationContext;
import org.apache.tamaya.spi.ConfigurationBuilder;
-import org.apache.tamaya.spi.ConfigurationContextBuilder;
import org.apache.tamaya.spi.ConfigurationProviderSpi;
import org.mockito.Mockito;
@@ -47,31 +46,11 @@ public class TestConfigurationProvider implements ConfigurationProviderSpi {
}
@Override
- public ConfigurationContext getConfigurationContext() {
- return context;
- }
-
- public ConfigurationContext getConfigurationContextFromInterface(){
- return ConfigurationProviderSpi.super.getConfigurationContext();
- }
-
- @Override
- public void setConfigurationContext(ConfigurationContext context) {
- this.context = context;
- }
-
-
- @Override
public ConfigurationBuilder getConfigurationBuilder() {
return Mockito.mock(ConfigurationBuilder.class, Mockito.RETURNS_DEEP_STUBS);
}
@Override
- public ConfigurationContextBuilder getConfigurationContextBuilder() {
- return Mockito.mock(ConfigurationContextBuilder.class);
- }
-
- @Override
public void setConfiguration(Configuration config, ClassLoader classLoader) {
this.config = config;
}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/606f8ec6/code/api/src/test/java/org/apache/tamaya/spi/ConfigurationProviderSpiTest.java
----------------------------------------------------------------------
diff --git a/code/api/src/test/java/org/apache/tamaya/spi/ConfigurationProviderSpiTest.java b/code/api/src/test/java/org/apache/tamaya/spi/ConfigurationProviderSpiTest.java
index 067a18a..d5624d8 100644
--- a/code/api/src/test/java/org/apache/tamaya/spi/ConfigurationProviderSpiTest.java
+++ b/code/api/src/test/java/org/apache/tamaya/spi/ConfigurationProviderSpiTest.java
@@ -21,38 +21,14 @@ package org.apache.tamaya.spi;
import org.apache.tamaya.TestConfigurationProvider;
import org.junit.Test;
import static org.assertj.core.api.Assertions.*;
-import org.mockito.Mockito;
public class ConfigurationProviderSpiTest {
-TestConfigurationProvider configProvider = new TestConfigurationProvider();
+ TestConfigurationProvider configProvider = new TestConfigurationProvider();
@Test
public void testIsConfigurationSettableByDefault(){
assertThat(configProvider.isConfigurationSettable(Thread.currentThread().getContextClassLoader())).isTrue();
}
- @Test
- public void testIsConfigurationContextSettable(){
- assertThat(configProvider.isConfigurationContextSettable()).isTrue();
- }
-
- /**
- * Test of getConfigurationContext and setConfigurationContext method, of
- * class ConfigurationProviderSpi.
- */
- @Test
- public void testGetSetConfigurationContext() {
- ConfigurationContext currentContext = configProvider.getConfigurationContextFromInterface();
- assertThat(currentContext instanceof ConfigurationContext).isTrue();
- ConfigurationContext newContext = Mockito.mock(ConfigurationContext.class);
- try{
- configProvider.setConfigurationContext(newContext);
- //The mocked TestConfigurationProvider doesn't setCurrent the context on the
- // inner Configuration createObject, as that's deprecated.
- assertThat(configProvider.getConfigurationContext()).isEqualTo(newContext);
- }finally{
- configProvider.setConfigurationContext(currentContext);
- }
- }
}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/606f8ec6/code/api/src/test/java/org/apache/tamaya/spi/ConversionContextTest.java
----------------------------------------------------------------------
diff --git a/code/api/src/test/java/org/apache/tamaya/spi/ConversionContextTest.java b/code/api/src/test/java/org/apache/tamaya/spi/ConversionContextTest.java
index a6a777f..620b2b6 100644
--- a/code/api/src/test/java/org/apache/tamaya/spi/ConversionContextTest.java
+++ b/code/api/src/test/java/org/apache/tamaya/spi/ConversionContextTest.java
@@ -20,17 +20,13 @@ package org.apache.tamaya.spi;
import java.lang.annotation.Annotation;
import java.lang.reflect.AnnotatedElement;
-import org.apache.tamaya.ConfigOperator;
-import org.apache.tamaya.ConfigQuery;
import org.apache.tamaya.Configuration;
import org.apache.tamaya.TypeLiteral;
-import org.apache.tamaya.spi.*;
import org.junit.Test;
import java.net.InetAddress;
import java.util.ArrayList;
import java.util.List;
-import java.util.Map;
import static org.assertj.core.api.Assertions.*;
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/606f8ec6/code/api/src/test/java/org/apache/tamaya/spi/PropertySourceTest.java
----------------------------------------------------------------------
diff --git a/code/api/src/test/java/org/apache/tamaya/spi/PropertySourceTest.java b/code/api/src/test/java/org/apache/tamaya/spi/PropertySourceTest.java
index 3b8dbac..c979829 100644
--- a/code/api/src/test/java/org/apache/tamaya/spi/PropertySourceTest.java
+++ b/code/api/src/test/java/org/apache/tamaya/spi/PropertySourceTest.java
@@ -35,20 +35,10 @@ public class PropertySourceTest {
assertThat(instance.getName()).isEqualTo("<empty>");
assertThat(instance.get("key")).isNull();
assertThat(instance.getProperties().isEmpty()).isTrue();
- assertThat(instance.isScannable()).isFalse();
assertThat(instance.toString()).isEqualTo("PropertySource.EMPTY");
}
- /**
- * Test of default isScannable method, of class PropertySource.
- */
- @Test
- public void testIsScannableByDefault() {
- PropertySource instance = new PropertySourceImpl();
- assertThat(instance.isScannable()).isEqualTo(true);
- }
-
public class PropertySourceImpl implements PropertySource {
public int getOrdinal() {
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/606f8ec6/code/api/src/test/java/org/apache/tamaya/spi/PropertyValueCombinationPolicyTest.java
----------------------------------------------------------------------
diff --git a/code/api/src/test/java/org/apache/tamaya/spi/PropertyValueCombinationPolicyTest.java b/code/api/src/test/java/org/apache/tamaya/spi/PropertyValueCombinationPolicyTest.java
deleted file mode 100644
index edf6765..0000000
--- a/code/api/src/test/java/org/apache/tamaya/spi/PropertyValueCombinationPolicyTest.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * 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 org.junit.Test;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-public class PropertyValueCombinationPolicyTest {
-
- @Test
- public void defaulPolicyOverridesCurrentValueByTheOneOfTheGivenProperySource() throws Exception {
- PropertyValueCombinationPolicy policy = PropertyValueCombinationPolicy.DEFAULT_OVERRIDING_POLICY;
-
- PropertyValue current = PropertyValue.of("a", "AAA", "Test");
- PropertyValue v = policy.collect(current, "a", new DummyPropertySource());
- assertThat(v.getKey()).isEqualTo("a");
- assertThat(v.getValue()).isEqualTo("Ami");
- }
-
- @Test
- public void defaulPolicyOverridesKeepsTheCurrentValueIfGivenProperySourceDoesNotHaveIt() throws Exception {
- PropertyValueCombinationPolicy policy = PropertyValueCombinationPolicy.DEFAULT_OVERRIDING_POLICY;
-
- PropertyValue current = PropertyValue.of("a", "AAA", "Test");
- PropertyValue v = policy.collect(current, "a", PropertySource.EMPTY);
- assertThat(v.getKey()).isEqualTo("a");
- assertThat(v.getValue()).isEqualTo("AAA");
- assertThat(v).isEqualTo(current);
- }
-
-
- static class DummyPropertySource implements PropertySource {
- @Override
- public int getOrdinal() {
- return 10;
- }
-
- @Override
- public String getName() {
- return "NAME";
- }
-
- @Override
- public PropertyValue get(String key) {
- return getProperties().get(key);
- }
-
- @Override
- public Map<String, PropertyValue> getProperties() {
- PropertyValue a = PropertyValue.of("a", "Ami", "Test");
- PropertyValue b = PropertyValue.of("b", "Big", "Test");
-
- HashMap<String, PropertyValue> properties = new HashMap<>();
-
- properties.put(a.getKey(), a);
- properties.put(b.getKey(), b);
-
- return properties;
- }
-
- @Override
- public boolean isScannable() {
- return true;
- }
- }
-
-}
\ No newline at end of file