Repository: incubator-tamaya-extensions
Updated Branches:
  refs/heads/configjsr d28a3f570 -> 4da423e70


Renamed Context to FilterChain.

Signed-off-by: Anatole Tresch <[email protected]>


Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/commit/4da423e7
Tree: 
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/tree/4da423e7
Diff: 
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/diff/4da423e7

Branch: refs/heads/configjsr
Commit: 4da423e700076926a2dc8b7ed5ff11f5e200d268
Parents: d28a3f5
Author: Anatole Tresch <[email protected]>
Authored: Mon Feb 5 19:53:30 2018 +0100
Committer: Anatole Tresch <[email protected]>
Committed: Mon Feb 5 19:53:30 2018 +0100

----------------------------------------------------------------------
 .../java/org/apache/tamaya/filter/Context.java  | 122 -------------------
 .../org/apache/tamaya/filter/FilterChain.java   | 122 +++++++++++++++++++
 .../filter/ProgrammableFilterTest.java          |  16 +--
 3 files changed, 130 insertions(+), 130 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/4da423e7/modules/filter/src/main/java/org/apache/tamaya/filter/Context.java
----------------------------------------------------------------------
diff --git a/modules/filter/src/main/java/org/apache/tamaya/filter/Context.java 
b/modules/filter/src/main/java/org/apache/tamaya/filter/Context.java
deleted file mode 100644
index 702f7f3..0000000
--- a/modules/filter/src/main/java/org/apache/tamaya/filter/Context.java
+++ /dev/null
@@ -1,122 +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.filter;
-
-import org.apache.tamaya.base.filter.Filter;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
-
-/**
- * A set of property filter and accessor methods. This class is built for
- * usage within a single threaded context, so it is NOT thread-safe.
- */
-public final class Context implements Filter{
-    /** The filters. */
-    private List<Filter> filters = new ArrayList<>();
-
-    /**
-     * Add a filter.
-     * @param filter the filter.
-     */
-    public void addFilter(Filter filter){
-        if(!filters.contains(filter)) {
-            filters.add(filter);
-        }
-    }
-
-    /**
-     * Adds a filter at given position.
-     * @param pos the position.
-     * @param filter the filter.
-     */
-    public void addFilter(int pos, Filter filter){
-        if(!filters.contains(filter)) {
-            filters.add(pos, filter);
-        }
-    }
-
-    /**
-     * Removes a filter at a given position.
-     * @param pos the position.
-     * @return the filter removed, or null.
-     */
-    public Filter removeFilter(int pos){
-        return filters.remove(pos);
-    }
-
-    /**
-     * Removes a filter.
-     * @param filter the filter to be removed, not null.
-     */
-    public void removeFilter(Filter filter) {
-        filters.remove(filter);
-    }
-
-    /**
-     * Clears all filters.
-     */
-    public void clearFilters(){
-        filters.clear();
-    }
-
-    /**
-     * Set the filters.
-     * @param filters the filters to be applied.
-     */
-    public void setFilters(Filter... filters){
-        setFilters(Arrays.asList(filters));
-    }
-
-    /**
-     * Set the filters.
-     * @param filters the filters to be applied.
-     */
-    public void setFilters(Collection<Filter> filters) {
-        this.filters.clear();
-        this.filters.addAll(filters);
-    }
-
-    /**
-     * Get all filters.
-     * @return all filters.
-     */
-    public List<Filter> getFilters(){
-        return Collections.unmodifiableList(filters);
-    }
-
-    @Override
-    public String filterProperty(String key, String valueToBeFiltered) {
-        for(Filter filter: filters){
-            valueToBeFiltered = filter.filterProperty(key, valueToBeFiltered);
-        }
-        return valueToBeFiltered;
-    }
-
-    @Override
-    public String toString() {
-        return "ProgrammableFilter{" +
-                "filters=" + filters +
-                '}';
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/4da423e7/modules/filter/src/main/java/org/apache/tamaya/filter/FilterChain.java
----------------------------------------------------------------------
diff --git 
a/modules/filter/src/main/java/org/apache/tamaya/filter/FilterChain.java 
b/modules/filter/src/main/java/org/apache/tamaya/filter/FilterChain.java
new file mode 100644
index 0000000..68fb587
--- /dev/null
+++ b/modules/filter/src/main/java/org/apache/tamaya/filter/FilterChain.java
@@ -0,0 +1,122 @@
+/*
+ * 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.filter;
+
+import org.apache.tamaya.base.filter.Filter;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+
+/**
+ * A set of property filter and accessor methods. This class is built for
+ * usage within a single threaded context, so it is NOT thread-safe.
+ */
+public final class FilterChain implements Filter{
+    /** The filters. */
+    private List<Filter> filters = new ArrayList<>();
+
+    /**
+     * Add a filter.
+     * @param filter the filter.
+     */
+    public void addFilter(Filter filter){
+        if(!filters.contains(filter)) {
+            filters.add(filter);
+        }
+    }
+
+    /**
+     * Adds a filter at given position.
+     * @param pos the position.
+     * @param filter the filter.
+     */
+    public void addFilter(int pos, Filter filter){
+        if(!filters.contains(filter)) {
+            filters.add(pos, filter);
+        }
+    }
+
+    /**
+     * Removes a filter at a given position.
+     * @param pos the position.
+     * @return the filter removed, or null.
+     */
+    public Filter removeFilter(int pos){
+        return filters.remove(pos);
+    }
+
+    /**
+     * Removes a filter.
+     * @param filter the filter to be removed, not null.
+     */
+    public void removeFilter(Filter filter) {
+        filters.remove(filter);
+    }
+
+    /**
+     * Clears all filters.
+     */
+    public void clearFilters(){
+        filters.clear();
+    }
+
+    /**
+     * Set the filters.
+     * @param filters the filters to be applied.
+     */
+    public void setFilters(Filter... filters){
+        setFilters(Arrays.asList(filters));
+    }
+
+    /**
+     * Set the filters.
+     * @param filters the filters to be applied.
+     */
+    public void setFilters(Collection<Filter> filters) {
+        this.filters.clear();
+        this.filters.addAll(filters);
+    }
+
+    /**
+     * Get all filters.
+     * @return all filters.
+     */
+    public List<Filter> getFilters(){
+        return Collections.unmodifiableList(filters);
+    }
+
+    @Override
+    public String filterProperty(String key, String valueToBeFiltered) {
+        for(Filter filter: filters){
+            valueToBeFiltered = filter.filterProperty(key, valueToBeFiltered);
+        }
+        return valueToBeFiltered;
+    }
+
+    @Override
+    public String toString() {
+        return "ProgrammableFilter{" +
+                "filters=" + filters +
+                '}';
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/4da423e7/modules/filter/src/test/java/org/apache/tamaya/spisupport/filter/ProgrammableFilterTest.java
----------------------------------------------------------------------
diff --git 
a/modules/filter/src/test/java/org/apache/tamaya/spisupport/filter/ProgrammableFilterTest.java
 
b/modules/filter/src/test/java/org/apache/tamaya/spisupport/filter/ProgrammableFilterTest.java
index 2aa6fbe..8d525ca 100644
--- 
a/modules/filter/src/test/java/org/apache/tamaya/spisupport/filter/ProgrammableFilterTest.java
+++ 
b/modules/filter/src/test/java/org/apache/tamaya/spisupport/filter/ProgrammableFilterTest.java
@@ -20,7 +20,7 @@ package org.apache.tamaya.spisupport.filter;
 
 import org.apache.tamaya.base.filter.FilterContext;
 import org.apache.tamaya.base.filter.RegexPropertyFilter;
-import org.apache.tamaya.filter.Context;
+import org.apache.tamaya.filter.FilterChain;
 import org.apache.tamaya.base.filter.Filter;
 import org.junit.Test;
 
@@ -33,7 +33,7 @@ import java.util.Map;
 import static org.junit.Assert.*;
 
 /**
- * Tests for {@link Context}. Created by atsticks on 11.02.16.
+ * Tests for {@link FilterChain}. Created by atsticks on 11.02.16.
  */
 public class ProgrammableFilterTest {
 
@@ -44,7 +44,7 @@ public class ProgrammableFilterTest {
 
     @Test
     public void testAddRemoveFilter() throws Exception {
-        Context filter = new Context();
+        FilterChain filter = new FilterChain();
         Map<String,String> map = new HashMap<>();
         FilterContext.setContext(new FilterContext(map, config));
         assertEquals(filter.filterProperty(test1Property,test1Property), 
test1Property);
@@ -79,7 +79,7 @@ public class ProgrammableFilterTest {
 
     @Test
     public void testClearFilters() throws Exception {
-        Context filter = new Context();
+        FilterChain filter = new FilterChain();
         RegexPropertyFilter regexFilter = new RegexPropertyFilter();
         regexFilter.setIncludes("test1.*");
         Map<String,String> map = new HashMap<>();
@@ -110,7 +110,7 @@ public class ProgrammableFilterTest {
 
     @Test
     public void testSetFilters() throws Exception {
-        Context filter = new Context();
+        FilterChain filter = new FilterChain();
         RegexPropertyFilter regexFilter = new RegexPropertyFilter();
         regexFilter.setIncludes("test\\..*");
         Map<String,String> map = new HashMap<>();
@@ -134,7 +134,7 @@ public class ProgrammableFilterTest {
 
     @Test
     public void testSetFilters1() throws Exception {
-        Context filter = new Context();
+        FilterChain filter = new FilterChain();
         RegexPropertyFilter regexFilter = new RegexPropertyFilter();
         regexFilter.setIncludes("test1.*");
         Map<String,String> map = new HashMap<>();
@@ -155,7 +155,7 @@ public class ProgrammableFilterTest {
 
     @Test
     public void testGetFilters() throws Exception {
-        Context filter = new Context();
+        FilterChain filter = new FilterChain();
         assertNotNull(filter.getFilters());
         assertTrue(filter.getFilters().isEmpty());
         RegexPropertyFilter regexFilter = new RegexPropertyFilter();
@@ -169,7 +169,7 @@ public class ProgrammableFilterTest {
 
     @Test
     public void testToString() throws Exception {
-        Context filter = new Context();
+        FilterChain filter = new FilterChain();
         assertFalse(filter.toString().contains("test\\..*"));
         assertTrue(filter.toString().contains("ProgrammableFilter"));
         assertFalse(filter.toString().contains("RegexPropertyFilter"));

Reply via email to