You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tamaya.apache.org by pl...@apache.org on 2016/09/15 17:26:34 UTC
[17/24] incubator-tamaya git commit: Removed all modules from the
main repository. They will be reborn in separate ASF repository.
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/formats/src/test/java/org/apache/tamaya/format/FlattenedDefaultPropertySourceTest.java
----------------------------------------------------------------------
diff --git a/modules/formats/src/test/java/org/apache/tamaya/format/FlattenedDefaultPropertySourceTest.java b/modules/formats/src/test/java/org/apache/tamaya/format/FlattenedDefaultPropertySourceTest.java
deleted file mode 100644
index adc94f6..0000000
--- a/modules/formats/src/test/java/org/apache/tamaya/format/FlattenedDefaultPropertySourceTest.java
+++ /dev/null
@@ -1,98 +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.format;
-
-import org.apache.tamaya.format.formats.PropertiesFormat;
-import org.apache.tamaya.spi.PropertySource;
-import org.junit.Test;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-
-/**
- * Tests for {@link org.apache.tamaya.format.FlattenedDefaultPropertySource}.
- */
-public class FlattenedDefaultPropertySourceTest {
-
- @Test
- public void testGetName() throws Exception {
- FlattenedDefaultPropertySource ps = new FlattenedDefaultPropertySource(createConfigurationData("test1"));
- assertEquals("test1", ps.getName());
- }
-
- private ConfigurationData createConfigurationData(String sourceName) {
- return ConfigurationDataBuilder.of(sourceName, new PropertiesFormat())
- .addProperty("a", "aValue").addSectionProperty("section1", "sectionKey1", "sectionValue11")
- .addSections("section1", "section12")
- .addSectionProperty("section2", "sectionKey1", "sectionValue21").build();
- }
-
- private ConfigurationData createConfigurationData(String sourceName, int ordinal) {
- return ConfigurationDataBuilder.of(sourceName, new PropertiesFormat())
- .addProperty("a", "aValue").addSectionProperty("section1", "sectionKey1", "sectionValue11")
- .addSections("section1", "section12").addProperty(PropertySource.TAMAYA_ORDINAL, String.valueOf(ordinal))
- .addSectionProperty("section2", "sectionKey1", "sectionValue21").build();
- }
-
- private ConfigurationData createConfigurationDataNoDefault(String sourceName) {
- return ConfigurationDataBuilder.of(sourceName, new PropertiesFormat())
- .addSectionProperty("section1", "sectionKey1", "sectionValue11")
- .addSections("section1", "section12")
- .addSectionProperty("section2", "sectionKey1", "sectionValue21").build();
- }
-
- @Test
- public void testGetOrdinal() throws Exception {
- FlattenedDefaultPropertySource ps = new FlattenedDefaultPropertySource(createConfigurationData("test1", 11));
- assertEquals(11, ps.getOrdinal());
- }
-
- @Test
- public void testGet() throws Exception {
- FlattenedDefaultPropertySource ps = new FlattenedDefaultPropertySource(createConfigurationData("test2"));
- assertEquals("aValue", ps.get("a").get("a"));
- assertNotNull(ps.get("section1.sectionKey1").get("section1.sectionKey1"));
- assertNotNull(ps.get("section2.sectionKey1").get("section2.sectionKey1"));
- assertNull(ps.get("sectionKey1"));
- ps = new FlattenedDefaultPropertySource(createConfigurationDataNoDefault("test2"));
- assertEquals("sectionValue11", ps.get("section1.sectionKey1").get("section1.sectionKey1"));
- assertEquals("sectionValue21", ps.get("section2.sectionKey1").get("section2.sectionKey1"));
- assertNull(ps.get("a"));
- assertNull(ps.get("section1"));
- }
-
- @Test
- public void testGetProperties() throws Exception {
- FlattenedDefaultPropertySource ps = new FlattenedDefaultPropertySource(createConfigurationData("test3"));
- assertNotNull(ps.getProperties());
- assertEquals("aValue", ps.getProperties().get("a"));
- assertNotNull(ps.getProperties().get("section1.sectionKey1"));
- assertNotNull(ps.getProperties().get("section2.sectionKey1"));
- assertNull(ps.getProperties().get("section1.sectionKey2"));
- assertNull(ps.getProperties().get("section2.sectionKey2"));
- assertNull(ps.getProperties().get("sectionKey1"));
- assertNull(ps.getProperties().get("sectionKey2"));
- ps = new FlattenedDefaultPropertySource(createConfigurationDataNoDefault("test3"));
- assertNotNull(ps.getProperties());
- assertEquals("sectionValue11", ps.getProperties().get("section1.sectionKey1"));
- assertEquals("sectionValue21", ps.getProperties().get("section2.sectionKey1"));
- assertNull(ps.get("section1"));
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/formats/src/test/java/org/apache/tamaya/format/InputStreamFactoryTest.java
----------------------------------------------------------------------
diff --git a/modules/formats/src/test/java/org/apache/tamaya/format/InputStreamFactoryTest.java b/modules/formats/src/test/java/org/apache/tamaya/format/InputStreamFactoryTest.java
deleted file mode 100644
index c05da09..0000000
--- a/modules/formats/src/test/java/org/apache/tamaya/format/InputStreamFactoryTest.java
+++ /dev/null
@@ -1,145 +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.format;
-
-import org.junit.Test;
-import org.mockito.ArgumentCaptor;
-
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-
-import static org.hamcrest.CoreMatchers.equalTo;
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
-
-public class InputStreamFactoryTest {
-
- @Test(expected = NullPointerException.class)
- public void ctorEnforcesNonNullOriginal() throws IOException {
- new InputStreamFactory(null);
- }
-
- @Test
- public void givenStreamIsClosedInTryWithResourcesConstruct() throws Exception {
- InputStream stream = mock(InputStream.class);
- doReturn(34).when(stream).read();
-
- InputStreamFactory factory = new InputStreamFactory(stream);
- verify(stream).close();
- for (int i = 0; i < 100; i++) {
- try (InputStream in = factory.createInputStream()) {
- in.read();
- }
- }
- verify(stream).close();
- }
-
- @Test
- public void callToReadIsNotForwardedCallToWrapped() throws IOException {
- InputStream stream = new ByteArrayInputStream(new byte[]{1, 2, 3, 4});
- InputStreamFactory closer = new InputStreamFactory(stream);
- byte[] byteArray = new byte[4];
- for (int i = 0; i < 100; i++) {
- InputStream is = closer.createInputStream();
- assertThat(is.read(byteArray), equalTo(4));
- }
- }
-
-
- @Test
- public void callToSkipIsForwardedToWrapped() throws IOException {
- InputStream stream = new ByteArrayInputStream(new byte[]{1, 2, 3, 4});
- InputStreamFactory closer = new InputStreamFactory(stream);
- for (int i = 0; i < 100; i++) {
- InputStream is = closer.createInputStream();
- assertThat(is.skip(2L), equalTo(2L));
- }
- }
-
-
- @Test
- public void callToAvailableIsNotForwardedToWrapped() throws IOException {
- InputStream stream = new ByteArrayInputStream(new byte[]{1, 2, 3, 4});
- InputStreamFactory closer = new InputStreamFactory(stream);
- for (int i = 0; i < 100; i++) {
- InputStream is = closer.createInputStream();
- assertThat(is.available(), equalTo(4));
- }
- }
-
- @Test
- public void callToCloseIsNotForwardedToWrapped() throws IOException {
- InputStream stream = new ByteArrayInputStream(new byte[]{1, 2, 3, 4});
- InputStreamFactory closer = new InputStreamFactory(stream);
- for (int i = 0; i < 100; i++) {
- InputStream is = closer.createInputStream();
- is.close();
- }
- }
-
- @Test
- public void callToMarkIsNotForwardedToWrapped() throws IOException {
-// ArgumentCaptor<Integer> captor = ArgumentCaptor.forClass(Integer.class);
- InputStream stream = new ByteArrayInputStream(new byte[]{1, 2, 3, 4});
- InputStreamFactory closer = new InputStreamFactory(stream);
- for (int i = 0; i < 100; i++) {
- InputStream is = closer.createInputStream();
- is.mark(2);
- }
- }
-
-
- @Test
- public void callToResetIsNotForwardedToWrapped() throws IOException {
- InputStream stream = new ByteArrayInputStream(new byte[]{1, 2, 3, 4});
- InputStreamFactory closer = new InputStreamFactory(stream);
- for (int i = 0; i < 100; i++) {
- InputStream is = closer.createInputStream();
- is.reset();
- }
- }
-
- @Test
- public void callToMarkSupportedIsNotForwardedToWrapped() throws IOException {
- InputStream stream = new ByteArrayInputStream(new byte[]{1, 2, 3, 4});
- InputStreamFactory closer = new InputStreamFactory(stream);
- for (int i = 0; i < 100; i++) {
- InputStream is = closer.createInputStream();
- assertThat(is.markSupported(), is(true));
- }
- }
-
- @Test
- public void callToReadIsForwardedToWrapped() throws IOException {
- InputStream stream = new ByteArrayInputStream(new byte[]{1, 2, 3, 4});
- InputStreamFactory closer = new InputStreamFactory(stream);
- for (int i = 0; i < 100; i++) {
- InputStream is = closer.createInputStream();
- assertThat(is.read(), equalTo(1));
- assertThat(is.read(), equalTo(2));
- assertThat(is.read(), equalTo(3));
- assertThat(is.read(), equalTo(4));
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/formats/src/test/resources/Test.ini
----------------------------------------------------------------------
diff --git a/modules/formats/src/test/resources/Test.ini b/modules/formats/src/test/resources/Test.ini
deleted file mode 100644
index 906a1e6..0000000
--- a/modules/formats/src/test/resources/Test.ini
+++ /dev/null
@@ -1,26 +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 current 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.
-#
-
-aGeneralEntry=blabla
-
-[MySection1]
-sectionEntry1=value1
-
-[MySection2]
-sectionEntry2=value2
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/formats/src/test/resources/Test.properties
----------------------------------------------------------------------
diff --git a/modules/formats/src/test/resources/Test.properties b/modules/formats/src/test/resources/Test.properties
deleted file mode 100644
index ced544b..0000000
--- a/modules/formats/src/test/resources/Test.properties
+++ /dev/null
@@ -1,21 +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 current 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.
-#
-aGeneralEntry=blabla
-MySection1.sectionEntry1=value1
-MySection2.sectionEntry2=value2
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/functions/pom.xml
----------------------------------------------------------------------
diff --git a/modules/functions/pom.xml b/modules/functions/pom.xml
deleted file mode 100644
index 88d95e4..0000000
--- a/modules/functions/pom.xml
+++ /dev/null
@@ -1,79 +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 current 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.
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.apache.tamaya.ext</groupId>
- <artifactId>tamaya-extensions</artifactId>
- <version>0.3-incubating-SNAPSHOT</version>
- <relativePath>..</relativePath>
- </parent>
-
- <artifactId>tamaya-functions</artifactId>
- <name>Apache Tamaya Modules - Common Functional Extensions</name>
- <packaging>bundle</packaging>
-
- <properties>
- <jdkVersion>1.7</jdkVersion>
- </properties>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.tamaya</groupId>
- <artifactId>tamaya-api</artifactId>
- <version>${project.version}</version>
- </dependency>
- <!-- Test scope only, do not create a code dependency! -->
- <dependency>
- <groupId>org.apache.tamaya</groupId>
- <artifactId>tamaya-core</artifactId>
- <version>${project.version}</version>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.hamcrest</groupId>
- <artifactId>java-hamcrest</artifactId>
- </dependency>
-
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <extensions>true</extensions>
- <configuration>
- <instructions>
- <Export-Package>
- org.apache.tamaya.functions
- </Export-Package>
- </instructions>
- </configuration>
- </plugin>
- </plugins>
- </build>
-
-</project>
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/functions/src/main/java/org/apache/tamaya/functions/CombinedConfiguration.java
----------------------------------------------------------------------
diff --git a/modules/functions/src/main/java/org/apache/tamaya/functions/CombinedConfiguration.java b/modules/functions/src/main/java/org/apache/tamaya/functions/CombinedConfiguration.java
deleted file mode 100644
index 8a479e9..0000000
--- a/modules/functions/src/main/java/org/apache/tamaya/functions/CombinedConfiguration.java
+++ /dev/null
@@ -1,146 +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.functions;
-
-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.ConfigurationContext;
-
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * Combines a set of child configurations to a new one, by overriding the first entries with result from
- * later instances.
- */
-class CombinedConfiguration implements Configuration{
- /** The name of the new configuration. */
- private final String name;
- /** The configuration's in evaluation order. Instances with higher indices override results with lower ones. */
- private final Configuration[] configurations;
-
- /**
- * Creates a combined configuration instance.
- * @param configName the name of the new config.
- * @param configs the configurations hereby instances with higher indices override results with lower ones.
- */
- public CombinedConfiguration(String configName, Configuration... configs){
- this.name = configName;
- this.configurations =configs.clone();
- }
-
- @Override
- public String get(String key) {
- String curValue = null;
- for(Configuration config: configurations){
- String value = config.get(key);
- if(value!=null){
- curValue = value;
- }
- }
- return curValue;
- }
-
- @Override
- public String getOrDefault(String key, String defaultValue) {
- String val = get(key);
- if(val==null){
- return defaultValue;
- }
- return val;
- }
-
- @Override
- public <T> T getOrDefault(String key, Class<T> type, T defaultValue) {
- T val = get(key, type);
- if(val==null){
- return defaultValue;
- }
- return val;
- }
-
- @Override
- public <T> T get(String key, Class<T> type) {
- T curValue = null;
- for(Configuration config: configurations){
- T value = config.get(key, type);
- if(value!=null){
- curValue = value;
- }
- }
- return curValue;
- }
-
- @Override
- public <T> T get(String key, TypeLiteral<T> type) {
- T curValue = null;
- for(Configuration config: configurations){
- T value = config.get(key, type);
- if(value!=null){
- curValue = value;
- }
- }
- return curValue;
- }
-
- @Override
- public <T> T getOrDefault(String key, TypeLiteral<T> type, T defaultValue) {
- T val = get(key, type);
- if(val==null){
- return defaultValue;
- }
- return val;
- }
-
- @Override
- public Map<String, String> getProperties() {
- Map<String, String> result = new HashMap<>();
- for(Configuration ps:configurations){
- result.putAll(ps.getProperties());
- }
- return result;
- }
-
- @Override
- public Configuration with(ConfigOperator operator) {
- return operator.operate(this);
- }
-
- @Override
- public <T> T query(ConfigQuery<T> query) {
- return query.query(this);
- }
-
- @Override
- public ConfigurationContext getContext() {
- // TODO thjink on combining the participating contexts...
- return configurations[0].getContext();
- }
-
- @Override
- public String toString() {
- return "CombinedConfiguration{" +
- "name='" + name + '\'' +
- ", configurations=" + Arrays.toString(configurations) +
- '}';
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/functions/src/main/java/org/apache/tamaya/functions/ConfigWrappingPropertySource.java
----------------------------------------------------------------------
diff --git a/modules/functions/src/main/java/org/apache/tamaya/functions/ConfigWrappingPropertySource.java b/modules/functions/src/main/java/org/apache/tamaya/functions/ConfigWrappingPropertySource.java
deleted file mode 100644
index 83a628a..0000000
--- a/modules/functions/src/main/java/org/apache/tamaya/functions/ConfigWrappingPropertySource.java
+++ /dev/null
@@ -1,80 +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.functions;
-
-import org.apache.tamaya.Configuration;
-import org.apache.tamaya.spi.PropertySource;
-import org.apache.tamaya.spi.PropertyValue;
-
-import java.util.Map;
-import java.util.Objects;
-
-/**
- * PropertySource that wraps a Configuration instance.
- */
-final class ConfigWrappingPropertySource implements PropertySource {
- /** The property source name. */
- private final String name;
- /** The ordinal. */
- private final int ordinal;
- /** The wrapped config. */
- private final Configuration config;
-
- /**
- * Constructor.
- * @param name the property source name, not null.
- * @param ordinal ths ordinal
- * @param config the wrapped config, not null.
- */
- public ConfigWrappingPropertySource(String name, int ordinal, Configuration config){
- this.name = Objects.requireNonNull(name);
- this.ordinal = ordinal;
- this.config = Objects.requireNonNull(config);
- }
-
- @Override
- public int getOrdinal() {
- return ordinal;
- }
-
- @Override
- public String getName() {
- return name;
- }
-
- @Override
- public PropertyValue get(String key) {
- return PropertyValue.of(key, config.get(key), getName());
- }
-
- @Override
- public Map<String, String> getProperties() {
- return config.getProperties();
- }
-
- @Override
- public boolean isScannable() {
- return true;
- }
-
- @Override
- public String toString(){
- return "ConfigWrappingPropertySource(name="+name+", ordinal="+ordinal+", config="+config+")";
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/functions/src/main/java/org/apache/tamaya/functions/ConfigurationFunctions.java
----------------------------------------------------------------------
diff --git a/modules/functions/src/main/java/org/apache/tamaya/functions/ConfigurationFunctions.java b/modules/functions/src/main/java/org/apache/tamaya/functions/ConfigurationFunctions.java
deleted file mode 100644
index 6dd0427..0000000
--- a/modules/functions/src/main/java/org/apache/tamaya/functions/ConfigurationFunctions.java
+++ /dev/null
@@ -1,662 +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.functions;
-
-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.ConfigurationContext;
-import org.apache.tamaya.spi.ConfigurationContextBuilder;
-import org.apache.tamaya.spi.PropertyConverter;
-import org.apache.tamaya.spi.PropertyFilter;
-import org.apache.tamaya.spi.PropertySource;
-import org.apache.tamaya.spi.PropertyValueCombinationPolicy;
-
-import java.net.Inet4Address;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.Date;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.TreeMap;
-import java.util.TreeSet;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-/**
- * Accessor that provides useful functions along with configuration.
- */
-public final class ConfigurationFunctions {
-
- /**
- * The Logger used.
- */
- private static final Logger LOG = Logger.getLogger(ConfigurationFunctions.class.getName());
-
- /**
- * Implementation of an empty propertySource.
- */
- private static final Configuration EMPTY_CONFIGURATION = new Configuration() {
-
- @Override
- public String get(String key) {
- return null;
- }
-
- @Override
- public String getOrDefault(String key, String defaultValue) {
- return defaultValue;
- }
-
- @Override
- public <T> T getOrDefault(String key, Class<T> type, T defaultValue) {
- return defaultValue;
- }
-
- @Override
- public <T> T get(String key, Class<T> type) {
- return null;
- }
-
- @Override
- public <T> T get(String key, TypeLiteral<T> type) {
- return null;
- }
-
- @Override
- public <T> T getOrDefault(String key, TypeLiteral<T> type, T defaultValue) {
- return defaultValue;
- }
-
- @Override
- public Map<String, String> getProperties() {
- return Collections.emptyMap();
- }
-
- @Override
- public Configuration with(ConfigOperator operator) {
- return operator.operate(this);
- }
-
- @Override
- public <T> T query(ConfigQuery<T> query) {
- return query.query(this);
- }
-
- @Override
- public ConfigurationContext getContext() {
- return EMPTY_CONFIGURATION_CONTEXT;
- }
-
- @Override
- public String toString(){
- return "Configuration<empty>";
- }
- };
-
- private static final ConfigurationContext EMPTY_CONFIGURATION_CONTEXT = new ConfigurationContext() {
- @Override
- public void addPropertySources(PropertySource... propertySourcesToAdd) {
- // ignore
- }
-
- @Override
- public List<PropertySource> getPropertySources() {
- return Collections.emptyList();
- }
-
- @Override
- public <T> void addPropertyConverter(TypeLiteral<T> typeToConvert, PropertyConverter<T> propertyConverter) {
- // ignore
- }
-
- @Override
- public Map<TypeLiteral<?>, List<PropertyConverter<?>>> getPropertyConverters() {
- return Collections.emptyMap();
- }
-
- @Override
- public <T> List<PropertyConverter<T>> getPropertyConverters(TypeLiteral<T> type) {
- return Collections.emptyList();
- }
-
- @Override
- public List<PropertyFilter> getPropertyFilters() {
- return Collections.emptyList();
- }
-
- @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";
- }
- };
-
- /**
- * Private singleton constructor.
- */
- private ConfigurationFunctions() {
- }
-
- /**
- * Creates a ConfigOperator that creates a Configuration containing only keys
- * that are selected by the given {@link PropertyMatcher}.
- *
- * @param filter the filter, not null
- * @return the section configuration, with the areaKey stripped away.
- */
- public static ConfigOperator filter(final PropertyMatcher filter) {
- return new ConfigOperator() {
- @Override
- public Configuration operate(Configuration config) {
- return new FilteredConfiguration(config, filter, "FilterClass: " + filter.getClass().getName());
- }
- };
- }
-
- /**
- * Creates a ConfigOperator that creates a Configuration with keys mapped as
- * defined by the given keyMapper.
- *
- * @param keyMapper the keyMapper, not null
- * @return the section configuration, with the areaKey stripped away.
- */
- public static ConfigOperator map(final KeyMapper keyMapper) {
- return new ConfigOperator() {
- @Override
- public Configuration operate(Configuration config) {
- return new MappedConfiguration(config, keyMapper, null);
- }
- };
- }
-
- /**
- * Creates a ConfigOperator that creates a Configuration containing only keys
- * that are contained in the given section (non recursive). Hereby
- * the section key is stripped away fromMap the resulting key.
- *
- * @param areaKey the section key, not null
- * @return the section configuration, with the areaKey stripped away.
- */
- public static ConfigOperator section(String areaKey) {
- return section(areaKey, false);
- }
-
- /**
- * Creates a ConfigOperator that creates a Configuration containing only keys
- * that are contained in the given section (non recursive).
- *
- * @param areaKey the section key, not null
- * @param stripKeys if set to true, the section key is stripped away fromMap the resulting key.
- * @return the section configuration, with the areaKey stripped away.
- */
- public static ConfigOperator section(final String areaKey, final boolean stripKeys) {
- return new ConfigOperator() {
- @Override
- public Configuration operate(Configuration config) {
- Configuration filtered = new FilteredConfiguration(config,
- new PropertyMatcher() {
- @Override
- public boolean test(String k, String v) {
- return isKeyInSection(k, areaKey);
- }
- }, "section: " + areaKey);
- if (stripKeys) {
- return new MappedConfiguration(filtered, new KeyMapper(){
- @Override
- public String mapKey(String key) {
- if(key.startsWith(areaKey)) {
- return key.substring(areaKey.length());
- }
- return null;
- }
- }, "stripped");
- }
- return filtered;
- }
- };
- }
-
- /**
- * Calculates the current section key and compares it with the given key.
- *
- * @param key the fully qualified entry key, not null
- * @param sectionKey the section key, not null
- * @return true, if the entry is exact in this section
- */
- public static boolean isKeyInSection(String key, String sectionKey) {
- return key.startsWith(sectionKey);
- }
-
- /**
- * Calculates the current section key and compares it with the given section keys.
- *
- * @param key the fully qualified entry key, not null
- * @param sectionKeys the section keys, not null
- * @return true, if the entry is exact in this section
- */
- public static boolean isKeyInSections(String key, String... sectionKeys) {
- for (String areaKey : sectionKeys) {
- if (isKeyInSection(key, areaKey)) {
- return true;
- }
- }
- return false;
- }
-
- /**
- * Return a query to evaluate the set with all fully qualifies section names. This method should return the sections as accurate as possible,
- * but may not provide a complete set of sections that are finally accessible, especially when the underlying storage
- * does not support key iteration.
- *
- * @return s set with all sections, never {@code null}.
- */
- public static ConfigQuery<Set<String>> sections() {
- return new ConfigQuery<Set<String>>() {
- @Override
- public Set<String> query(Configuration config) {
- final Set<String> areas = new TreeSet<>();
- for (String s : config.getProperties().keySet()) {
- int index = s.lastIndexOf('.');
- if (index > 0) {
- areas.add(s.substring(0, index));
- }
- }
- return areas;
- }
- };
- }
-
- /**
- * Return a query to evaluate the set with all fully qualified section names, containing the transitive closure also including all
- * subarea names, regardless if properties are accessible or not. This method should return the sections as accurate
- * as possible, but may not provide a complete set of sections that are finally accessible, especially when the
- * underlying storage does not support key iteration.
- *
- * @return s set with all transitive sections, never {@code null}.
- */
- public static ConfigQuery<Set<String>> transitiveSections() {
- return new ConfigQuery<Set<String>>() {
- @Override
- public Set<String> query(Configuration config) {
- final Set<String> transitiveAreas = new TreeSet<>();
- for (String s : config.query(sections())) {
- transitiveAreas.add(s);
- int index = s.lastIndexOf('.');
- while (index > 0) {
- s = s.substring(0, index);
- transitiveAreas.add(s);
- index = s.lastIndexOf('.');
- }
- }
- return transitiveAreas;
- }
- };
- }
-
- /**
- * Return a query to evaluate the set with all fully qualified section names, containing only the
- * sections that match the predicate and have properties attached. This method should return the sections as accurate as possible,
- * but may not provide a complete set of sections that are finally accessible, especially when the underlying storage
- * does not support key iteration.
- *
- * @param predicate A predicate to deternine, which sections should be returned, not {@code null}.
- * @return s set with all sections, never {@code null}.
- */
- public static ConfigQuery<Set<String>> sections(final Predicate<String> predicate) {
- return new ConfigQuery<Set<String>>() {
- @Override
- public Set<String> query(Configuration config) {
- Set<String> result = new TreeSet<>();
- for (String s : sections().query(config)) {
- if (predicate.test(s)) {
- result.add(s);
- }
- }
- return result;
- }
- };
-
- }
-
- /**
- * Return a query to evaluate the set with all fully qualified section names, containing the transitive closure also including all
- * subarea names, regardless if properties are accessible or not. This method should return the sections as accurate as possible,
- * but may not provide a complete set of sections that are finally accessible, especially when the underlying storage
- * does not support key iteration.
- *
- * @param predicate A predicate to deternine, which sections should be returned, not {@code null}.
- * @return s set with all transitive sections, never {@code null}.
- */
- public static ConfigQuery<Set<String>> transitiveSections(final Predicate<String> predicate) {
- return new ConfigQuery<Set<String>>() {
- @Override
- public Set<String> query(Configuration config) {
- Set<String> result = new TreeSet<>();
- for (String s : transitiveSections().query(config)) {
- if (predicate.test(s)) {
- result.add(s);
- }
- }
- return result;
- }
- };
- }
-
- /**
- * Creates a ConfigOperator that creates a Configuration containing only keys
- * that are contained in the given section (recursive).
- *
- * @param sectionKeys the section keys, not null
- * @return the section configuration, with the areaKey stripped away.
- */
- public static ConfigOperator sectionsRecursive(String... sectionKeys) {
- return sectionRecursive(false, sectionKeys);
- }
-
- /**
- * Creates a Configuration that creates a new instance using the configuration instances provided. Hereby
- * values from higher instances override previous values..
- *
- * @param configName the new config name
- * @param configs the configs to be combined. The entries of the first config are overwritten
- * by entries of the later instances.
- * @return the resulting configuration instance.
- */
- public static Configuration combine(String configName, Configuration... configs) {
- return new CombinedConfiguration(configName, configs);
- }
-
- /**
- * Creates a {@link PropertySource}, based on the given {@link Configuration}. The keys and propertx map
- * are dynamically calculated, so the returned PropertySource is a real dynamic wrapper.
- * @param name the name of the property source, not null.
- * @param ordinal ordinal of the property source.
- * @param config the config to be mapped, not null.
- * @return a property source wrapping the configuration.
- */
- public static PropertySource propertySourceFrom(final String name, final int ordinal, final Configuration config){
- return new ConfigWrappingPropertySource(name, ordinal, config);
- }
-
- /**
- * Creates a ConfigOperator that creates a Configuration containing only keys
- * that are contained in the given section (recursive).
- *
- * @param sectionKeys the section keys, not null
- * @param stripKeys if set to true, the section key is stripped away fromMap the resulting key.
- * @return the section configuration, with the areaKey stripped away.
- */
- public static ConfigOperator sectionRecursive(final boolean stripKeys, final String... sectionKeys) {
- return new ConfigOperator() {
- @Override
- public Configuration operate(Configuration config) {
- Configuration filtered = new FilteredConfiguration(config, new PropertyMatcher() {
- @Override
- public boolean test(final String k, String v) {
- return isKeyInSections(k, sectionKeys);
- }
- }, "sections: " + Arrays.toString(sectionKeys));
- if (stripKeys) {
- return new MappedConfiguration(filtered, new KeyMapper() {
- @Override
- public String mapKey(String key) {
- return PropertySourceFunctions.stripSectionKeys(key, sectionKeys);
- }
- }, "stripped");
- }
- return filtered;
- }
- };
- }
-
- /**
- * Creates a ConfigQuery that creates a JSON formatted ouitput of all properties in the given configuration.
- *
- * @return the given query.
- */
- public static ConfigQuery<String> jsonInfo() {
- return jsonInfo(null);
- }
-
- /**
- * Creates a ConfigQuery that creates a JSON formatted ouitput of all properties in the given configuration.
- *
- * @param info the additional information attributes to be added to the output, e.g. the original request
- * parameters.
- * @return the given query.
- */
- public static ConfigQuery<String> jsonInfo(final Map<String, String> info) {
- return new ConfigQuery<String>() {
- @Override
- public String query(Configuration config) {
- Map<String, String> props = new TreeMap<>(config.getProperties());
- props.put("__timestamp", String.valueOf(System.currentTimeMillis()));
- if(info!=null) {
- for (Map.Entry<String, String> en : info.entrySet()) {
- props.put("__" + escape(en.getKey()), escape(en.getValue()));
- }
- }
- StringBuilder builder = new StringBuilder(400).append("{\n");
- for (Map.Entry<String, String> en : props.entrySet()) {
- builder.append(" \"").append(escape(en.getKey())).append("\": \"" )
- .append(escape(en.getValue())).append("\",\n");
- }
- if(builder.toString().endsWith(",\n")){
- builder.setLength(builder.length()-2);
- builder.append('\n');
- }
- builder.append("}\n");
- return builder.toString();
- }
- };
- }
-
- /**
- * Creates a ConfigQuery that creates a XML formatted ouitput of all properties in the given configuration.
- *
- * @return the given query.
- */
- public static ConfigQuery<String> xmlInfo() {
- return xmlInfo(null);
- }
-
- /**
- * Creates a ConfigQuery that creates a XML formatted ouitput of all properties in the given configuration.
- *
- * @param info the additional information attributes to be added to the output, e.g. the original request
- * parameters.
- * @return the given query.
- */
- public static ConfigQuery<String> xmlInfo(final Map<String, String> info) {
- return new ConfigQuery<String>() {
- @Override
- public String query(Configuration config) {
- Map<String, String> props = new TreeMap<>(config.getProperties());
- props.put("__timestamp", String.valueOf(System.currentTimeMillis()));
- if(info!=null) {
- for (Map.Entry<String, String> en : info.entrySet()) {
- props.put("__" + escape(en.getKey()), escape(en.getValue()));
- }
- }
- StringBuilder builder = new StringBuilder(400);
- builder.append("<configuration>\n");
- for (Map.Entry<String, String> en : props.entrySet()) {
- builder.append(" <entry key=\"" + escape(en.getKey()) + "\">" + escape(en.getValue()) + "</entry>\n");
- }
- builder.append("</configuration>\n");
- return builder.toString();
- }
- };
- }
-
- /**
- * Creates a ConfigQuery that creates a plain text formatted output of all properties in the given configuration.
- *
- * @return the given query.
- */
- public static ConfigQuery<String> textInfo() {
- return textInfo(null);
- }
-
- /**
- * Creates a ConfigQuery that creates a plain text formatted output of all properties in the given configuration.
- * @param info configuration values to use for filtering.
- * @return the given query.
- */
- public static ConfigQuery<String> textInfo(final Map<String, String> info) {
- return new ConfigQuery<String>() {
- @Override
- public String query(Configuration config) {
- Map<String, String> props = new TreeMap<>(config.getProperties());
- props.put("__timestamp", String.valueOf(System.currentTimeMillis()));
- if(info!=null) {
- for (Map.Entry<String, String> en : info.entrySet()) {
- props.put("__" + escape(en.getKey()), escape(en.getValue()));
- }
- }
- StringBuilder builder = new StringBuilder(400).append("Configuration:\n");
- for (Map.Entry<String, String> en : props.entrySet()) {
- builder.append(" " + escape(en.getKey()) + ": " + escape(en.getValue()).replace("\n", "\n ") + ",\n");
- }
- if(builder.toString().endsWith(",\n")){
- builder.setLength(builder.length() - 2);
- }
- builder.append("\n");
- return builder.toString();
- }
- };
- }
-
- /**
- * Creates a ConfigOperator that adds the given items.
- * @param items the items to be added/replaced.
- * @param override if true, all items existing are overridden by the new ones passed.
- * @return the ConfigOperator, never null.
- */
- public static ConfigOperator addItems(final Map<String,Object> items, final boolean override){
- return new ConfigOperator() {
- @Override
- public Configuration operate(Configuration config) {
- return new EnrichedConfiguration(config,items, override);
- }
- };
- }
-
- /**
- * Creates an operator that adds items to the instance.
- * @param items the items, not null.
- * @return the operator, never null.
- */
- public static ConfigOperator addItems(Map<String,Object> items){
- return addItems(items, false);
- }
-
- /**
- * Creates an operator that replaces the given items.
- * @param items the items.
- * @return the operator for replacing the items.
- */
- public static ConfigOperator replaceItems(Map<String,Object> items){
- return addItems(items, true);
- }
-
- /**
- * Creates a ConfigQuery that creates a html formatted ouitput of all properties in the given configuration.
- *
- * @return the given query.
- */
- public static ConfigQuery<String> htmlInfo() {
- return htmlInfo(null);
- }
-
- /**
- * Creates a ConfigQuery that creates a html formatted ouitput of all properties in the given configuration.
- * @param info configuration values to use for filtering.
- * @return the given query.
- */
- public static ConfigQuery<String> htmlInfo(final Map<String, String> info) {
- return new ConfigQuery<String>() {
- @Override
- public String query(Configuration config) {
- StringBuilder builder = new StringBuilder();
- addHeader(builder);
- builder.append("<pre>\n").append(textInfo(info).query(config)).append("</pre>\n");
- addFooter(builder);
- return builder.toString();
- }
- };
- }
-
- private static void addFooter(StringBuilder b) {
- b.append("</body>\n</html>\n");
- }
-
- private static void addHeader(StringBuilder b) {
- String host = "unknown";
- try {
- host = Inet4Address.getLocalHost().getHostName();
- } catch (Exception e) {
- LOG.log(Level.INFO, "Failed to lookup hostname.", e);
- }
- b.append("<html>\n<head><title>System Configuration</title></head>\n" +
- "<body>\n" +
- "<h1>System Configuration</h1>\n" +
- "<p>This view shows the system configuration of " + host + " at " + new Date() + ".</p>");
-
- }
-
- /**
- * Replaces new lines, returns, tabs and '"' with escaped variants.
- *
- * @param text the input text, not null
- * @return the escaped text.
- */
- private static String escape(String text) {
- return text.replace("\t", "\\t").replace("\"", "\\\"");
- }
-
- /**
- * Accesses an empty {@link Configuration}.
- * @return an empty {@link Configuration}, never null.
- */
- public static Configuration emptyConfiguration(){
- return EMPTY_CONFIGURATION;
- }
-
- /**
- * Accesses an empty {@link ConfigurationContext}.
- * @return an empty {@link ConfigurationContext}, never null.
- */
- public static ConfigurationContext emptyConfigurationContext(){
- return EMPTY_CONFIGURATION_CONTEXT;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/functions/src/main/java/org/apache/tamaya/functions/EnrichedConfiguration.java
----------------------------------------------------------------------
diff --git a/modules/functions/src/main/java/org/apache/tamaya/functions/EnrichedConfiguration.java b/modules/functions/src/main/java/org/apache/tamaya/functions/EnrichedConfiguration.java
deleted file mode 100644
index 7969563..0000000
--- a/modules/functions/src/main/java/org/apache/tamaya/functions/EnrichedConfiguration.java
+++ /dev/null
@@ -1,159 +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.functions;
-
-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.ConfigurationContext;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Objects;
-
-/**
- * Configuration, that has values added or overridden.
- */
-class EnrichedConfiguration implements Configuration {
-
- private final Configuration baseConfiguration;
-
- private final Map<String, Object> addedProperties = new HashMap<>();
-
- private final boolean overriding;
-
- /**
- * Constructor.
- *
- * @param configuration the base config, not null.
- * @param properties the properties to be added, not null.
- * @param overriding true, if existing keys should be overriden, or config should be extended only.
- */
- EnrichedConfiguration(Configuration configuration, Map<String, Object> properties, boolean overriding) {
- this.baseConfiguration = Objects.requireNonNull(configuration);
- this.addedProperties.putAll(addedProperties);
- this.overriding = overriding;
- }
-
- @Override
- public String get(String key) {
- if (overriding) {
- Object val = addedProperties.get(key);
- if (val != null) {
- return val.toString();
- }
- return baseConfiguration.get(key);
- }
- String val = baseConfiguration.get(key);
- if (val != null) {
- return val;
- }
- Object val2 = addedProperties.get(key);
- if (val2 != null) {
- return val2.toString();
- }
- return null;
- }
-
- @Override
- public String getOrDefault(String key, String defaultValue) {
- String val = get(key);
- if (val == null) {
- return defaultValue;
- }
- return val;
- }
-
- @Override
- public <T> T getOrDefault(String key, Class<T> type, T defaultValue) {
- T val = get(key, type);
- if (val == null) {
- return defaultValue;
- }
- return val;
- }
-
- @Override
- public <T> T get(String key, Class<T> type) {
- return (T) get(key, TypeLiteral.of(type));
- }
-
- @Override
- public <T> T get(String key, TypeLiteral<T> type) {
- if (overriding) {
- Object val = addedProperties.get(key);
- if (val != null && type.getRawType().isAssignableFrom(val.getClass())) {
- return (T) val;
- }
- return baseConfiguration.get(key, type);
- }
- T val = baseConfiguration.get(key, type);
- if (val != null) {
- return val;
- }
- Object val2 = addedProperties.get(key);
- if (val2 != null && type.getRawType().isAssignableFrom(val2.getClass())) {
- return (T) val2;
- }
- return null;
- }
-
- @Override
- public <T> T getOrDefault(String key, TypeLiteral<T> type, T defaultValue) {
- T val = get(key, type);
- if (val == null) {
- return defaultValue;
- }
- return val;
- }
-
- @Override
- public Map<String, String> getProperties() {
- Map<String, String> allProps = new HashMap<>();
- if (overriding) {
- allProps.putAll(baseConfiguration.getProperties());
- for (Map.Entry<String, Object> en : addedProperties.entrySet()) {
- allProps.put(en.getKey(), en.getValue().toString());
- }
- } else {
- for (Map.Entry<String, Object> en : addedProperties.entrySet()) {
- allProps.put(en.getKey(), en.getValue().toString());
- }
- allProps.putAll(baseConfiguration.getProperties());
- }
- return allProps;
- }
-
- @Override
- public Configuration with(ConfigOperator operator) {
- return operator.operate(this);
- }
-
- @Override
- public <T> T query(ConfigQuery<T> query) {
- return query.query(this);
- }
-
- @Override
- public ConfigurationContext getContext() {
- return baseConfiguration.getContext();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/functions/src/main/java/org/apache/tamaya/functions/EnrichedPropertySource.java
----------------------------------------------------------------------
diff --git a/modules/functions/src/main/java/org/apache/tamaya/functions/EnrichedPropertySource.java b/modules/functions/src/main/java/org/apache/tamaya/functions/EnrichedPropertySource.java
deleted file mode 100644
index de48fa8..0000000
--- a/modules/functions/src/main/java/org/apache/tamaya/functions/EnrichedPropertySource.java
+++ /dev/null
@@ -1,97 +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.functions;
-
-import org.apache.tamaya.spi.PropertySource;
-import org.apache.tamaya.spi.PropertyValue;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Objects;
-
-/**
- * PropertySource, that has values added or overridden.
- */
-class EnrichedPropertySource implements PropertySource {
-
- private final PropertySource basePropertySource;
-
- private final Map<String, String> addedProperties;
-
- private final boolean overriding;
-
- /**
- * Constructor.
- *
- * @param propertySource the base property source, not null.
- * @param properties the properties to be added.
- * @param overriding flag if existing properties are overridden.
- */
- EnrichedPropertySource(PropertySource propertySource, Map<String, String> properties, boolean overriding) {
- this.basePropertySource = Objects.requireNonNull(propertySource);
- this.addedProperties = Objects.requireNonNull(properties);
- this.overriding = overriding;
- }
-
-
- @Override
- public int getOrdinal() {
- return basePropertySource.getOrdinal();
- }
-
- @Override
- public String getName() {
- return basePropertySource.getName();
- }
-
- @Override
- public PropertyValue get(String key) {
- if (overriding) {
- String val = addedProperties.get(key);
- if (val != null) {
- return PropertyValue.of(key, val, getName());
- }
- return basePropertySource.get(key);
- }
- PropertyValue val = basePropertySource.get(key);
- if (val != null) {
- return val;
- }
- return PropertyValue.of(key, addedProperties.get(key), getName());
-
- }
-
- @Override
- public Map<String, String> getProperties() {
- Map<String, String> allProps;
- if (overriding) {
- allProps = new HashMap<>(basePropertySource.getProperties());
- allProps.putAll(addedProperties);
- } else {
- allProps = new HashMap<>(addedProperties);
- allProps.putAll(basePropertySource.getProperties());
- }
- return allProps;
- }
-
- @Override
- public boolean isScannable() {
- return basePropertySource.isScannable();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/functions/src/main/java/org/apache/tamaya/functions/FilteredConfiguration.java
----------------------------------------------------------------------
diff --git a/modules/functions/src/main/java/org/apache/tamaya/functions/FilteredConfiguration.java b/modules/functions/src/main/java/org/apache/tamaya/functions/FilteredConfiguration.java
deleted file mode 100644
index e8acaaa..0000000
--- a/modules/functions/src/main/java/org/apache/tamaya/functions/FilteredConfiguration.java
+++ /dev/null
@@ -1,126 +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.functions;
-
-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.ConfigurationContext;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Objects;
-
-/**
- * Configuration that filters part of the entries defined by a matcher predicate.
- */
-class FilteredConfiguration implements Configuration {
-
- private final Configuration baseConfiguration;
- private final PropertyMatcher matcher;
- private final String filterType;
-
- FilteredConfiguration(Configuration baseConfiguration, PropertyMatcher matcher, String filterType) {
- this.baseConfiguration = Objects.requireNonNull(baseConfiguration);
- this.matcher = Objects.requireNonNull(matcher);
- this.filterType = filterType!=null?filterType:this.matcher.toString();
- }
-
- @Override
- public String get(String key) {
- return get(key, String.class);
- }
-
- @Override
- public String getOrDefault(String key, String defaultValue) {
- String val = get(key);
- if(val==null){
- return defaultValue;
- }
- return val;
- }
-
- @Override
- public <T> T getOrDefault(String key, Class<T> type, T defaultValue) {
- T val = get(key, type);
- if(val==null){
- return defaultValue;
- }
- return val;
- }
-
- @Override
- public <T> T get(String key, Class<T> type) {
- return (T)get(key, TypeLiteral.of(type));
- }
-
- @Override
- public <T> T get(String key, TypeLiteral<T> type) {
- String value = baseConfiguration.get(key);
- if (matcher.test(key, value)) {
- return baseConfiguration.get(key, type);
- }
- return null;
- }
-
- @Override
- public <T> T getOrDefault(String key, TypeLiteral<T> type, T defaultValue) {
- T val = get(key, type);
- if(val==null){
- return defaultValue;
- }
- return val;
- }
-
- @Override
- public Map<String, String> getProperties() {
- Map<String, String> result = new HashMap<>();
- for(Map.Entry<String,String> en:baseConfiguration.getProperties().entrySet()){
- if(matcher.test(en.getKey(), en.getValue())){
- result.put(en.getKey(), en.getValue());
- }
- }
- return result;
- }
-
- @Override
- public Configuration with(ConfigOperator operator) {
- return null;
- }
-
- @Override
- public <T> T query(ConfigQuery<T> query) {
- return query.query(this);
- }
-
- @Override
- public ConfigurationContext getContext() {
- return baseConfiguration.getContext();
- }
-
- @Override
- public String toString() {
- return "FilteredConfiguration{" +
- "baseConfiguration=" + baseConfiguration +
- ", matcher=" + filterType +
- '}';
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/functions/src/main/java/org/apache/tamaya/functions/FilteredPropertySource.java
----------------------------------------------------------------------
diff --git a/modules/functions/src/main/java/org/apache/tamaya/functions/FilteredPropertySource.java b/modules/functions/src/main/java/org/apache/tamaya/functions/FilteredPropertySource.java
deleted file mode 100644
index 7eccdee..0000000
--- a/modules/functions/src/main/java/org/apache/tamaya/functions/FilteredPropertySource.java
+++ /dev/null
@@ -1,84 +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.functions;
-
-import org.apache.tamaya.spi.PropertySource;
-import org.apache.tamaya.spi.PropertyValue;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Objects;
-
-/**
- * PropertySource that on the fly filters out part of the key/values of the underlying PropertySource.
- */
-class FilteredPropertySource implements PropertySource {
-
- private final PropertySource baseSource;
- private final Predicate<String> filter;
-
- /**
- * Creates a new instance
- * @param baseSource the underlying PropertySource
- * @param filter the filter to be applied.
- */
- public FilteredPropertySource(PropertySource baseSource, Predicate<String> filter){
- this.baseSource = Objects.requireNonNull(baseSource);
- this.filter = Objects.requireNonNull(filter);
- }
-
- @Override
- public int getOrdinal(){
- return baseSource.getOrdinal();
- }
-
- @Override
- public String getName() {
- return baseSource.getName();
- }
-
- @Override
- public PropertyValue get(String key) {
- return PropertyValue.of(key, getProperties().get(key), getName());
- }
-
- @Override
- public Map<String,String> getProperties(){
- final Map<String,String> result = new HashMap<>();
- for(Map.Entry<String,String> en: this.baseSource.getProperties().entrySet()) {
- if (filter.test(en.getKey())) {
- result.put(en.getKey(), en.getValue());
- }
- }
- return result;
- }
-
- @Override
- public boolean isScannable() {
- return baseSource.isScannable();
- }
-
- @Override
- public String toString() {
- return "FilteredPropertySource{" +
- "baseSource=" + baseSource +
- ", filter=" + filter +
- '}';
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/functions/src/main/java/org/apache/tamaya/functions/KeyMapper.java
----------------------------------------------------------------------
diff --git a/modules/functions/src/main/java/org/apache/tamaya/functions/KeyMapper.java b/modules/functions/src/main/java/org/apache/tamaya/functions/KeyMapper.java
deleted file mode 100644
index 2666c1b..0000000
--- a/modules/functions/src/main/java/org/apache/tamaya/functions/KeyMapper.java
+++ /dev/null
@@ -1,37 +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.functions;
-
-/**
- * Represents a function that maps a key of a property entry to another key (or removes it
- * if mapped to null).
- *
- */
-//@FunctionalInterface
-public interface KeyMapper {
-
- /**
- * Maps a property key to another key.
- * @param key the fproperty key, not null
- * @return the new key, returning null, removes the entry.
- */
- String mapKey(String key);
-
-}
-
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/functions/src/main/java/org/apache/tamaya/functions/MappedConfiguration.java
----------------------------------------------------------------------
diff --git a/modules/functions/src/main/java/org/apache/tamaya/functions/MappedConfiguration.java b/modules/functions/src/main/java/org/apache/tamaya/functions/MappedConfiguration.java
deleted file mode 100644
index b93b9ca..0000000
--- a/modules/functions/src/main/java/org/apache/tamaya/functions/MappedConfiguration.java
+++ /dev/null
@@ -1,132 +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.functions;
-
-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.ConfigurationContext;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Objects;
-import java.util.logging.Logger;
-
-
-/**
- * Configuration that filters part of the entries defined by a filter predicate.
- */
-class MappedConfiguration implements Configuration {
-
- private static final Logger LOG = Logger.getLogger(MappedConfiguration.class.getName());
- private final Configuration baseConfiguration;
- private final KeyMapper keyMapper;
- private final String mapType;
-
- MappedConfiguration(Configuration baseConfiguration, KeyMapper keyMapper, String mapType) {
- this.baseConfiguration = Objects.requireNonNull(baseConfiguration);
- this.keyMapper = Objects.requireNonNull(keyMapper);
- this.mapType = mapType!=null?mapType:this.keyMapper.toString();
- }
-
- @Override
- public String get(String key) {
- return get(key, String.class);
- }
-
- @Override
- public String getOrDefault(String key, String defaultValue) {
- String val = get(key);
- if(val==null){
- return defaultValue;
- }
- return val;
- }
-
- @Override
- public <T> T getOrDefault(String key, Class<T> type, T defaultValue) {
- T val = get(key, type);
- if(val==null){
- return defaultValue;
- }
- return val;
- }
-
- @Override
- public <T> T get(String key, Class<T> type) {
- return (T)get(key, TypeLiteral.of(type));
- }
-
- @Override
- public <T> T get(String key, TypeLiteral<T> type) {
- String targetKey = keyMapper.mapKey(key);
- if (targetKey != null) {
- return baseConfiguration.get(targetKey, type);
- }
- LOG.finest("Configuration property hidden by KeyMapper, key="+key+", mapper="+keyMapper+", config="+this);
- return null;
- }
-
- @Override
- public <T> T getOrDefault(String key, TypeLiteral<T> type, T defaultValue) {
- T val = get(key, type);
- if(val==null){
- return defaultValue;
- }
- return val;
- }
-
- @Override
- public Map<String, String> getProperties() {
- Map<String, String> baseProps = baseConfiguration.getProperties();
- Map<String, String> props = new HashMap<>(baseProps.size());
- for(Map.Entry<String,String> en:baseProps.entrySet()){
- String targetKey = keyMapper.mapKey(en.getKey());
- if (targetKey != null) {
- props.put(targetKey, en.getValue());
- }
- }
- return props;
- }
-
- @Override
- public Configuration with(ConfigOperator operator) {
- return operator.operate(this);
- }
-
- @Override
- public <T> T query(ConfigQuery<T> query) {
- return query.query(this);
- }
-
- @Override
- public ConfigurationContext getContext() {
- return baseConfiguration.getContext();
- }
-
- @Override
- public String toString() {
- return "FilteredConfiguration{" +
- "baseConfiguration=" + baseConfiguration +
- ", mapping=" + mapType +
- '}';
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/functions/src/main/java/org/apache/tamaya/functions/MappedPropertySource.java
----------------------------------------------------------------------
diff --git a/modules/functions/src/main/java/org/apache/tamaya/functions/MappedPropertySource.java b/modules/functions/src/main/java/org/apache/tamaya/functions/MappedPropertySource.java
deleted file mode 100644
index 3f85f53..0000000
--- a/modules/functions/src/main/java/org/apache/tamaya/functions/MappedPropertySource.java
+++ /dev/null
@@ -1,88 +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.functions;
-
-import org.apache.tamaya.spi.PropertySource;
-import org.apache.tamaya.spi.PropertyValue;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Objects;
-
-/**
- * PropertySource implementation that maps certain parts (defined by an {@code UnaryOperator<String>}) to alternate sections.
- */
-class MappedPropertySource implements PropertySource {
-
- private static final long serialVersionUID = 8690637705511432083L;
-
- /**
- * The mapping operator.
- */
- private final KeyMapper keyMapper;
- /**
- * The base configuration.
- */
- private final PropertySource propertySource;
-
- /**
- * Creates a new instance.
- *
- * @param config the base configuration, not null
- * @param keyMapper The mapping operator, not null
- */
- public MappedPropertySource(PropertySource config, KeyMapper keyMapper) {
- this.propertySource = Objects.requireNonNull(config);
- this.keyMapper = Objects.requireNonNull(keyMapper);
- }
-
- @Override
- public int getOrdinal() {
- return this.propertySource.getOrdinal();
- }
-
- @Override
- public String getName() {
- return this.propertySource.getName() + "[mapped]";
- }
-
- @Override
- public Map<String, String> getProperties() {
- Map<String, String> result = new HashMap<>();
- Map<String, String> map = this.propertySource.getProperties();
- for (Map.Entry<String, String> en : map.entrySet()) {
- String targetKey = keyMapper.mapKey(en.getKey());
- if (targetKey != null) {
- result.put(targetKey, en.getValue());
- }
- }
- return result;
- }
-
- @Override
- public boolean isScannable() {
- return propertySource.isScannable();
- }
-
- @Override
- public PropertyValue get(String key) {
- return PropertyValue.of(key, getProperties().get(key), getName());
- }
-
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/functions/src/main/java/org/apache/tamaya/functions/Predicate.java
----------------------------------------------------------------------
diff --git a/modules/functions/src/main/java/org/apache/tamaya/functions/Predicate.java b/modules/functions/src/main/java/org/apache/tamaya/functions/Predicate.java
deleted file mode 100644
index 3061746..0000000
--- a/modules/functions/src/main/java/org/apache/tamaya/functions/Predicate.java
+++ /dev/null
@@ -1,42 +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.functions;
-
-/**
- * Represents a predicate (boolean-valued function) of one argument.
- *
- * <p>This is a <a href="package-summary.html">functional interface</a>
- * whose functional method is {@link #test(Object)}.
- *
- * @param <T> the type of the input to the predicate
- */
-//@FunctionalInterface
-public interface Predicate<T> {
-
- /**
- * Evaluates this predicate on the given argument.
- *
- * @param t the input argument
- * @return {@code true} if the input argument matches the predicate,
- * otherwise {@code false}
- */
- boolean test(T t);
-
-}
-
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/functions/src/main/java/org/apache/tamaya/functions/PropertyMapper.java
----------------------------------------------------------------------
diff --git a/modules/functions/src/main/java/org/apache/tamaya/functions/PropertyMapper.java b/modules/functions/src/main/java/org/apache/tamaya/functions/PropertyMapper.java
deleted file mode 100644
index dc5bd30..0000000
--- a/modules/functions/src/main/java/org/apache/tamaya/functions/PropertyMapper.java
+++ /dev/null
@@ -1,36 +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.functions;
-
-/**
- * This is a simple functional interface, used for mapping properties.
- * It can be used as functional interface in Java 8.
- */
-//@FunctionalInterface
-public interface PropertyMapper {
-
- /**
- * Maps the given key/value to another value.
- * @param key the key, not null.
- * @param value the value, not null.
- * @return the new value, not null.
- */
- String mapProperty(String key, String value);
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/359d3e4a/modules/functions/src/main/java/org/apache/tamaya/functions/PropertyMatcher.java
----------------------------------------------------------------------
diff --git a/modules/functions/src/main/java/org/apache/tamaya/functions/PropertyMatcher.java b/modules/functions/src/main/java/org/apache/tamaya/functions/PropertyMatcher.java
deleted file mode 100644
index 45d44ee..0000000
--- a/modules/functions/src/main/java/org/apache/tamaya/functions/PropertyMatcher.java
+++ /dev/null
@@ -1,38 +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.functions;
-
-/**
- * Represents a selector predicate for selecting configuration properties.
- * This can be used as a functional interface in Java 8.
- */
-//@FunctionalInterface
-public interface PropertyMatcher {
-
- /**
- * Evaluates this predicate on the given arguments.
- *
- * @param key the key, not null
- * @param value the value, not null
- * @return {@code true} if the entry should match the predicate
- */
- boolean test(String key, String value);
-
-}
-