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 2016/02/27 22:40:34 UTC
[1/6] incubator-tamaya git commit: Moved collections module into
active modules folder.
Repository: incubator-tamaya
Updated Branches:
refs/heads/master 6d9abdeb9 -> ebb7d90b0
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/314ad28d/sandbox/collections/src/test/java/org/apache/tamaya/collections/CollectionsTypedReadOnlyTests.java
----------------------------------------------------------------------
diff --git a/sandbox/collections/src/test/java/org/apache/tamaya/collections/CollectionsTypedReadOnlyTests.java b/sandbox/collections/src/test/java/org/apache/tamaya/collections/CollectionsTypedReadOnlyTests.java
deleted file mode 100644
index 7882512..0000000
--- a/sandbox/collections/src/test/java/org/apache/tamaya/collections/CollectionsTypedReadOnlyTests.java
+++ /dev/null
@@ -1,173 +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.collections;
-
-import org.apache.tamaya.Configuration;
-import org.apache.tamaya.ConfigurationProvider;
-import org.apache.tamaya.TypeLiteral;
-import org.junit.Test;
-
-import java.util.*;
-
-import static junit.framework.TestCase.assertEquals;
-import static org.junit.Assert.*;
-
-/**
- * Basic tests for Tamaya collection support. Relevant configs for this tests:
- * <pre>base.items=1,2,3,4,5,6,7,8,9,0
- * base.map=1::a, 2::b, 3::c, [4:: ]
- * </pre>
- */
-public class CollectionsTypedReadOnlyTests {
-
- @Test(expected=UnsupportedOperationException.class)
- public void testArrayListList_1(){
- Configuration config = ConfigurationProvider.getConfiguration();
- List<String> items = config.get("typed.arraylist", new TypeLiteral<List<String>>(){});
- assertNotNull(items);
- assertFalse(items.isEmpty());
- assertEquals(10, items.size());
- items.add("test");
- }
-
- @Test(expected=UnsupportedOperationException.class)
- public void testArrayListList_2(){
- Configuration config = ConfigurationProvider.getConfiguration();
- List<String> items = (List<String>) config.get("typed.arraylist", List.class);
- assertNotNull(items);
- assertFalse(items.isEmpty());
- assertEquals(10, items.size());
- items.add("test");
- }
-
- @Test(expected=UnsupportedOperationException.class)
- public void testLinkedListList_1(){
- Configuration config = ConfigurationProvider.getConfiguration();
- List<String> items = config.get("typed.linkedlist", new TypeLiteral<List<String>>(){});
- assertNotNull(items);
- assertFalse(items.isEmpty());
- assertEquals(10, items.size());
- items.add("test");
- }
-
- @Test(expected=UnsupportedOperationException.class)
- public void testLinkedListList_2(){
- Configuration config = ConfigurationProvider.getConfiguration();
- List<String> items = (List<String>) config.get("typed.linkedlist", List.class);
- assertNotNull(items);
- assertFalse(items.isEmpty());
- assertEquals(10, items.size());
- items.add("test");
- }
-
-
- @Test(expected=UnsupportedOperationException.class)
- public void testHashSet_1(){
- Configuration config = ConfigurationProvider.getConfiguration();
- Set<String> items = config.get("typed.hashset", new TypeLiteral<Set<String>>(){});
- assertNotNull(items);
- assertFalse(items.isEmpty());
- assertEquals(10, items.size());
- items.add("test");
- }
- @Test(expected=UnsupportedOperationException.class)
- public void testHashSet_2(){
- Configuration config = ConfigurationProvider.getConfiguration();
- Set<String> items = (Set<String>) config.get("typed.hashset", Set.class);
- assertNotNull(items);
- assertFalse(items.isEmpty());
- assertEquals(10, items.size());
- items.add("test");
- }
-
- @Test(expected=UnsupportedOperationException.class)
- public void testTreeSet_1(){
- Configuration config = ConfigurationProvider.getConfiguration();
- Set<String> items = config.get("typed.treeset", new TypeLiteral<Set<String>>(){});
- assertNotNull(items);
- assertFalse(items.isEmpty());
- assertEquals(10, items.size());
- items.add("test");
- }
- @Test(expected=UnsupportedOperationException.class)
- public void testTreeSet_2(){
- Configuration config = ConfigurationProvider.getConfiguration();
- Set<String> items = items = (Set<String>) config.get("typed.treeset", Set.class);
- assertNotNull(items);
- assertFalse(items.isEmpty());
- assertEquals(10, items.size());
- items.add("test");
- }
-
- @Test(expected=UnsupportedOperationException.class)
- public void testHashMap_1(){
- Configuration config = ConfigurationProvider.getConfiguration();
- Map<String,String> items = config.get("typed.hashmap", new TypeLiteral<Map<String,String>>(){});
- assertNotNull(items);
- assertFalse(items.isEmpty());
- assertEquals(4, items.size());
- assertEquals("a", items.get("1"));
- assertEquals("b", items.get("2"));
- assertEquals("c", items.get("3"));
- assertEquals(" ", items.get("4"));
- items.put("g","hjhhj");
- }
- @Test(expected=UnsupportedOperationException.class)
- public void testHashMap_2(){
- Configuration config = ConfigurationProvider.getConfiguration();
- Map<String,String> items = (Map<String,String>) config.get("typed.hashmap", Map.class);
- assertNotNull(items);
- assertFalse(items.isEmpty());
- assertEquals(4, items.size());
- assertEquals("a", items.get("1"));
- assertEquals("b", items.get("2"));
- assertEquals("c", items.get("3"));
- assertEquals(" ", items.get("4"));
- items.put("g","hjhhj");
- }
-
-
- @Test(expected=UnsupportedOperationException.class)
- public void testTreeMap_1(){
- Configuration config = ConfigurationProvider.getConfiguration();
- Map<String,String> items = config.get("typed.treemap", new TypeLiteral<Map<String,String>>(){});
- assertNotNull(items);
- assertFalse(items.isEmpty());
- assertEquals(4, items.size());
- assertEquals("a", items.get("1"));
- assertEquals("b", items.get("2"));
- assertEquals("c", items.get("3"));
- assertEquals(" ", items.get("4"));
- items.put("g","hjhhj");
- }
- @Test(expected=UnsupportedOperationException.class)
- public void testTreeMap_2(){
- Configuration config = ConfigurationProvider.getConfiguration();
- Map<String,String> items = (Map<String,String>) config.get("typed.treemap", Map.class);
- assertNotNull(items);
- assertFalse(items.isEmpty());
- assertEquals(4, items.size());
- assertEquals("a", items.get("1"));
- assertEquals("b", items.get("2"));
- assertEquals("c", items.get("3"));
- assertEquals(" ", items.get("4"));
- items.put("g","hjhhj");
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/314ad28d/sandbox/collections/src/test/java/org/apache/tamaya/collections/CollectionsTypedTests.java
----------------------------------------------------------------------
diff --git a/sandbox/collections/src/test/java/org/apache/tamaya/collections/CollectionsTypedTests.java b/sandbox/collections/src/test/java/org/apache/tamaya/collections/CollectionsTypedTests.java
deleted file mode 100644
index b4e4d52..0000000
--- a/sandbox/collections/src/test/java/org/apache/tamaya/collections/CollectionsTypedTests.java
+++ /dev/null
@@ -1,208 +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.collections;
-
-import org.apache.tamaya.Configuration;
-import org.apache.tamaya.ConfigurationProvider;
-import org.apache.tamaya.TypeLiteral;
-import org.junit.Test;
-
-import java.util.*;
-
-import static junit.framework.TestCase.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
-/**
- * Basic tests for Tamaya collection support. Relevant configs for this tests:
- * <pre>base.items=1,2,3,4,5,6,7,8,9,0
- * base.map=1::a, 2::b, 3::c, [4:: ]
- * </pre>
- */
-public class CollectionsTypedTests {
-
- @Test
- public void testArrayListList_String(){
- Configuration config = ConfigurationProvider.getConfiguration();
- List<String> items = config.get("typed2.arraylist", new TypeLiteral<List<String>>(){});
- assertNotNull(items);
- assertFalse(items.isEmpty());
- assertEquals(10, items.size());
- assertTrue(items instanceof ArrayList);
- items = (List<String>) config.get("typed2.arraylist", List.class);
- assertNotNull(items);
- assertFalse(items.isEmpty());
- assertEquals(10, items.size());
- assertTrue(items instanceof ArrayList);
- }
-
- @Test
- public void testLinkedListList_String(){
- Configuration config = ConfigurationProvider.getConfiguration();
- List<String> items = config.get("typed2.linkedlist", new TypeLiteral<List<String>>(){});
- assertNotNull(items);
- assertFalse(items.isEmpty());
- assertEquals(10, items.size());
- assertTrue(items instanceof LinkedList);
- items = (List<String>) config.get("typed2.linkedlist", List.class);
- assertNotNull(items);
- assertFalse(items.isEmpty());
- assertEquals(10, items.size());
- assertTrue(items instanceof LinkedList);
- }
-
-
- @Test
- public void testHashSet_String(){
- Configuration config = ConfigurationProvider.getConfiguration();
- Set<String> items = config.get("typed2.hashset", new TypeLiteral<Set<String>>(){});
- assertNotNull(items);
- assertFalse(items.isEmpty());
- assertEquals(10, items.size());
- assertTrue(items instanceof HashSet);
- items = (Set<String>) config.get("typed2.hashset", Set.class);
- assertNotNull(items);
- assertFalse(items.isEmpty());
- assertEquals(10, items.size());
- assertTrue(items instanceof HashSet);
- }
-
- @Test
- public void testTreeSet_String(){
- Configuration config = ConfigurationProvider.getConfiguration();
- Set<String> items = config.get("typed2.treeset", new TypeLiteral<Set<String>>(){});
- assertNotNull(items);
- assertFalse(items.isEmpty());
- assertEquals(10, items.size());
- assertTrue(items instanceof TreeSet);
- items = (Set<String>) config.get("typed2.treeset", Set.class);
- assertNotNull(items);
- assertFalse(items.isEmpty());
- assertEquals(10, items.size());
- assertTrue(items instanceof TreeSet);
- }
-
- @Test
- public void testHashMap_String(){
- Configuration config = ConfigurationProvider.getConfiguration();
- Map<String,String> items = config.get("typed2.hashmap", new TypeLiteral<Map<String,String>>(){});
- assertNotNull(items);
- assertFalse(items.isEmpty());
- assertEquals(4, items.size());
- assertEquals("a", items.get("1"));
- assertEquals("b", items.get("2"));
- assertEquals("c", items.get("3"));
- assertEquals(" ", items.get("4"));
- assertTrue(items instanceof HashMap);
- items = (Map<String,String>) config.get("typed2.hashmap", Map.class);
- assertNotNull(items);
- assertFalse(items.isEmpty());
- assertEquals(4, items.size());
- assertEquals("a", items.get("1"));
- assertEquals("b", items.get("2"));
- assertEquals("c", items.get("3"));
- assertEquals(" ", items.get("4"));
- assertTrue(items instanceof HashMap);
- }
-
- @Test
- public void testTreeMap_String(){
- Configuration config = ConfigurationProvider.getConfiguration();
- Map<String,String> items = config.get("typed2.treemap", new TypeLiteral<Map<String,String>>(){});
- assertNotNull(items);
- assertFalse(items.isEmpty());
- assertEquals(4, items.size());
- assertEquals("a", items.get("1"));
- assertEquals("b", items.get("2"));
- assertEquals("c", items.get("3"));
- assertEquals(" ", items.get("4"));
- assertTrue(items instanceof TreeMap);
- items = (Map<String,String>) config.get("typed2.treemap", Map.class);
- assertNotNull(items);
- assertFalse(items.isEmpty());
- assertEquals(4, items.size());
- assertEquals("a", items.get("1"));
- assertEquals("b", items.get("2"));
- assertEquals("c", items.get("3"));
- assertEquals(" ", items.get("4"));
- assertTrue(items instanceof TreeMap);
- }
-
- @Test
- public void testCollection_HashSet(){
- Configuration config = ConfigurationProvider.getConfiguration();
- Collection<String> items = config.get("typed2.hashset", new TypeLiteral<Collection<String>>(){});
- assertNotNull(items);
- assertFalse(items.isEmpty());
- assertEquals(10, items.size());
- assertTrue(items instanceof HashSet);
- items = (Collection<String>) config.get("typed2.hashset", Collection.class);
- assertNotNull(items);
- assertFalse(items.isEmpty());
- assertEquals(10, items.size());
- assertTrue(items instanceof HashSet);
- }
-
- @Test
- public void testCollection_TreeSet(){
- Configuration config = ConfigurationProvider.getConfiguration();
- Collection<String> items = config.get("typed2.treeset", new TypeLiteral<Collection<String>>(){});
- assertNotNull(items);
- assertFalse(items.isEmpty());
- assertEquals(10, items.size());
- assertTrue(items instanceof TreeSet);
- items = (Collection<String>) config.get("typed2.treeset", Collection.class);
- assertNotNull(items);
- assertFalse(items.isEmpty());
- assertEquals(10, items.size());
- assertTrue(items instanceof TreeSet);
- }
-
- @Test
- public void testCollection_ArrayList(){
- Configuration config = ConfigurationProvider.getConfiguration();
- Collection<String> items = config.get("typed2.arraylist", new TypeLiteral<Collection<String>>(){});
- assertNotNull(items);
- assertFalse(items.isEmpty());
- assertEquals(10, items.size());
- assertTrue(items instanceof ArrayList);
- items = (Collection<String>) config.get("typed2.arraylist", Collection.class);
- assertNotNull(items);
- assertFalse(items.isEmpty());
- assertEquals(10, items.size());
- assertTrue(items instanceof ArrayList);
- }
-
- @Test
- public void testCollection_LinkedList(){
- Configuration config = ConfigurationProvider.getConfiguration();
- Collection<String> items = config.get("typed2.linkedlist", new TypeLiteral<Collection<String>>(){});
- assertNotNull(items);
- assertFalse(items.isEmpty());
- assertEquals(10, items.size());
- assertTrue(items instanceof LinkedList);
- items = (Collection<String>) config.get("typed2.linkedlist", Collection.class);
- assertNotNull(items);
- assertFalse(items.isEmpty());
- assertEquals(10, items.size());
- assertTrue(items instanceof LinkedList);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/314ad28d/sandbox/collections/src/test/java/org/apache/tamaya/collections/MyUpperCaseConverter.java
----------------------------------------------------------------------
diff --git a/sandbox/collections/src/test/java/org/apache/tamaya/collections/MyUpperCaseConverter.java b/sandbox/collections/src/test/java/org/apache/tamaya/collections/MyUpperCaseConverter.java
deleted file mode 100644
index 1c95261..0000000
--- a/sandbox/collections/src/test/java/org/apache/tamaya/collections/MyUpperCaseConverter.java
+++ /dev/null
@@ -1,33 +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.collections;
-
-import org.apache.tamaya.spi.ConversionContext;
-import org.apache.tamaya.spi.PropertyConverter;
-
-/**
- * Example converter that is used for testing the custom parsing functionality. It sorrounds values with () and
- * converts them to uppercase.
- */
-public class MyUpperCaseConverter implements PropertyConverter<String>{
- @Override
- public String convert(String value, ConversionContext context) {
- return "("+value.toUpperCase()+")";
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/314ad28d/sandbox/collections/src/test/resources/META-INF/javaconfiguration.properties
----------------------------------------------------------------------
diff --git a/sandbox/collections/src/test/resources/META-INF/javaconfiguration.properties b/sandbox/collections/src/test/resources/META-INF/javaconfiguration.properties
deleted file mode 100644
index e9a234c..0000000
--- a/sandbox/collections/src/test/resources/META-INF/javaconfiguration.properties
+++ /dev/null
@@ -1,73 +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.
-#
-# Similar to etcd all keys starting with a _ are hidden by default (only directly accessible).
-
-# Config for base tests (no combination policy)
-base.items=1,2,3,4,5,6,7,8,9,0
-base.map=1::a, 2::b, 3::c, [4:: ]
-
-# Config for tests with explcit implementation types
-typed2.arraylist=1,2,3,4,5,6,7,8,9,0
-_typed2.arraylist.collection-type=ArrayList
-_typed2.arraylist.read-only=false
-typed2.linkedlist=1,2,3,4,5,6,7,8,9,0
-_typed2.linkedlist.collection-type=java.util.LinkedList
-_typed2.linkedlist.read-only=false
-typed2.hashset=1,2,3,4,5,6,7,8,9,0
-_typed2.hashset.collection-type=HashSet
-_typed2.hashset.read-only=false
-typed2.treeset=1,2,3,4,5,6,7,8,9,0
-_typed2.treeset.collection-type=TreeSet
-_typed2.treeset.read-only=false
-typed2.hashmap=1::a, 2::b, 3::c, [4:: ]
-_typed2.hashmap.collection-type=java.util.HashMap
-_typed2.hashmap.read-only=false
-typed2.treemap=1::a, 2::b, 3::c, [4:: ]
-_typed2.treemap.collection-type=TreeMap
-_typed2.treemap.read-only=false
-
-# Config for tests with combination policy, writable
-typed.arraylist=1,2,3,4,5,6,7,8,9,0
-_typed.arraylist.collection-type=ArrayList
-typed.linkedlist=1,2,3,4,5,6,7,8,9,0
-_typed.linkedlist.collection-type=java.util.LinkedList
-typed.hashset=1,2,3,4,5,6,7,8,9,0
-_typed.hashset.collection-type=HashSet
-typed.treeset=1,2,3,4,5,6,7,8,9,0
-_typed.treeset.collection-type=TreeSet
-typed.hashmap=1::a, 2::b, 3::c, [4:: ]
-_typed.hashmap.collection-type=java.util.HashMap
-typed.treemap=1::a, 2::b, 3::c, [4:: ]
-_typed.treemap.collection-type=TreeMap
-
-# Config for advanced tests
-sep-list=a,b,c|d,e,f|g,h,i
-_sep-list.collection-type=List
-_sep-list.item-separator=|
-currency-list=CHF,USD,USS
-_currency-list.collection-type=List
-
-parser-list=a,b,c
-_parser-list.collection-type=List
-_parser-list.item-converter=org.apache.tamaya.collections.MyUpperCaseConverter
-
-redefined-map=0==none | 1==single | 2==any
-_redefined-map.map-entry-separator===
-_redefined-map.item-separator=|
-
[3/6] incubator-tamaya git commit: Moved collections module into
active modules folder.
Posted by an...@apache.org.
Moved collections module into active modules folder.
Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/commit/314ad28d
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/tree/314ad28d
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/diff/314ad28d
Branch: refs/heads/master
Commit: 314ad28dac5e558331724e9ad5f6eec3d9152f57
Parents: 6d9abde
Author: anatole <an...@apache.org>
Authored: Sat Feb 27 22:12:31 2016 +0100
Committer: anatole <an...@apache.org>
Committed: Sat Feb 27 22:12:31 2016 +0100
----------------------------------------------------------------------
modules/collections/pom.xml | 75 ++++++
.../internal/AdaptiveCombinationPolicy.java | 126 ++++++++++
.../internal/ArrayListConverter.java | 64 ++++++
.../internal/CollectionConverter.java | 63 +++++
.../internal/ConcurrentHashMapConverter.java | 65 ++++++
.../collections/internal/HashMapConverter.java | 64 ++++++
.../collections/internal/HashSetConverter.java | 65 ++++++
.../collections/internal/ItemTokenizer.java | 171 ++++++++++++++
.../internal/LinkedListConverter.java | 64 ++++++
.../collections/internal/ListConverter.java | 55 +++++
.../collections/internal/MapConverter.java | 59 +++++
.../collections/internal/SetConverter.java | 55 +++++
.../internal/SortedMapConverter.java | 37 +++
.../internal/SortedSetConverter.java | 36 +++
.../collections/internal/TreeMapConverter.java | 62 +++++
.../collections/internal/TreeSetConverter.java | 64 ++++++
.../org.apache.tamaya.spi.PropertyConverter | 31 +++
...he.tamaya.spi.PropertyValueCombinationPolicy | 19 ++
.../collections/CollectionAdvancedTests.java | 99 ++++++++
.../collections/CollectionsBaseTests.java | 227 +++++++++++++++++++
.../CollectionsTypedReadOnlyTests.java | 173 ++++++++++++++
.../collections/CollectionsTypedTests.java | 208 +++++++++++++++++
.../collections/MyUpperCaseConverter.java | 33 +++
.../META-INF/javaconfiguration.properties | 73 ++++++
sandbox/collections/pom.xml | 75 ------
.../internal/AdaptiveCombinationPolicy.java | 126 ----------
.../internal/ArrayListConverter.java | 64 ------
.../internal/CollectionConverter.java | 63 -----
.../internal/ConcurrentHashMapConverter.java | 65 ------
.../collections/internal/HashMapConverter.java | 64 ------
.../collections/internal/HashSetConverter.java | 65 ------
.../collections/internal/ItemTokenizer.java | 171 --------------
.../internal/LinkedListConverter.java | 64 ------
.../collections/internal/ListConverter.java | 55 -----
.../collections/internal/MapConverter.java | 59 -----
.../collections/internal/SetConverter.java | 55 -----
.../internal/SortedMapConverter.java | 37 ---
.../internal/SortedSetConverter.java | 36 ---
.../collections/internal/TreeMapConverter.java | 62 -----
.../collections/internal/TreeSetConverter.java | 64 ------
.../org.apache.tamaya.spi.PropertyConverter | 31 ---
...he.tamaya.spi.PropertyValueCombinationPolicy | 19 --
.../collections/CollectionAdvancedTests.java | 99 --------
.../collections/CollectionsBaseTests.java | 227 -------------------
.../CollectionsTypedReadOnlyTests.java | 173 --------------
.../collections/CollectionsTypedTests.java | 208 -----------------
.../collections/MyUpperCaseConverter.java | 33 ---
.../META-INF/javaconfiguration.properties | 73 ------
48 files changed, 1988 insertions(+), 1988 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/314ad28d/modules/collections/pom.xml
----------------------------------------------------------------------
diff --git a/modules/collections/pom.xml b/modules/collections/pom.xml
new file mode 100644
index 0000000..d5ed30b
--- /dev/null
+++ b/modules/collections/pom.xml
@@ -0,0 +1,75 @@
+<!--
+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-sandbox</artifactId>
+ <version>0.2-incubating-SNAPSHOT</version>
+ <relativePath>..</relativePath>
+ </parent>
+
+ <artifactId>tamaya-collections</artifactId>
+ <name>Apache Tamaya Modules - Collections Support</name>
+ <packaging>bundle</packaging>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tamaya</groupId>
+ <artifactId>tamaya-core</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tamaya</groupId>
+ <artifactId>tamaya-api</artifactId>
+ <version>${project.version}</version>
+ </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>
+ <Import-Package>
+ org.apache.tamaya,
+ org.apache.tamaya.spi,
+ javax.annotation,
+ *
+ </Import-Package>
+ <Private-Package>
+ org.apache.tamaya.collections.internal
+ </Private-Package>
+ </instructions>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/314ad28d/modules/collections/src/main/java/org/apache/tamaya/collections/internal/AdaptiveCombinationPolicy.java
----------------------------------------------------------------------
diff --git a/modules/collections/src/main/java/org/apache/tamaya/collections/internal/AdaptiveCombinationPolicy.java b/modules/collections/src/main/java/org/apache/tamaya/collections/internal/AdaptiveCombinationPolicy.java
new file mode 100644
index 0000000..d86abe7
--- /dev/null
+++ b/modules/collections/src/main/java/org/apache/tamaya/collections/internal/AdaptiveCombinationPolicy.java
@@ -0,0 +1,126 @@
+/*
+ * 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.collections.internal;
+
+import org.apache.tamaya.ConfigurationProvider;
+import org.apache.tamaya.spi.PropertySource;
+import org.apache.tamaya.spi.PropertyValue;
+import org.apache.tamaya.spi.PropertyValueCombinationPolicy;
+
+import javax.annotation.Priority;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ * PropertyValueCombinationPolicy that allows to configure a PropertyValueCombinationPolicy for each key
+ * individually, by adding a configured entry of the form
+ * {@code _key.combination-policy=collect|override|fqPolicyClassName}.
+ */
+@Priority(100)
+public class AdaptiveCombinationPolicy implements PropertyValueCombinationPolicy {
+ /** Logger. */
+ private static final Logger LOG = Logger.getLogger(AdaptiveCombinationPolicy.class.getName());
+
+ /**
+ * Collecting combination policy using (optional) {@code item-separator} parameter for determining the sparator
+ * to combine multiple config entries found.
+ */
+ private static final PropertyValueCombinationPolicy COLLECTING_POLICY = new PropertyValueCombinationPolicy(){
+ @Override
+ public Map<String, String> collect(Map<String, String> currentValue, String key, PropertySource propertySource) {
+ // check for default collection combination policies for lists, sets, maps etc.
+ final String SEPARATOR = ConfigurationProvider.getConfiguration().getOrDefault('_' + key+".item-separator", ",");
+ PropertyValue newValue = propertySource.get(key);
+ if(newValue!=null){
+ Map<String,String> newMapValue = new HashMap<>();
+ if(currentValue!=null){
+ newMapValue.putAll(currentValue);
+ }
+ String oldVal = newMapValue.get(key);
+ newMapValue.putAll(newValue.getConfigEntries());
+ if(oldVal!=null){
+ newMapValue.put(key,oldVal + SEPARATOR + newValue.getValue());
+ }
+ return newMapValue;
+ }else{
+ if(currentValue!=null){
+ return currentValue;
+ }
+ return Collections.emptyMap();
+ }
+ }
+ };
+
+ /** Cache for loaded custom combination policies. */
+ private Map<Class, PropertyValueCombinationPolicy> configuredPolicies = new ConcurrentHashMap<>();
+
+ @Override
+ public Map<String,String> collect(Map<String,String> currentValue, String key, PropertySource propertySource){
+ if(key.startsWith("_")){
+ PropertyValue newValue = propertySource.get(key);
+ if(newValue!=null){
+ return newValue.getConfigEntries();
+ }
+ return currentValue;
+ }
+ String adaptiveCombinationPolicyClass = ConfigurationProvider.getConfiguration().getOrDefault(
+ '_' + key+".combination-policy", "override");
+ PropertyValueCombinationPolicy combinationPolicy = null;
+ switch(adaptiveCombinationPolicyClass){
+ case "collect":
+ case "COLLECT":
+ if(LOG.isLoggable(Level.FINEST)){
+ LOG.finest("Using collecting combination policy for key: " + key + "");
+ }
+ combinationPolicy = COLLECTING_POLICY;
+ break;
+ case "override":
+ case "OVERRIDE":
+ if(LOG.isLoggable(Level.FINEST)){
+ LOG.finest("Using default (overriding) combination policy for key: " + key + "");
+ }
+ combinationPolicy = PropertyValueCombinationPolicy.DEFAULT_OVERRIDING_COLLECTOR;
+ break;
+ default:
+ try{
+ Class<PropertyValueCombinationPolicy> clazz = (Class<PropertyValueCombinationPolicy>)
+ Class.forName(adaptiveCombinationPolicyClass);
+ combinationPolicy = configuredPolicies.get(clazz);
+ if(combinationPolicy==null){
+ combinationPolicy = clazz.newInstance();
+ configuredPolicies.put(clazz, combinationPolicy);
+ }
+ if(LOG.isLoggable(Level.FINEST)){
+ LOG.finest("Using custom combination policy "+adaptiveCombinationPolicyClass+" for " +
+ "key: " + key + "");
+ }
+ }
+ catch(Exception e){
+ LOG.log(Level.SEVERE, "Error loading configured PropertyValueCombinationPolicy for " +
+ "key: " + key + ", using default (overriding) policy.", e);
+ combinationPolicy = PropertyValueCombinationPolicy.DEFAULT_OVERRIDING_COLLECTOR;
+ }
+ }
+ return combinationPolicy.collect(currentValue, key, propertySource);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/314ad28d/modules/collections/src/main/java/org/apache/tamaya/collections/internal/ArrayListConverter.java
----------------------------------------------------------------------
diff --git a/modules/collections/src/main/java/org/apache/tamaya/collections/internal/ArrayListConverter.java b/modules/collections/src/main/java/org/apache/tamaya/collections/internal/ArrayListConverter.java
new file mode 100644
index 0000000..8281395
--- /dev/null
+++ b/modules/collections/src/main/java/org/apache/tamaya/collections/internal/ArrayListConverter.java
@@ -0,0 +1,64 @@
+/*
+ * 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.collections.internal;
+
+import org.apache.tamaya.ConfigurationProvider;
+import org.apache.tamaya.TypeLiteral;
+import org.apache.tamaya.spi.ConversionContext;
+import org.apache.tamaya.spi.PropertyConverter;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ * PropertyConverter for gnerating ArrayList representation of a values.
+ */
+public class ArrayListConverter implements PropertyConverter<ArrayList> {
+
+ private static final Logger LOG = Logger.getLogger(ArrayListConverter.class.getName());
+
+ /** The shared instance, used by other collection converters in this package.*/
+ private static ArrayListConverter INSTANCE = new ArrayListConverter();
+
+ /**
+ * Provide a shared instance, used by other collection converters in this package.
+ * @return the shared instance, never null.
+ */
+ static ArrayListConverter getInstance(){
+ return INSTANCE;
+ }
+
+ @Override
+ public ArrayList convert(String value, ConversionContext context) {
+ List<String> rawList = ItemTokenizer.split(value, context);
+ ArrayList<Object> mlist = new ArrayList<>();
+ for(String raw:rawList){
+ Object convValue = ItemTokenizer.convertValue(raw, context);
+ if (convValue != null) {
+ mlist.add(convValue);
+ }else{
+ LOG.log(Level.SEVERE, "Failed to convert collection value type for '"+raw+"'.");
+ }
+ }
+ return mlist;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/314ad28d/modules/collections/src/main/java/org/apache/tamaya/collections/internal/CollectionConverter.java
----------------------------------------------------------------------
diff --git a/modules/collections/src/main/java/org/apache/tamaya/collections/internal/CollectionConverter.java b/modules/collections/src/main/java/org/apache/tamaya/collections/internal/CollectionConverter.java
new file mode 100644
index 0000000..0d9a799
--- /dev/null
+++ b/modules/collections/src/main/java/org/apache/tamaya/collections/internal/CollectionConverter.java
@@ -0,0 +1,63 @@
+/*
+ * 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.collections.internal;
+
+import org.apache.tamaya.spi.ConversionContext;
+import org.apache.tamaya.spi.PropertyConverter;
+
+import java.util.Collection;
+import java.util.Collections;
+
+/**
+ * PropertyConverter for gnerating a LIST representation of values.
+ */
+public class CollectionConverter implements PropertyConverter<Collection> {
+
+ @Override
+ public Collection convert(String value, ConversionContext context) {
+ String collectionType = context.getConfiguration().getOrDefault('_' + context.getKey()+".collection-type", "List");
+ if(collectionType.startsWith("java.util.")){
+ collectionType = collectionType.substring("java.util.".length());
+ }
+ Collection result = null;
+ switch(collectionType){
+ case "List":
+ case "ArrayList":
+ default:
+ result = ArrayListConverter.getInstance().convert(value, context);
+ break;
+ case "LinkedList":
+ result = LinkedListConverter.getInstance().convert(value, context);
+ break;
+ case "Set":
+ case "HashSet":
+ result = HashSetConverter.getInstance().convert(value, context);
+ break;
+ case "SortedSet":
+ case "TreeSet":
+ result = TreeSetConverter.getInstance().convert(value, context);
+ break;
+ }
+ if(context.getConfiguration().getOrDefault('_' + context.getKey()+".read-only",
+ Boolean.class, Boolean.TRUE)){
+ return Collections.unmodifiableCollection(result);
+ }
+ return result;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/314ad28d/modules/collections/src/main/java/org/apache/tamaya/collections/internal/ConcurrentHashMapConverter.java
----------------------------------------------------------------------
diff --git a/modules/collections/src/main/java/org/apache/tamaya/collections/internal/ConcurrentHashMapConverter.java b/modules/collections/src/main/java/org/apache/tamaya/collections/internal/ConcurrentHashMapConverter.java
new file mode 100644
index 0000000..131b41c
--- /dev/null
+++ b/modules/collections/src/main/java/org/apache/tamaya/collections/internal/ConcurrentHashMapConverter.java
@@ -0,0 +1,65 @@
+/*
+ * 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.collections.internal;
+
+import org.apache.tamaya.TypeLiteral;
+import org.apache.tamaya.spi.ConversionContext;
+import org.apache.tamaya.spi.PropertyConverter;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ * PropertyConverter for gnerating ConcurrentHashMap representation of a values.
+ */
+public class ConcurrentHashMapConverter implements PropertyConverter<ConcurrentHashMap> {
+ private static final Logger LOG = Logger.getLogger(ConcurrentHashMapConverter.class.getName());
+
+ /** The shared instance, used by other collection converters in this package.*/
+ private static ConcurrentHashMapConverter INSTANCE = new ConcurrentHashMapConverter();
+
+ /**
+ * Provide a shared instance, used by other collection converters in this package.
+ * @return the shared instance, never null.
+ */
+ static ConcurrentHashMapConverter getInstance(){
+ return INSTANCE;
+ }
+
+ @Override
+ public ConcurrentHashMap convert(String value, ConversionContext context) {
+ List<String> rawList = ItemTokenizer.split(value, context);
+ ConcurrentHashMap result = new ConcurrentHashMap(rawList.size());
+ for(String raw:rawList){
+ String[] items = ItemTokenizer.splitMapEntry(raw, context);
+ Object convValue = ItemTokenizer.convertValue(items[1], context);
+ if(convValue!=null){
+ result.put(items[0], convValue);
+ }else{
+ LOG.log(Level.SEVERE, "Failed to convert collection value type for '"+raw+"'.");
+ }
+ }
+ return result;
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/314ad28d/modules/collections/src/main/java/org/apache/tamaya/collections/internal/HashMapConverter.java
----------------------------------------------------------------------
diff --git a/modules/collections/src/main/java/org/apache/tamaya/collections/internal/HashMapConverter.java b/modules/collections/src/main/java/org/apache/tamaya/collections/internal/HashMapConverter.java
new file mode 100644
index 0000000..6a3ac97
--- /dev/null
+++ b/modules/collections/src/main/java/org/apache/tamaya/collections/internal/HashMapConverter.java
@@ -0,0 +1,64 @@
+/*
+ * 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.collections.internal;
+
+import org.apache.tamaya.TypeLiteral;
+import org.apache.tamaya.spi.ConversionContext;
+import org.apache.tamaya.spi.PropertyConverter;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ * PropertyConverter for gnerating HashMap representation of a values.
+ */
+public class HashMapConverter implements PropertyConverter<HashMap> {
+ private static final Logger LOG = Logger.getLogger(HashMapConverter.class.getName());
+
+ /** The shared instance, used by other collection converters in this package.*/
+ private static HashMapConverter INSTANCE = new HashMapConverter();
+
+ /**
+ * Provide a shared instance, used by other collection converters in this package.
+ * @return the shared instance, never null.
+ */
+ static HashMapConverter getInstance(){
+ return INSTANCE;
+ }
+
+ @Override
+ public HashMap convert(String value, ConversionContext context) {
+ List<String> rawList = ItemTokenizer.split(value, context);
+ HashMap result = new HashMap(rawList.size());
+ for(String raw:rawList){
+ String[] items = ItemTokenizer.splitMapEntry(raw, context);
+ Object convValue = ItemTokenizer.convertValue(items[1], context);
+ if(convValue!=null){
+ result.put(items[0], convValue);
+ }else{
+ LOG.log(Level.SEVERE, "Failed to convert collection value type for '"+raw+"'.");
+ }
+ }
+ return result;
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/314ad28d/modules/collections/src/main/java/org/apache/tamaya/collections/internal/HashSetConverter.java
----------------------------------------------------------------------
diff --git a/modules/collections/src/main/java/org/apache/tamaya/collections/internal/HashSetConverter.java b/modules/collections/src/main/java/org/apache/tamaya/collections/internal/HashSetConverter.java
new file mode 100644
index 0000000..40b204f
--- /dev/null
+++ b/modules/collections/src/main/java/org/apache/tamaya/collections/internal/HashSetConverter.java
@@ -0,0 +1,65 @@
+/*
+ * 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.collections.internal;
+
+import org.apache.tamaya.TypeLiteral;
+import org.apache.tamaya.spi.ConversionContext;
+import org.apache.tamaya.spi.PropertyConverter;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ * PropertyConverter for gnerating HashSet representation of a values.
+ */
+public class HashSetConverter implements PropertyConverter<HashSet> {
+
+ private static final Logger LOG = Logger.getLogger(HashSetConverter.class.getName());
+
+ /** The shared instance, used by other collection converters in this package.*/
+ private static HashSetConverter INSTANCE = new HashSetConverter();
+
+ /**
+ * Provide a shared instance, used by other collection converters in this package.
+ * @return the shared instance, never null.
+ */
+ static HashSetConverter getInstance(){
+ return INSTANCE;
+ }
+
+ @Override
+ public HashSet convert(String value, ConversionContext context) {
+ List<String> rawList = ItemTokenizer.split(value, context);
+ HashSet<Object> result = new HashSet<>();
+ for(String raw:rawList){
+ String[] items = ItemTokenizer.splitMapEntry(raw, context);
+ Object convValue = ItemTokenizer.convertValue(items[1], context);
+ if(convValue!=null){
+ result.add(convValue);
+ }else{
+ LOG.log(Level.SEVERE, "Failed to convert collection value type for '"+raw+"'.");
+ }
+ }
+ return result;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/314ad28d/modules/collections/src/main/java/org/apache/tamaya/collections/internal/ItemTokenizer.java
----------------------------------------------------------------------
diff --git a/modules/collections/src/main/java/org/apache/tamaya/collections/internal/ItemTokenizer.java b/modules/collections/src/main/java/org/apache/tamaya/collections/internal/ItemTokenizer.java
new file mode 100644
index 0000000..7d213a4
--- /dev/null
+++ b/modules/collections/src/main/java/org/apache/tamaya/collections/internal/ItemTokenizer.java
@@ -0,0 +1,171 @@
+/*
+ * 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.collections.internal;
+
+import org.apache.tamaya.ConfigurationProvider;
+import org.apache.tamaya.TypeLiteral;
+import org.apache.tamaya.spi.ConversionContext;
+import org.apache.tamaya.spi.PropertyConverter;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ * Helper class that implements the tokenizing of the entries of a configuration value.
+ */
+final class ItemTokenizer {
+
+ private static final Logger LOG = Logger.getLogger(ItemTokenizer.class.getName());
+
+ /**
+ * Private singleton.
+ */
+ private ItemTokenizer(){}
+
+ /**
+ * Splits the given value using the given separator. Matcjhing is done by traversing the String value using
+ * {@code indexOf} calls, one by one. The last unresolvable item (without any next separator token)
+ * is added at the end of the list.
+ * @param value the value, not null.
+ * @param context the conversion context.
+ * @return the tokenized value as list, in order of occurrence.
+ */
+ public static List<String> split(String value, ConversionContext context){
+ return split(value, ConfigurationProvider.getConfiguration().getOrDefault(
+ '_' + context.getKey()+ "" +
+ "item-separator", ","));
+ }
+
+ /**
+ * Splits the given value using the given separator. Matcjhing is done by traversing the String value using
+ * {@code indexOf} calls, one by one. The last unresolvable item (without any next separator token)
+ * is added at the end of the list.
+ * @param value the value, not null.
+ * @param separator the separator to be used.
+ * @return the tokenized value as list, in order of occurrence.
+ */
+ public static List<String> split(String value, final String separator) {
+ ArrayList<String> result = new ArrayList<>();
+ int start = 0;
+ int end = value.indexOf(separator,start);
+ while(end>0) {
+ if (end>0 && (value.charAt(end - 1) != '\\')) {
+ result.add(value.substring(start, end));
+ start = end + separator.length();
+ end = value.indexOf(separator,start);
+ }else{
+ end = value.indexOf(separator,end + separator.length());
+ }
+ end = value.indexOf(separator,start);
+ }
+ if(start < value.length()){
+ result.add(value.substring(start));
+ }
+ return result;
+ }
+
+ /**
+ * plits the given String value as a map entry, splitting it into key and value part with the given separator.
+ * If the value cannot be split then {@code key = value = mapEntry} is used for further processing. key or value
+ * parts are normally trimmed, unless they are enmcosed with brackets {@code []}.
+ * @param mapEntry the entry, not null.
+ * @param context the conversion context.
+ * @return an array of length 2, with the trimmed and parsed key/value pair.
+ */
+ public static String[] splitMapEntry(String mapEntry, ConversionContext context){
+ return splitMapEntry(mapEntry, ConfigurationProvider.getConfiguration().getOrDefault(
+ '_' + context.getKey()+".map-entry-separator", "::"));
+ }
+
+ /**
+ * Splits the given String value as a map entry, splitting it into key and value part with the given separator.
+ * If the value cannot be split then {@code key = value = mapEntry} is used for further processing. key or value
+ * parts are normally trimmed, unless they are enmcosed with brackets {@code []}.
+ * @param mapEntry the entry, not null.
+ * @param separator the separator, not null.
+ * @return an array of length 2, with the trimmed and parsed key/value pair.
+ */
+ public static String[] splitMapEntry(final String mapEntry, final String separator) {
+ int index = mapEntry.indexOf(separator);
+ String[] items;
+ if(index<0) {
+ items = new String[]{mapEntry, mapEntry};
+ }else {
+ items = new String[]{mapEntry.substring(0,index),
+ mapEntry.substring(index+separator.length())};
+ }
+ if(items[0].trim().startsWith("[")){
+ items[0]= items[0].trim();
+ items[0] = items[0].substring(1);
+ }else{
+ items[0]= items[0].trim();
+ }
+ if(items[1].trim().endsWith("]")){
+ items[1] = items[1].substring(0,items[1].length()-1);
+ }else{
+ items[1]= items[1].trim();
+ }
+ return items;
+ }
+
+ /**
+ * Parses the given value into the required collection target type, defined by the context.
+ * @param value the raw String value.
+ * @param context the context
+ * @return the parsed value, or null.
+ */
+ public static Object convertValue(String value, ConversionContext context) {
+ String converterClass = context.getConfiguration().get('_' + context.getKey() + ".item-converter");
+ List<PropertyConverter<Object>> valueConverters = new ArrayList<>(1);
+ if (converterClass != null) {
+ try {
+ valueConverters.add((PropertyConverter<Object>) Class.forName(converterClass).newInstance());
+ } catch (Exception e) {
+ LOG.log(Level.SEVERE, "Error convertion config to ArrayList type.", e);
+ }
+ }
+ if (TypeLiteral.getTypeParameters(context.getTargetType().getType()).length>0) {
+ valueConverters.addAll(context.getConfigurationContext().getPropertyConverters(
+ TypeLiteral.of(TypeLiteral.getTypeParameters(context.getTargetType().getType())[0])));
+ }
+ ConversionContext ctx = new ConversionContext.Builder(context.getConfiguration(),
+ context.getConfigurationContext(), context.getKey(),
+ TypeLiteral.of(context.getTargetType().getType())).build();
+ Object result = null;
+ if (valueConverters.isEmpty()) {
+ return value;
+ } else {
+ for (PropertyConverter<Object> conv : valueConverters) {
+ try {
+ result = conv.convert(value, ctx);
+ if (result != null) {
+ return result;
+ }
+ } catch (Exception e) {
+ LOG.log(Level.SEVERE, "Error convertion config to ArrayList type.", e);
+ }
+ }
+ }
+ LOG.log(Level.SEVERE, "Failed to convert collection value type for '" + value + "'.");
+ return null;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/314ad28d/modules/collections/src/main/java/org/apache/tamaya/collections/internal/LinkedListConverter.java
----------------------------------------------------------------------
diff --git a/modules/collections/src/main/java/org/apache/tamaya/collections/internal/LinkedListConverter.java b/modules/collections/src/main/java/org/apache/tamaya/collections/internal/LinkedListConverter.java
new file mode 100644
index 0000000..4389a54
--- /dev/null
+++ b/modules/collections/src/main/java/org/apache/tamaya/collections/internal/LinkedListConverter.java
@@ -0,0 +1,64 @@
+/*
+ * 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.collections.internal;
+
+import org.apache.tamaya.TypeLiteral;
+import org.apache.tamaya.spi.ConversionContext;
+import org.apache.tamaya.spi.PropertyConverter;
+
+import java.util.LinkedList;
+import java.util.List;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ * PropertyConverter for gnerating LinkedList representation of a values.
+ */
+public class LinkedListConverter implements PropertyConverter<LinkedList> {
+ private static final Logger LOG = Logger.getLogger(LinkedListConverter.class.getName());
+
+ /** The shared instance, used by other collection converters in this package.*/
+ private static LinkedListConverter INSTANCE = new LinkedListConverter();
+
+ /**
+ * Provide a shared instance, used by other collection converters in this package.
+ * @return the shared instance, never null.
+ */
+ static LinkedListConverter getInstance(){
+ return INSTANCE;
+ }
+
+ @Override
+ public LinkedList convert(String value, ConversionContext context) {
+ List<String> rawList = ItemTokenizer.split(value, context);
+ LinkedList<Object> result = new LinkedList<>();
+ for(String raw:rawList){
+ String[] items = ItemTokenizer.splitMapEntry(raw, context);
+ Object convValue = ItemTokenizer.convertValue(items[1], context);
+ if(convValue!=null){
+ result.add(convValue);
+ continue;
+ }else{
+ LOG.log(Level.SEVERE, "Failed to convert collection value type for '"+raw+"'.");
+ }
+ }
+ return result;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/314ad28d/modules/collections/src/main/java/org/apache/tamaya/collections/internal/ListConverter.java
----------------------------------------------------------------------
diff --git a/modules/collections/src/main/java/org/apache/tamaya/collections/internal/ListConverter.java b/modules/collections/src/main/java/org/apache/tamaya/collections/internal/ListConverter.java
new file mode 100644
index 0000000..65fc54e
--- /dev/null
+++ b/modules/collections/src/main/java/org/apache/tamaya/collections/internal/ListConverter.java
@@ -0,0 +1,55 @@
+/*
+ * 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.collections.internal;
+
+import org.apache.tamaya.spi.ConversionContext;
+import org.apache.tamaya.spi.PropertyConverter;
+
+import java.util.Collections;
+import java.util.List;
+
+/**
+ * PropertyConverter for gnerating a LIST representation of values.
+ */
+public class ListConverter implements PropertyConverter<List> {
+
+ @Override
+ public List convert(String value, ConversionContext context) {
+ String collectionType = context.getConfiguration().getOrDefault('_' + context.getKey()+".collection-type", "List");
+ if(collectionType.startsWith("java.util.")){
+ collectionType = collectionType.substring("java.util.".length());
+ }
+ List result = null;
+ switch(collectionType){
+ case "List":
+ case "ArrayList":
+ default:
+ result = ArrayListConverter.getInstance().convert(value, context);
+ break;
+ case "LinkedList":
+ result = LinkedListConverter.getInstance().convert(value, context);
+ break;
+ }
+ if(context.getConfiguration().getOrDefault('_' + context.getKey()+".read-only",
+ Boolean.class, Boolean.TRUE)){
+ return Collections.unmodifiableList(result);
+ }
+ return result;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/314ad28d/modules/collections/src/main/java/org/apache/tamaya/collections/internal/MapConverter.java
----------------------------------------------------------------------
diff --git a/modules/collections/src/main/java/org/apache/tamaya/collections/internal/MapConverter.java b/modules/collections/src/main/java/org/apache/tamaya/collections/internal/MapConverter.java
new file mode 100644
index 0000000..606e14f
--- /dev/null
+++ b/modules/collections/src/main/java/org/apache/tamaya/collections/internal/MapConverter.java
@@ -0,0 +1,59 @@
+/*
+ * 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.collections.internal;
+
+import org.apache.tamaya.spi.ConversionContext;
+import org.apache.tamaya.spi.PropertyConverter;
+
+import java.util.Collections;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * PropertyConverter for gnerating HashMap representation of a values.
+ */
+public class MapConverter implements PropertyConverter<Map> {
+
+ @Override
+ public Map convert(String value, ConversionContext context) {
+ String collectionType = context.getConfiguration().getOrDefault('_' + context.getKey()+".collection-type", "Map");
+ if(collectionType.startsWith("java.util.")){
+ collectionType = collectionType.substring("java.util.".length());
+ }
+ Map result = null;
+ switch(collectionType){
+ case "Map":
+ case "HashMap":
+ default:
+ result = HashMapConverter.getInstance().convert(value, context);
+ break;
+ case "TreeMap":
+ result = TreeMapConverter.getInstance().convert(value, context);
+ break;
+ case "ConcurrentHashMap":
+ result = ConcurrentHashMapConverter.getInstance().convert(value, context);
+ break;
+ }
+ if(context.getConfiguration().getOrDefault('_' + context.getKey()+".read-only",
+ Boolean.class, Boolean.TRUE)){
+ return Collections.unmodifiableMap(result);
+ }
+ return result;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/314ad28d/modules/collections/src/main/java/org/apache/tamaya/collections/internal/SetConverter.java
----------------------------------------------------------------------
diff --git a/modules/collections/src/main/java/org/apache/tamaya/collections/internal/SetConverter.java b/modules/collections/src/main/java/org/apache/tamaya/collections/internal/SetConverter.java
new file mode 100644
index 0000000..75301bc
--- /dev/null
+++ b/modules/collections/src/main/java/org/apache/tamaya/collections/internal/SetConverter.java
@@ -0,0 +1,55 @@
+/*
+ * 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.collections.internal;
+
+import org.apache.tamaya.spi.ConversionContext;
+import org.apache.tamaya.spi.PropertyConverter;
+
+import java.util.Collections;
+import java.util.Set;
+
+/**
+ * PropertyConverter for gnerating a LIST representation of values.
+ */
+public class SetConverter implements PropertyConverter<Set> {
+
+ @Override
+ public Set convert(String value, ConversionContext context) {
+ String collectionType = context.getConfiguration().getOrDefault('_' + context.getKey()+".collection-type", "Set");
+ if(collectionType.startsWith("java.util.")){
+ collectionType = collectionType.substring("java.util.".length());
+ }
+ Set result = null;
+ switch(collectionType){
+ case "Set":
+ case "HashSet":
+ default:
+ result = HashSetConverter.getInstance().convert(value, context);
+ break;
+ case "TreeSet":
+ result = TreeSetConverter.getInstance().convert(value, context);
+ break;
+ }
+ if(context.getConfiguration().getOrDefault('_' + context.getKey()+".read-only",
+ Boolean.class, Boolean.TRUE)){
+ return Collections.unmodifiableSet(result);
+ }
+ return result;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/314ad28d/modules/collections/src/main/java/org/apache/tamaya/collections/internal/SortedMapConverter.java
----------------------------------------------------------------------
diff --git a/modules/collections/src/main/java/org/apache/tamaya/collections/internal/SortedMapConverter.java b/modules/collections/src/main/java/org/apache/tamaya/collections/internal/SortedMapConverter.java
new file mode 100644
index 0000000..1015751
--- /dev/null
+++ b/modules/collections/src/main/java/org/apache/tamaya/collections/internal/SortedMapConverter.java
@@ -0,0 +1,37 @@
+/*
+ * 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.collections.internal;
+
+import org.apache.tamaya.spi.ConversionContext;
+import org.apache.tamaya.spi.PropertyConverter;
+
+import java.util.Collections;
+import java.util.SortedMap;
+import java.util.SortedSet;
+
+/**
+ * PropertyConverter for gnerating a LIST representation of values.
+ */
+public class SortedMapConverter implements PropertyConverter<SortedMap> {
+
+ @Override
+ public SortedMap convert(String value, ConversionContext context) {
+ return Collections.unmodifiableSortedMap(TreeMapConverter.getInstance().convert(value, context));
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/314ad28d/modules/collections/src/main/java/org/apache/tamaya/collections/internal/SortedSetConverter.java
----------------------------------------------------------------------
diff --git a/modules/collections/src/main/java/org/apache/tamaya/collections/internal/SortedSetConverter.java b/modules/collections/src/main/java/org/apache/tamaya/collections/internal/SortedSetConverter.java
new file mode 100644
index 0000000..c0b8065
--- /dev/null
+++ b/modules/collections/src/main/java/org/apache/tamaya/collections/internal/SortedSetConverter.java
@@ -0,0 +1,36 @@
+/*
+ * 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.collections.internal;
+
+import org.apache.tamaya.spi.ConversionContext;
+import org.apache.tamaya.spi.PropertyConverter;
+
+import java.util.Collections;
+import java.util.SortedSet;
+
+/**
+ * PropertyConverter for gnerating a LIST representation of values.
+ */
+public class SortedSetConverter implements PropertyConverter<SortedSet> {
+
+ @Override
+ public SortedSet convert(String value, ConversionContext context) {
+ return Collections.unmodifiableSortedSet(TreeSetConverter.getInstance().convert(value, context));
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/314ad28d/modules/collections/src/main/java/org/apache/tamaya/collections/internal/TreeMapConverter.java
----------------------------------------------------------------------
diff --git a/modules/collections/src/main/java/org/apache/tamaya/collections/internal/TreeMapConverter.java b/modules/collections/src/main/java/org/apache/tamaya/collections/internal/TreeMapConverter.java
new file mode 100644
index 0000000..fef25fe
--- /dev/null
+++ b/modules/collections/src/main/java/org/apache/tamaya/collections/internal/TreeMapConverter.java
@@ -0,0 +1,62 @@
+/*
+ * 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.collections.internal;
+
+import org.apache.tamaya.spi.ConversionContext;
+import org.apache.tamaya.spi.PropertyConverter;
+
+import java.util.List;
+import java.util.TreeMap;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ * PropertyConverter for gnerating HashMap representation of a values.
+ */
+public class TreeMapConverter implements PropertyConverter<TreeMap> {
+ /** Logger used. */
+ private static final Logger LOG = Logger.getLogger(HashMapConverter.class.getName());
+
+ /** The shared instance, used by other collection converters in this package.*/
+ private static TreeMapConverter INSTANCE = new TreeMapConverter();
+
+ /**
+ * Provide a shared instance, used by other collection converters in this package.
+ * @return the shared instance, never null.
+ */
+ static TreeMapConverter getInstance(){
+ return INSTANCE;
+ }
+
+ @Override
+ public TreeMap convert(String value, ConversionContext context) {
+ List<String> rawList = ItemTokenizer.split(value, context);
+ TreeMap result = new TreeMap();
+ for(String raw:rawList){
+ String[] items = ItemTokenizer.splitMapEntry(raw, context);
+ Object convValue = ItemTokenizer.convertValue(items[1], context);
+ if(convValue!=null){
+ result.put(items[0], convValue);
+ }else{
+ LOG.log(Level.SEVERE, "Failed to convert collection value type for '"+raw+"'.");
+ }
+ }
+ return result;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/314ad28d/modules/collections/src/main/java/org/apache/tamaya/collections/internal/TreeSetConverter.java
----------------------------------------------------------------------
diff --git a/modules/collections/src/main/java/org/apache/tamaya/collections/internal/TreeSetConverter.java b/modules/collections/src/main/java/org/apache/tamaya/collections/internal/TreeSetConverter.java
new file mode 100644
index 0000000..9206f07
--- /dev/null
+++ b/modules/collections/src/main/java/org/apache/tamaya/collections/internal/TreeSetConverter.java
@@ -0,0 +1,64 @@
+/*
+ * 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.collections.internal;
+
+import org.apache.tamaya.TypeLiteral;
+import org.apache.tamaya.spi.ConversionContext;
+import org.apache.tamaya.spi.PropertyConverter;
+
+import java.util.List;
+import java.util.TreeSet;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ * PropertyConverter for gnerating HashSet representation of a values.
+ */
+public class TreeSetConverter implements PropertyConverter<TreeSet> {
+
+ private static final Logger LOG = Logger.getLogger(TreeSetConverter.class.getName());
+
+ /** The shared instance, used by other collection converters in this package.*/
+ private static TreeSetConverter INSTANCE = new TreeSetConverter();
+
+ /**
+ * Provide a shared instance, used by other collection converters in this package.
+ * @return the shared instance, never null.
+ */
+ static TreeSetConverter getInstance(){
+ return INSTANCE;
+ }
+
+ @Override
+ public TreeSet convert(String value, ConversionContext context) {
+ List<String> rawList = ItemTokenizer.split(value, context);
+ TreeSet<Object> result = new TreeSet<>();
+ for(String raw:rawList){
+ String[] items = ItemTokenizer.splitMapEntry(raw, context);
+ Object convValue = ItemTokenizer.convertValue(items[1], context);
+ if(convValue!=null){
+ result.add(convValue);
+ continue;
+ }else{
+ LOG.log(Level.SEVERE, "Failed to convert collection value type for '"+raw+"'.");
+ }
+ }
+ return result;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/314ad28d/modules/collections/src/main/resources/META-INF/services/org.apache.tamaya.spi.PropertyConverter
----------------------------------------------------------------------
diff --git a/modules/collections/src/main/resources/META-INF/services/org.apache.tamaya.spi.PropertyConverter b/modules/collections/src/main/resources/META-INF/services/org.apache.tamaya.spi.PropertyConverter
new file mode 100644
index 0000000..9a93a69
--- /dev/null
+++ b/modules/collections/src/main/resources/META-INF/services/org.apache.tamaya.spi.PropertyConverter
@@ -0,0 +1,31 @@
+#
+# 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.
+#
+org.apache.tamaya.collections.internal.ArrayListConverter
+org.apache.tamaya.collections.internal.CollectionConverter
+org.apache.tamaya.collections.internal.HashMapConverter
+org.apache.tamaya.collections.internal.ConcurrentHashMapConverter
+org.apache.tamaya.collections.internal.HashSetConverter
+org.apache.tamaya.collections.internal.LinkedListConverter
+org.apache.tamaya.collections.internal.ListConverter
+org.apache.tamaya.collections.internal.MapConverter
+org.apache.tamaya.collections.internal.SetConverter
+org.apache.tamaya.collections.internal.SortedSetConverter
+org.apache.tamaya.collections.internal.SortedMapConverter
+org.apache.tamaya.collections.internal.TreeMapConverter
+org.apache.tamaya.collections.internal.TreeSetConverter
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/314ad28d/modules/collections/src/main/resources/META-INF/services/org.apache.tamaya.spi.PropertyValueCombinationPolicy
----------------------------------------------------------------------
diff --git a/modules/collections/src/main/resources/META-INF/services/org.apache.tamaya.spi.PropertyValueCombinationPolicy b/modules/collections/src/main/resources/META-INF/services/org.apache.tamaya.spi.PropertyValueCombinationPolicy
new file mode 100644
index 0000000..6b7a67b
--- /dev/null
+++ b/modules/collections/src/main/resources/META-INF/services/org.apache.tamaya.spi.PropertyValueCombinationPolicy
@@ -0,0 +1,19 @@
+#
+# 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.
+#
+org.apache.tamaya.collections.internal.AdaptiveCombinationPolicy
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/314ad28d/modules/collections/src/test/java/org/apache/tamaya/collections/CollectionAdvancedTests.java
----------------------------------------------------------------------
diff --git a/modules/collections/src/test/java/org/apache/tamaya/collections/CollectionAdvancedTests.java b/modules/collections/src/test/java/org/apache/tamaya/collections/CollectionAdvancedTests.java
new file mode 100644
index 0000000..ddabb23
--- /dev/null
+++ b/modules/collections/src/test/java/org/apache/tamaya/collections/CollectionAdvancedTests.java
@@ -0,0 +1,99 @@
+package org.apache.tamaya.collections;
+
+import org.apache.tamaya.Configuration;
+import org.apache.tamaya.ConfigurationProvider;
+import org.apache.tamaya.TypeLiteral;
+import org.junit.Test;
+
+import java.util.Currency;
+import java.util.List;
+import java.util.Map;
+
+import static junit.framework.TestCase.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+
+/**
+ * Created by atsticks on 16.02.16.
+ */
+public class CollectionAdvancedTests {
+
+ /**
+ * Tests if a custom separator works, Config is
+ * <pre>
+ * sep-list=a,b,c|d,e,f|g,h,i
+ * _sep-list.collection-type=List
+ * _sep-list.collection-separator=|
+ * </pre>
+ */
+ @Test
+ public void testCustomSeparator(){
+ Configuration config = ConfigurationProvider.getConfiguration();
+ List<String> items = config.get("sep-list", new TypeLiteral<List<String>>(){});
+ assertNotNull(items);
+ assertFalse(items.isEmpty());
+ assertEquals(3, items.size());
+ assertEquals("a,b,c", items.get(0));
+ assertEquals("d,e,f", items.get(1));
+ assertEquals("g,h,i", items.get(2));
+ }
+
+ /**
+ * Test typed content.
+ * <pre>
+ * currency-list=CHF,USD,YEN
+ * _currency-list.collection-type=List
+ * </pre>
+ */
+ @Test
+ public void testTypedContent(){
+ Configuration config = ConfigurationProvider.getConfiguration();
+ List<Currency> items = config.get("currency-list", new TypeLiteral<List<Currency>>(){});
+ assertNotNull(items);
+ assertFalse(items.isEmpty());
+ assertEquals(3, items.size());
+ assertEquals("CHF", items.get(0).getCurrencyCode());
+ assertEquals("USD", items.get(1).getCurrencyCode());
+ assertEquals("USS", items.get(2).getCurrencyCode());
+ }
+
+ /**
+ * Tests if a custom parser works, Config is
+ * <pre>
+ * parser-list=a,b,c
+ * _parser-list.collection-type=List
+ * _parser-list.item-converter=org.apache.tamaya.collections.MyUpperCaseConverter
+ * </pre>
+ */
+ @Test
+ public void testCustomParser(){
+ Configuration config = ConfigurationProvider.getConfiguration();
+ List<String> items = config.get("parser-list", new TypeLiteral<List<String>>(){});
+ assertNotNull(items);
+ assertFalse(items.isEmpty());
+ assertEquals(3, items.size());
+ assertEquals("(A)", items.get(0));
+ assertEquals("(B)", items.get(1));
+ assertEquals("(C)", items.get(2));
+ }
+
+ /**
+ * Redefined map format parsing, Config is as follows:
+ * <pre>
+ * redefined-map=0==none | 1==single | 2==any
+ * _redefined-map.map-entry-separator===
+ * _redefined-map.item-separator=|
+ * </pre>
+ */
+ @Test
+ public void testCustomMapParser(){
+ Configuration config = ConfigurationProvider.getConfiguration();
+ Map<String,String> items = config.get("redefined-map", Map.class);
+ assertNotNull(items);
+ assertFalse(items.isEmpty());
+ assertEquals(3, items.size());
+ assertEquals("none", items.get("0"));
+ assertEquals("single", items.get("1"));
+ assertEquals("any", items.get("2"));
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/314ad28d/modules/collections/src/test/java/org/apache/tamaya/collections/CollectionsBaseTests.java
----------------------------------------------------------------------
diff --git a/modules/collections/src/test/java/org/apache/tamaya/collections/CollectionsBaseTests.java b/modules/collections/src/test/java/org/apache/tamaya/collections/CollectionsBaseTests.java
new file mode 100644
index 0000000..34c82cb
--- /dev/null
+++ b/modules/collections/src/test/java/org/apache/tamaya/collections/CollectionsBaseTests.java
@@ -0,0 +1,227 @@
+/*
+ * 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.collections;
+
+import org.apache.tamaya.Configuration;
+import org.apache.tamaya.ConfigurationProvider;
+import org.apache.tamaya.TypeLiteral;
+import org.junit.Test;
+
+import java.util.*;
+
+import static junit.framework.TestCase.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+
+/**
+ * Basic tests for Tamaya collection support. Relevant configs for this tests:
+ * <pre>base.items=1,2,3,4,5,6,7,8,9,0
+ * base.map=1::a, 2::b, 3::c, [4:: ]
+ * </pre>
+ */
+public class CollectionsBaseTests {
+
+ @Test
+ public void testList_String(){
+ Configuration config = ConfigurationProvider.getConfiguration();
+ List<String> items = config.get("base.items", new TypeLiteral<List<String>>(){});
+ assertNotNull(items);
+ assertFalse(items.isEmpty());
+ assertEquals(10, items.size());
+ items = (List<String>) config.get("base.items", List.class);
+ assertNotNull(items);
+ assertFalse(items.isEmpty());
+ assertEquals(10, items.size());
+ }
+
+ @Test
+ public void testArrayList_String(){
+ Configuration config = ConfigurationProvider.getConfiguration();
+ ArrayList<String> items = config.get("base.items", new TypeLiteral<ArrayList<String>>(){});
+ assertNotNull(items);
+ assertFalse(items.isEmpty());
+ assertEquals(10, items.size());
+ items = (ArrayList<String>) config.get("base.items", ArrayList.class);
+ assertNotNull(items);
+ assertFalse(items.isEmpty());
+ assertEquals(10, items.size());
+ }
+
+ @Test
+ public void testLinkedList_String(){
+ Configuration config = ConfigurationProvider.getConfiguration();
+ LinkedList<String> items = config.get("base.items", new TypeLiteral<LinkedList<String>>(){});
+ assertNotNull(items);
+ assertFalse(items.isEmpty());
+ assertEquals(10, items.size());
+ items = (LinkedList<String>) config.get("base.items", LinkedList.class);
+ assertNotNull(items);
+ assertFalse(items.isEmpty());
+ assertEquals(10, items.size());
+ }
+
+ @Test
+ public void testSet_String(){
+ Configuration config = ConfigurationProvider.getConfiguration();
+ Set<String> items = config.get("base.items", new TypeLiteral<Set<String>>(){});
+ assertNotNull(items);
+ assertFalse(items.isEmpty());
+ assertEquals(10, items.size());
+ items = (Set<String>) config.get("base.items", Set.class);
+ assertNotNull(items);
+ assertFalse(items.isEmpty());
+ assertEquals(10, items.size());
+ }
+
+ @Test
+ public void testSortedSet_String(){
+ Configuration config = ConfigurationProvider.getConfiguration();
+ Set<String> items = config.get("base.items", new TypeLiteral<SortedSet<String>>(){});
+ assertNotNull(items);
+ assertFalse(items.isEmpty());
+ assertEquals(10, items.size());
+ items = (SortedSet<String>) config.get("base.items", SortedSet.class);
+ assertNotNull(items);
+ assertFalse(items.isEmpty());
+ assertEquals(10, items.size());
+ }
+
+ @Test
+ public void testHashSet_String(){
+ Configuration config = ConfigurationProvider.getConfiguration();
+ Set<String> items = config.get("base.items", new TypeLiteral<HashSet<String>>(){});
+ assertNotNull(items);
+ assertFalse(items.isEmpty());
+ assertEquals(10, items.size());
+ items = (HashSet<String>) config.get("base.items", HashSet.class);
+ assertNotNull(items);
+ assertFalse(items.isEmpty());
+ assertEquals(10, items.size());
+ }
+
+ @Test
+ public void testTreeSet_String(){
+ Configuration config = ConfigurationProvider.getConfiguration();
+ TreeSet<String> items = config.get("base.items", new TypeLiteral<TreeSet<String>>(){});
+ assertNotNull(items);
+ assertFalse(items.isEmpty());
+ assertEquals(10, items.size());
+ items = (TreeSet<String>) config.get("base.items", TreeSet.class);
+ assertNotNull(items);
+ assertFalse(items.isEmpty());
+ assertEquals(10, items.size());
+ }
+
+ @Test
+ public void testMap_String(){
+ Configuration config = ConfigurationProvider.getConfiguration();
+ Map<String,String> items = config.get("base.map", new TypeLiteral<Map<String,String>>(){});
+ assertNotNull(items);
+ assertFalse(items.isEmpty());
+ assertEquals(4, items.size());
+ assertEquals("a", items.get("1"));
+ assertEquals("b", items.get("2"));
+ assertEquals("c", items.get("3"));
+ assertEquals(" ", items.get("4"));
+ items = (Map<String,String>) config.get("base.map", Map.class);
+ assertNotNull(items);
+ assertFalse(items.isEmpty());
+ assertEquals(4, items.size());
+ assertEquals("a", items.get("1"));
+ assertEquals("b", items.get("2"));
+ assertEquals("c", items.get("3"));
+ assertEquals(" ", items.get("4"));
+ }
+
+ @Test
+ public void testHashMap_String(){
+ Configuration config = ConfigurationProvider.getConfiguration();
+ Map<String,String> items = config.get("base.map", new TypeLiteral<HashMap<String,String>>(){});
+ assertNotNull(items);
+ assertFalse(items.isEmpty());
+ assertEquals(4, items.size());
+ assertEquals("a", items.get("1"));
+ assertEquals("b", items.get("2"));
+ assertEquals("c", items.get("3"));
+ assertEquals(" ", items.get("4"));
+ items = (HashMap<String,String>) config.get("base.map", HashMap.class);
+ assertNotNull(items);
+ assertFalse(items.isEmpty());
+ assertEquals(4, items.size());
+ assertEquals("a", items.get("1"));
+ assertEquals("b", items.get("2"));
+ assertEquals("c", items.get("3"));
+ assertEquals(" ", items.get("4"));
+ }
+
+ @Test
+ public void testSortedMap_String(){
+ Configuration config = ConfigurationProvider.getConfiguration();
+ Map<String,String> items = config.get("base.map", new TypeLiteral<SortedMap<String,String>>(){});
+ assertNotNull(items);
+ assertFalse(items.isEmpty());
+ assertEquals(4, items.size());
+ assertEquals("a", items.get("1"));
+ assertEquals("b", items.get("2"));
+ assertEquals("c", items.get("3"));
+ assertEquals(" ", items.get("4"));
+ items = (Map<String,String>) config.get("base.map", SortedMap.class);
+ assertNotNull(items);
+ assertFalse(items.isEmpty());
+ assertEquals(4, items.size());
+ assertEquals("a", items.get("1"));
+ assertEquals("b", items.get("2"));
+ assertEquals("c", items.get("3"));
+ assertEquals(" ", items.get("4"));
+ }
+
+ @Test
+ public void testTreeMap_String(){
+ Configuration config = ConfigurationProvider.getConfiguration();
+ TreeMap<String,String> items = config.get("base.map", new TypeLiteral<TreeMap<String,String>>(){});
+ assertNotNull(items);
+ assertFalse(items.isEmpty());
+ assertEquals(4, items.size());
+ assertEquals("a", items.get("1"));
+ assertEquals("b", items.get("2"));
+ assertEquals("c", items.get("3"));
+ assertEquals(" ", items.get("4"));
+ items = config.get("base.map", TreeMap.class);
+ assertNotNull(items);
+ assertFalse(items.isEmpty());
+ assertEquals(4, items.size());
+ assertEquals("a", items.get("1"));
+ assertEquals("b", items.get("2"));
+ assertEquals("c", items.get("3"));
+ assertEquals(" ", items.get("4"));
+ }
+
+ @Test
+ public void testCollection_String(){
+ Configuration config = ConfigurationProvider.getConfiguration();
+ Collection<String> items = config.get("base.items", new TypeLiteral<Collection<String>>(){});
+ assertNotNull(items);
+ assertFalse(items.isEmpty());
+ assertEquals(10, items.size());
+ items = (Collection<String>) config.get("base.items", Collection.class);
+ assertNotNull(items);
+ assertFalse(items.isEmpty());
+ assertEquals(10, items.size());
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/314ad28d/modules/collections/src/test/java/org/apache/tamaya/collections/CollectionsTypedReadOnlyTests.java
----------------------------------------------------------------------
diff --git a/modules/collections/src/test/java/org/apache/tamaya/collections/CollectionsTypedReadOnlyTests.java b/modules/collections/src/test/java/org/apache/tamaya/collections/CollectionsTypedReadOnlyTests.java
new file mode 100644
index 0000000..7882512
--- /dev/null
+++ b/modules/collections/src/test/java/org/apache/tamaya/collections/CollectionsTypedReadOnlyTests.java
@@ -0,0 +1,173 @@
+/*
+ * 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.collections;
+
+import org.apache.tamaya.Configuration;
+import org.apache.tamaya.ConfigurationProvider;
+import org.apache.tamaya.TypeLiteral;
+import org.junit.Test;
+
+import java.util.*;
+
+import static junit.framework.TestCase.assertEquals;
+import static org.junit.Assert.*;
+
+/**
+ * Basic tests for Tamaya collection support. Relevant configs for this tests:
+ * <pre>base.items=1,2,3,4,5,6,7,8,9,0
+ * base.map=1::a, 2::b, 3::c, [4:: ]
+ * </pre>
+ */
+public class CollectionsTypedReadOnlyTests {
+
+ @Test(expected=UnsupportedOperationException.class)
+ public void testArrayListList_1(){
+ Configuration config = ConfigurationProvider.getConfiguration();
+ List<String> items = config.get("typed.arraylist", new TypeLiteral<List<String>>(){});
+ assertNotNull(items);
+ assertFalse(items.isEmpty());
+ assertEquals(10, items.size());
+ items.add("test");
+ }
+
+ @Test(expected=UnsupportedOperationException.class)
+ public void testArrayListList_2(){
+ Configuration config = ConfigurationProvider.getConfiguration();
+ List<String> items = (List<String>) config.get("typed.arraylist", List.class);
+ assertNotNull(items);
+ assertFalse(items.isEmpty());
+ assertEquals(10, items.size());
+ items.add("test");
+ }
+
+ @Test(expected=UnsupportedOperationException.class)
+ public void testLinkedListList_1(){
+ Configuration config = ConfigurationProvider.getConfiguration();
+ List<String> items = config.get("typed.linkedlist", new TypeLiteral<List<String>>(){});
+ assertNotNull(items);
+ assertFalse(items.isEmpty());
+ assertEquals(10, items.size());
+ items.add("test");
+ }
+
+ @Test(expected=UnsupportedOperationException.class)
+ public void testLinkedListList_2(){
+ Configuration config = ConfigurationProvider.getConfiguration();
+ List<String> items = (List<String>) config.get("typed.linkedlist", List.class);
+ assertNotNull(items);
+ assertFalse(items.isEmpty());
+ assertEquals(10, items.size());
+ items.add("test");
+ }
+
+
+ @Test(expected=UnsupportedOperationException.class)
+ public void testHashSet_1(){
+ Configuration config = ConfigurationProvider.getConfiguration();
+ Set<String> items = config.get("typed.hashset", new TypeLiteral<Set<String>>(){});
+ assertNotNull(items);
+ assertFalse(items.isEmpty());
+ assertEquals(10, items.size());
+ items.add("test");
+ }
+ @Test(expected=UnsupportedOperationException.class)
+ public void testHashSet_2(){
+ Configuration config = ConfigurationProvider.getConfiguration();
+ Set<String> items = (Set<String>) config.get("typed.hashset", Set.class);
+ assertNotNull(items);
+ assertFalse(items.isEmpty());
+ assertEquals(10, items.size());
+ items.add("test");
+ }
+
+ @Test(expected=UnsupportedOperationException.class)
+ public void testTreeSet_1(){
+ Configuration config = ConfigurationProvider.getConfiguration();
+ Set<String> items = config.get("typed.treeset", new TypeLiteral<Set<String>>(){});
+ assertNotNull(items);
+ assertFalse(items.isEmpty());
+ assertEquals(10, items.size());
+ items.add("test");
+ }
+ @Test(expected=UnsupportedOperationException.class)
+ public void testTreeSet_2(){
+ Configuration config = ConfigurationProvider.getConfiguration();
+ Set<String> items = items = (Set<String>) config.get("typed.treeset", Set.class);
+ assertNotNull(items);
+ assertFalse(items.isEmpty());
+ assertEquals(10, items.size());
+ items.add("test");
+ }
+
+ @Test(expected=UnsupportedOperationException.class)
+ public void testHashMap_1(){
+ Configuration config = ConfigurationProvider.getConfiguration();
+ Map<String,String> items = config.get("typed.hashmap", new TypeLiteral<Map<String,String>>(){});
+ assertNotNull(items);
+ assertFalse(items.isEmpty());
+ assertEquals(4, items.size());
+ assertEquals("a", items.get("1"));
+ assertEquals("b", items.get("2"));
+ assertEquals("c", items.get("3"));
+ assertEquals(" ", items.get("4"));
+ items.put("g","hjhhj");
+ }
+ @Test(expected=UnsupportedOperationException.class)
+ public void testHashMap_2(){
+ Configuration config = ConfigurationProvider.getConfiguration();
+ Map<String,String> items = (Map<String,String>) config.get("typed.hashmap", Map.class);
+ assertNotNull(items);
+ assertFalse(items.isEmpty());
+ assertEquals(4, items.size());
+ assertEquals("a", items.get("1"));
+ assertEquals("b", items.get("2"));
+ assertEquals("c", items.get("3"));
+ assertEquals(" ", items.get("4"));
+ items.put("g","hjhhj");
+ }
+
+
+ @Test(expected=UnsupportedOperationException.class)
+ public void testTreeMap_1(){
+ Configuration config = ConfigurationProvider.getConfiguration();
+ Map<String,String> items = config.get("typed.treemap", new TypeLiteral<Map<String,String>>(){});
+ assertNotNull(items);
+ assertFalse(items.isEmpty());
+ assertEquals(4, items.size());
+ assertEquals("a", items.get("1"));
+ assertEquals("b", items.get("2"));
+ assertEquals("c", items.get("3"));
+ assertEquals(" ", items.get("4"));
+ items.put("g","hjhhj");
+ }
+ @Test(expected=UnsupportedOperationException.class)
+ public void testTreeMap_2(){
+ Configuration config = ConfigurationProvider.getConfiguration();
+ Map<String,String> items = (Map<String,String>) config.get("typed.treemap", Map.class);
+ assertNotNull(items);
+ assertFalse(items.isEmpty());
+ assertEquals(4, items.size());
+ assertEquals("a", items.get("1"));
+ assertEquals("b", items.get("2"));
+ assertEquals("c", items.get("3"));
+ assertEquals(" ", items.get("4"));
+ items.put("g","hjhhj");
+ }
+
+}
[6/6] incubator-tamaya git commit: Moved collections module from
sandbox to modules.
Posted by an...@apache.org.
Moved collections module from sandbox to modules.
Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/commit/ebb7d90b
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/tree/ebb7d90b
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/diff/ebb7d90b
Branch: refs/heads/master
Commit: ebb7d90b0a7d63abd8d2012e0ac1383e4ec21f79
Parents: 03016f8
Author: anatole <an...@apache.org>
Authored: Sat Feb 27 22:40:03 2016 +0100
Committer: anatole <an...@apache.org>
Committed: Sat Feb 27 22:40:03 2016 +0100
----------------------------------------------------------------------
modules/collections/pom.xml | 2 +-
.../internal/AdaptiveCombinationPolicy.java | 7 +++----
.../collections/internal/ArrayListConverter.java | 4 +---
.../collections/internal/CollectionConverter.java | 10 +++++-----
.../internal/ConcurrentHashMapConverter.java | 4 +---
.../collections/internal/HashMapConverter.java | 3 +--
.../collections/internal/HashSetConverter.java | 5 +----
.../collections/internal/ItemTokenizer.java | 2 +-
.../collections/internal/LinkedListConverter.java | 3 +--
.../collections/internal/ListConverter.java | 6 +++---
.../tamaya/collections/internal/MapConverter.java | 11 +++++------
.../tamaya/collections/internal/SetConverter.java | 6 +++---
.../collections/internal/SortedMapConverter.java | 1 -
.../collections/internal/TreeMapConverter.java | 2 +-
.../collections/internal/TreeSetConverter.java | 3 +--
.../collections/CollectionAdvancedTests.java | 18 ++++++++++++++++++
16 files changed, 46 insertions(+), 41 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/ebb7d90b/modules/collections/pom.xml
----------------------------------------------------------------------
diff --git a/modules/collections/pom.xml b/modules/collections/pom.xml
index d5ed30b..45218d9 100644
--- a/modules/collections/pom.xml
+++ b/modules/collections/pom.xml
@@ -22,7 +22,7 @@ under the License.
<parent>
<groupId>org.apache.tamaya.ext</groupId>
- <artifactId>tamaya-sandbox</artifactId>
+ <artifactId>tamaya-extensions</artifactId>
<version>0.2-incubating-SNAPSHOT</version>
<relativePath>..</relativePath>
</parent>
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/ebb7d90b/modules/collections/src/main/java/org/apache/tamaya/collections/internal/AdaptiveCombinationPolicy.java
----------------------------------------------------------------------
diff --git a/modules/collections/src/main/java/org/apache/tamaya/collections/internal/AdaptiveCombinationPolicy.java b/modules/collections/src/main/java/org/apache/tamaya/collections/internal/AdaptiveCombinationPolicy.java
index d86abe7..c0e9b9a 100644
--- a/modules/collections/src/main/java/org/apache/tamaya/collections/internal/AdaptiveCombinationPolicy.java
+++ b/modules/collections/src/main/java/org/apache/tamaya/collections/internal/AdaptiveCombinationPolicy.java
@@ -49,7 +49,7 @@ public class AdaptiveCombinationPolicy implements PropertyValueCombinationPolicy
@Override
public Map<String, String> collect(Map<String, String> currentValue, String key, PropertySource propertySource) {
// check for default collection combination policies for lists, sets, maps etc.
- final String SEPARATOR = ConfigurationProvider.getConfiguration().getOrDefault('_' + key+".item-separator", ",");
+ final String separator = ConfigurationProvider.getConfiguration().getOrDefault('_' + key+".item-separator", ",");
PropertyValue newValue = propertySource.get(key);
if(newValue!=null){
Map<String,String> newMapValue = new HashMap<>();
@@ -59,7 +59,7 @@ public class AdaptiveCombinationPolicy implements PropertyValueCombinationPolicy
String oldVal = newMapValue.get(key);
newMapValue.putAll(newValue.getConfigEntries());
if(oldVal!=null){
- newMapValue.put(key,oldVal + SEPARATOR + newValue.getValue());
+ newMapValue.put(key,oldVal + separator + newValue.getValue());
}
return newMapValue;
}else{
@@ -114,8 +114,7 @@ public class AdaptiveCombinationPolicy implements PropertyValueCombinationPolicy
LOG.finest("Using custom combination policy "+adaptiveCombinationPolicyClass+" for " +
"key: " + key + "");
}
- }
- catch(Exception e){
+ } catch(Exception e){
LOG.log(Level.SEVERE, "Error loading configured PropertyValueCombinationPolicy for " +
"key: " + key + ", using default (overriding) policy.", e);
combinationPolicy = PropertyValueCombinationPolicy.DEFAULT_OVERRIDING_COLLECTOR;
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/ebb7d90b/modules/collections/src/main/java/org/apache/tamaya/collections/internal/ArrayListConverter.java
----------------------------------------------------------------------
diff --git a/modules/collections/src/main/java/org/apache/tamaya/collections/internal/ArrayListConverter.java b/modules/collections/src/main/java/org/apache/tamaya/collections/internal/ArrayListConverter.java
index 8281395..f337e26 100644
--- a/modules/collections/src/main/java/org/apache/tamaya/collections/internal/ArrayListConverter.java
+++ b/modules/collections/src/main/java/org/apache/tamaya/collections/internal/ArrayListConverter.java
@@ -18,8 +18,6 @@
*/
package org.apache.tamaya.collections.internal;
-import org.apache.tamaya.ConfigurationProvider;
-import org.apache.tamaya.TypeLiteral;
import org.apache.tamaya.spi.ConversionContext;
import org.apache.tamaya.spi.PropertyConverter;
@@ -36,7 +34,7 @@ public class ArrayListConverter implements PropertyConverter<ArrayList> {
private static final Logger LOG = Logger.getLogger(ArrayListConverter.class.getName());
/** The shared instance, used by other collection converters in this package.*/
- private static ArrayListConverter INSTANCE = new ArrayListConverter();
+ private static final ArrayListConverter INSTANCE = new ArrayListConverter();
/**
* Provide a shared instance, used by other collection converters in this package.
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/ebb7d90b/modules/collections/src/main/java/org/apache/tamaya/collections/internal/CollectionConverter.java
----------------------------------------------------------------------
diff --git a/modules/collections/src/main/java/org/apache/tamaya/collections/internal/CollectionConverter.java b/modules/collections/src/main/java/org/apache/tamaya/collections/internal/CollectionConverter.java
index 0d9a799..343610a 100644
--- a/modules/collections/src/main/java/org/apache/tamaya/collections/internal/CollectionConverter.java
+++ b/modules/collections/src/main/java/org/apache/tamaya/collections/internal/CollectionConverter.java
@@ -37,11 +37,6 @@ public class CollectionConverter implements PropertyConverter<Collection> {
}
Collection result = null;
switch(collectionType){
- case "List":
- case "ArrayList":
- default:
- result = ArrayListConverter.getInstance().convert(value, context);
- break;
case "LinkedList":
result = LinkedListConverter.getInstance().convert(value, context);
break;
@@ -53,6 +48,11 @@ public class CollectionConverter implements PropertyConverter<Collection> {
case "TreeSet":
result = TreeSetConverter.getInstance().convert(value, context);
break;
+ case "List":
+ case "ArrayList":
+ default:
+ result = ArrayListConverter.getInstance().convert(value, context);
+ break;
}
if(context.getConfiguration().getOrDefault('_' + context.getKey()+".read-only",
Boolean.class, Boolean.TRUE)){
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/ebb7d90b/modules/collections/src/main/java/org/apache/tamaya/collections/internal/ConcurrentHashMapConverter.java
----------------------------------------------------------------------
diff --git a/modules/collections/src/main/java/org/apache/tamaya/collections/internal/ConcurrentHashMapConverter.java b/modules/collections/src/main/java/org/apache/tamaya/collections/internal/ConcurrentHashMapConverter.java
index 131b41c..7770fcf 100644
--- a/modules/collections/src/main/java/org/apache/tamaya/collections/internal/ConcurrentHashMapConverter.java
+++ b/modules/collections/src/main/java/org/apache/tamaya/collections/internal/ConcurrentHashMapConverter.java
@@ -18,11 +18,9 @@
*/
package org.apache.tamaya.collections.internal;
-import org.apache.tamaya.TypeLiteral;
import org.apache.tamaya.spi.ConversionContext;
import org.apache.tamaya.spi.PropertyConverter;
-import java.util.HashMap;
import java.util.List;
import java.util.concurrent.ConcurrentHashMap;
import java.util.logging.Level;
@@ -35,7 +33,7 @@ public class ConcurrentHashMapConverter implements PropertyConverter<ConcurrentH
private static final Logger LOG = Logger.getLogger(ConcurrentHashMapConverter.class.getName());
/** The shared instance, used by other collection converters in this package.*/
- private static ConcurrentHashMapConverter INSTANCE = new ConcurrentHashMapConverter();
+ private static final ConcurrentHashMapConverter INSTANCE = new ConcurrentHashMapConverter();
/**
* Provide a shared instance, used by other collection converters in this package.
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/ebb7d90b/modules/collections/src/main/java/org/apache/tamaya/collections/internal/HashMapConverter.java
----------------------------------------------------------------------
diff --git a/modules/collections/src/main/java/org/apache/tamaya/collections/internal/HashMapConverter.java b/modules/collections/src/main/java/org/apache/tamaya/collections/internal/HashMapConverter.java
index 6a3ac97..4e405e3 100644
--- a/modules/collections/src/main/java/org/apache/tamaya/collections/internal/HashMapConverter.java
+++ b/modules/collections/src/main/java/org/apache/tamaya/collections/internal/HashMapConverter.java
@@ -18,7 +18,6 @@
*/
package org.apache.tamaya.collections.internal;
-import org.apache.tamaya.TypeLiteral;
import org.apache.tamaya.spi.ConversionContext;
import org.apache.tamaya.spi.PropertyConverter;
@@ -34,7 +33,7 @@ public class HashMapConverter implements PropertyConverter<HashMap> {
private static final Logger LOG = Logger.getLogger(HashMapConverter.class.getName());
/** The shared instance, used by other collection converters in this package.*/
- private static HashMapConverter INSTANCE = new HashMapConverter();
+ private static final HashMapConverter INSTANCE = new HashMapConverter();
/**
* Provide a shared instance, used by other collection converters in this package.
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/ebb7d90b/modules/collections/src/main/java/org/apache/tamaya/collections/internal/HashSetConverter.java
----------------------------------------------------------------------
diff --git a/modules/collections/src/main/java/org/apache/tamaya/collections/internal/HashSetConverter.java b/modules/collections/src/main/java/org/apache/tamaya/collections/internal/HashSetConverter.java
index 40b204f..dab1b82 100644
--- a/modules/collections/src/main/java/org/apache/tamaya/collections/internal/HashSetConverter.java
+++ b/modules/collections/src/main/java/org/apache/tamaya/collections/internal/HashSetConverter.java
@@ -18,13 +18,10 @@
*/
package org.apache.tamaya.collections.internal;
-import org.apache.tamaya.TypeLiteral;
import org.apache.tamaya.spi.ConversionContext;
import org.apache.tamaya.spi.PropertyConverter;
-import java.util.ArrayList;
import java.util.HashSet;
-import java.util.LinkedList;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
@@ -37,7 +34,7 @@ public class HashSetConverter implements PropertyConverter<HashSet> {
private static final Logger LOG = Logger.getLogger(HashSetConverter.class.getName());
/** The shared instance, used by other collection converters in this package.*/
- private static HashSetConverter INSTANCE = new HashSetConverter();
+ private static final HashSetConverter INSTANCE = new HashSetConverter();
/**
* Provide a shared instance, used by other collection converters in this package.
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/ebb7d90b/modules/collections/src/main/java/org/apache/tamaya/collections/internal/ItemTokenizer.java
----------------------------------------------------------------------
diff --git a/modules/collections/src/main/java/org/apache/tamaya/collections/internal/ItemTokenizer.java b/modules/collections/src/main/java/org/apache/tamaya/collections/internal/ItemTokenizer.java
index 7d213a4..658131f 100644
--- a/modules/collections/src/main/java/org/apache/tamaya/collections/internal/ItemTokenizer.java
+++ b/modules/collections/src/main/java/org/apache/tamaya/collections/internal/ItemTokenizer.java
@@ -67,7 +67,7 @@ final class ItemTokenizer {
int start = 0;
int end = value.indexOf(separator,start);
while(end>0) {
- if (end>0 && (value.charAt(end - 1) != '\\')) {
+ if (value.charAt(end - 1) != '\\') {
result.add(value.substring(start, end));
start = end + separator.length();
end = value.indexOf(separator,start);
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/ebb7d90b/modules/collections/src/main/java/org/apache/tamaya/collections/internal/LinkedListConverter.java
----------------------------------------------------------------------
diff --git a/modules/collections/src/main/java/org/apache/tamaya/collections/internal/LinkedListConverter.java b/modules/collections/src/main/java/org/apache/tamaya/collections/internal/LinkedListConverter.java
index 4389a54..2d35644 100644
--- a/modules/collections/src/main/java/org/apache/tamaya/collections/internal/LinkedListConverter.java
+++ b/modules/collections/src/main/java/org/apache/tamaya/collections/internal/LinkedListConverter.java
@@ -18,7 +18,6 @@
*/
package org.apache.tamaya.collections.internal;
-import org.apache.tamaya.TypeLiteral;
import org.apache.tamaya.spi.ConversionContext;
import org.apache.tamaya.spi.PropertyConverter;
@@ -34,7 +33,7 @@ public class LinkedListConverter implements PropertyConverter<LinkedList> {
private static final Logger LOG = Logger.getLogger(LinkedListConverter.class.getName());
/** The shared instance, used by other collection converters in this package.*/
- private static LinkedListConverter INSTANCE = new LinkedListConverter();
+ private static final LinkedListConverter INSTANCE = new LinkedListConverter();
/**
* Provide a shared instance, used by other collection converters in this package.
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/ebb7d90b/modules/collections/src/main/java/org/apache/tamaya/collections/internal/ListConverter.java
----------------------------------------------------------------------
diff --git a/modules/collections/src/main/java/org/apache/tamaya/collections/internal/ListConverter.java b/modules/collections/src/main/java/org/apache/tamaya/collections/internal/ListConverter.java
index 65fc54e..64917f2 100644
--- a/modules/collections/src/main/java/org/apache/tamaya/collections/internal/ListConverter.java
+++ b/modules/collections/src/main/java/org/apache/tamaya/collections/internal/ListConverter.java
@@ -37,14 +37,14 @@ public class ListConverter implements PropertyConverter<List> {
}
List result = null;
switch(collectionType){
+ case "LinkedList":
+ result = LinkedListConverter.getInstance().convert(value, context);
+ break;
case "List":
case "ArrayList":
default:
result = ArrayListConverter.getInstance().convert(value, context);
break;
- case "LinkedList":
- result = LinkedListConverter.getInstance().convert(value, context);
- break;
}
if(context.getConfiguration().getOrDefault('_' + context.getKey()+".read-only",
Boolean.class, Boolean.TRUE)){
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/ebb7d90b/modules/collections/src/main/java/org/apache/tamaya/collections/internal/MapConverter.java
----------------------------------------------------------------------
diff --git a/modules/collections/src/main/java/org/apache/tamaya/collections/internal/MapConverter.java b/modules/collections/src/main/java/org/apache/tamaya/collections/internal/MapConverter.java
index 606e14f..8b9287e 100644
--- a/modules/collections/src/main/java/org/apache/tamaya/collections/internal/MapConverter.java
+++ b/modules/collections/src/main/java/org/apache/tamaya/collections/internal/MapConverter.java
@@ -23,7 +23,6 @@ import org.apache.tamaya.spi.PropertyConverter;
import java.util.Collections;
import java.util.Map;
-import java.util.Set;
/**
* PropertyConverter for gnerating HashMap representation of a values.
@@ -38,17 +37,17 @@ public class MapConverter implements PropertyConverter<Map> {
}
Map result = null;
switch(collectionType){
- case "Map":
- case "HashMap":
- default:
- result = HashMapConverter.getInstance().convert(value, context);
- break;
case "TreeMap":
result = TreeMapConverter.getInstance().convert(value, context);
break;
case "ConcurrentHashMap":
result = ConcurrentHashMapConverter.getInstance().convert(value, context);
break;
+ case "Map":
+ case "HashMap":
+ default:
+ result = HashMapConverter.getInstance().convert(value, context);
+ break;
}
if(context.getConfiguration().getOrDefault('_' + context.getKey()+".read-only",
Boolean.class, Boolean.TRUE)){
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/ebb7d90b/modules/collections/src/main/java/org/apache/tamaya/collections/internal/SetConverter.java
----------------------------------------------------------------------
diff --git a/modules/collections/src/main/java/org/apache/tamaya/collections/internal/SetConverter.java b/modules/collections/src/main/java/org/apache/tamaya/collections/internal/SetConverter.java
index 75301bc..d4fe1c6 100644
--- a/modules/collections/src/main/java/org/apache/tamaya/collections/internal/SetConverter.java
+++ b/modules/collections/src/main/java/org/apache/tamaya/collections/internal/SetConverter.java
@@ -37,14 +37,14 @@ public class SetConverter implements PropertyConverter<Set> {
}
Set result = null;
switch(collectionType){
+ case "TreeSet":
+ result = TreeSetConverter.getInstance().convert(value, context);
+ break;
case "Set":
case "HashSet":
default:
result = HashSetConverter.getInstance().convert(value, context);
break;
- case "TreeSet":
- result = TreeSetConverter.getInstance().convert(value, context);
- break;
}
if(context.getConfiguration().getOrDefault('_' + context.getKey()+".read-only",
Boolean.class, Boolean.TRUE)){
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/ebb7d90b/modules/collections/src/main/java/org/apache/tamaya/collections/internal/SortedMapConverter.java
----------------------------------------------------------------------
diff --git a/modules/collections/src/main/java/org/apache/tamaya/collections/internal/SortedMapConverter.java b/modules/collections/src/main/java/org/apache/tamaya/collections/internal/SortedMapConverter.java
index 1015751..c87006d 100644
--- a/modules/collections/src/main/java/org/apache/tamaya/collections/internal/SortedMapConverter.java
+++ b/modules/collections/src/main/java/org/apache/tamaya/collections/internal/SortedMapConverter.java
@@ -23,7 +23,6 @@ import org.apache.tamaya.spi.PropertyConverter;
import java.util.Collections;
import java.util.SortedMap;
-import java.util.SortedSet;
/**
* PropertyConverter for gnerating a LIST representation of values.
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/ebb7d90b/modules/collections/src/main/java/org/apache/tamaya/collections/internal/TreeMapConverter.java
----------------------------------------------------------------------
diff --git a/modules/collections/src/main/java/org/apache/tamaya/collections/internal/TreeMapConverter.java b/modules/collections/src/main/java/org/apache/tamaya/collections/internal/TreeMapConverter.java
index fef25fe..c8a7c3a 100644
--- a/modules/collections/src/main/java/org/apache/tamaya/collections/internal/TreeMapConverter.java
+++ b/modules/collections/src/main/java/org/apache/tamaya/collections/internal/TreeMapConverter.java
@@ -34,7 +34,7 @@ public class TreeMapConverter implements PropertyConverter<TreeMap> {
private static final Logger LOG = Logger.getLogger(HashMapConverter.class.getName());
/** The shared instance, used by other collection converters in this package.*/
- private static TreeMapConverter INSTANCE = new TreeMapConverter();
+ private static final TreeMapConverter INSTANCE = new TreeMapConverter();
/**
* Provide a shared instance, used by other collection converters in this package.
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/ebb7d90b/modules/collections/src/main/java/org/apache/tamaya/collections/internal/TreeSetConverter.java
----------------------------------------------------------------------
diff --git a/modules/collections/src/main/java/org/apache/tamaya/collections/internal/TreeSetConverter.java b/modules/collections/src/main/java/org/apache/tamaya/collections/internal/TreeSetConverter.java
index 9206f07..399a07b 100644
--- a/modules/collections/src/main/java/org/apache/tamaya/collections/internal/TreeSetConverter.java
+++ b/modules/collections/src/main/java/org/apache/tamaya/collections/internal/TreeSetConverter.java
@@ -18,7 +18,6 @@
*/
package org.apache.tamaya.collections.internal;
-import org.apache.tamaya.TypeLiteral;
import org.apache.tamaya.spi.ConversionContext;
import org.apache.tamaya.spi.PropertyConverter;
@@ -35,7 +34,7 @@ public class TreeSetConverter implements PropertyConverter<TreeSet> {
private static final Logger LOG = Logger.getLogger(TreeSetConverter.class.getName());
/** The shared instance, used by other collection converters in this package.*/
- private static TreeSetConverter INSTANCE = new TreeSetConverter();
+ private static final TreeSetConverter INSTANCE = new TreeSetConverter();
/**
* Provide a shared instance, used by other collection converters in this package.
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/ebb7d90b/modules/collections/src/test/java/org/apache/tamaya/collections/CollectionAdvancedTests.java
----------------------------------------------------------------------
diff --git a/modules/collections/src/test/java/org/apache/tamaya/collections/CollectionAdvancedTests.java b/modules/collections/src/test/java/org/apache/tamaya/collections/CollectionAdvancedTests.java
index ddabb23..43f1f4f 100644
--- a/modules/collections/src/test/java/org/apache/tamaya/collections/CollectionAdvancedTests.java
+++ b/modules/collections/src/test/java/org/apache/tamaya/collections/CollectionAdvancedTests.java
@@ -1,3 +1,21 @@
+/*
+ * 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.collections;
import org.apache.tamaya.Configuration;
[2/6] incubator-tamaya git commit: Moved collections module into
active modules folder.
Posted by an...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/314ad28d/modules/collections/src/test/java/org/apache/tamaya/collections/CollectionsTypedTests.java
----------------------------------------------------------------------
diff --git a/modules/collections/src/test/java/org/apache/tamaya/collections/CollectionsTypedTests.java b/modules/collections/src/test/java/org/apache/tamaya/collections/CollectionsTypedTests.java
new file mode 100644
index 0000000..b4e4d52
--- /dev/null
+++ b/modules/collections/src/test/java/org/apache/tamaya/collections/CollectionsTypedTests.java
@@ -0,0 +1,208 @@
+/*
+ * 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.collections;
+
+import org.apache.tamaya.Configuration;
+import org.apache.tamaya.ConfigurationProvider;
+import org.apache.tamaya.TypeLiteral;
+import org.junit.Test;
+
+import java.util.*;
+
+import static junit.framework.TestCase.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+/**
+ * Basic tests for Tamaya collection support. Relevant configs for this tests:
+ * <pre>base.items=1,2,3,4,5,6,7,8,9,0
+ * base.map=1::a, 2::b, 3::c, [4:: ]
+ * </pre>
+ */
+public class CollectionsTypedTests {
+
+ @Test
+ public void testArrayListList_String(){
+ Configuration config = ConfigurationProvider.getConfiguration();
+ List<String> items = config.get("typed2.arraylist", new TypeLiteral<List<String>>(){});
+ assertNotNull(items);
+ assertFalse(items.isEmpty());
+ assertEquals(10, items.size());
+ assertTrue(items instanceof ArrayList);
+ items = (List<String>) config.get("typed2.arraylist", List.class);
+ assertNotNull(items);
+ assertFalse(items.isEmpty());
+ assertEquals(10, items.size());
+ assertTrue(items instanceof ArrayList);
+ }
+
+ @Test
+ public void testLinkedListList_String(){
+ Configuration config = ConfigurationProvider.getConfiguration();
+ List<String> items = config.get("typed2.linkedlist", new TypeLiteral<List<String>>(){});
+ assertNotNull(items);
+ assertFalse(items.isEmpty());
+ assertEquals(10, items.size());
+ assertTrue(items instanceof LinkedList);
+ items = (List<String>) config.get("typed2.linkedlist", List.class);
+ assertNotNull(items);
+ assertFalse(items.isEmpty());
+ assertEquals(10, items.size());
+ assertTrue(items instanceof LinkedList);
+ }
+
+
+ @Test
+ public void testHashSet_String(){
+ Configuration config = ConfigurationProvider.getConfiguration();
+ Set<String> items = config.get("typed2.hashset", new TypeLiteral<Set<String>>(){});
+ assertNotNull(items);
+ assertFalse(items.isEmpty());
+ assertEquals(10, items.size());
+ assertTrue(items instanceof HashSet);
+ items = (Set<String>) config.get("typed2.hashset", Set.class);
+ assertNotNull(items);
+ assertFalse(items.isEmpty());
+ assertEquals(10, items.size());
+ assertTrue(items instanceof HashSet);
+ }
+
+ @Test
+ public void testTreeSet_String(){
+ Configuration config = ConfigurationProvider.getConfiguration();
+ Set<String> items = config.get("typed2.treeset", new TypeLiteral<Set<String>>(){});
+ assertNotNull(items);
+ assertFalse(items.isEmpty());
+ assertEquals(10, items.size());
+ assertTrue(items instanceof TreeSet);
+ items = (Set<String>) config.get("typed2.treeset", Set.class);
+ assertNotNull(items);
+ assertFalse(items.isEmpty());
+ assertEquals(10, items.size());
+ assertTrue(items instanceof TreeSet);
+ }
+
+ @Test
+ public void testHashMap_String(){
+ Configuration config = ConfigurationProvider.getConfiguration();
+ Map<String,String> items = config.get("typed2.hashmap", new TypeLiteral<Map<String,String>>(){});
+ assertNotNull(items);
+ assertFalse(items.isEmpty());
+ assertEquals(4, items.size());
+ assertEquals("a", items.get("1"));
+ assertEquals("b", items.get("2"));
+ assertEquals("c", items.get("3"));
+ assertEquals(" ", items.get("4"));
+ assertTrue(items instanceof HashMap);
+ items = (Map<String,String>) config.get("typed2.hashmap", Map.class);
+ assertNotNull(items);
+ assertFalse(items.isEmpty());
+ assertEquals(4, items.size());
+ assertEquals("a", items.get("1"));
+ assertEquals("b", items.get("2"));
+ assertEquals("c", items.get("3"));
+ assertEquals(" ", items.get("4"));
+ assertTrue(items instanceof HashMap);
+ }
+
+ @Test
+ public void testTreeMap_String(){
+ Configuration config = ConfigurationProvider.getConfiguration();
+ Map<String,String> items = config.get("typed2.treemap", new TypeLiteral<Map<String,String>>(){});
+ assertNotNull(items);
+ assertFalse(items.isEmpty());
+ assertEquals(4, items.size());
+ assertEquals("a", items.get("1"));
+ assertEquals("b", items.get("2"));
+ assertEquals("c", items.get("3"));
+ assertEquals(" ", items.get("4"));
+ assertTrue(items instanceof TreeMap);
+ items = (Map<String,String>) config.get("typed2.treemap", Map.class);
+ assertNotNull(items);
+ assertFalse(items.isEmpty());
+ assertEquals(4, items.size());
+ assertEquals("a", items.get("1"));
+ assertEquals("b", items.get("2"));
+ assertEquals("c", items.get("3"));
+ assertEquals(" ", items.get("4"));
+ assertTrue(items instanceof TreeMap);
+ }
+
+ @Test
+ public void testCollection_HashSet(){
+ Configuration config = ConfigurationProvider.getConfiguration();
+ Collection<String> items = config.get("typed2.hashset", new TypeLiteral<Collection<String>>(){});
+ assertNotNull(items);
+ assertFalse(items.isEmpty());
+ assertEquals(10, items.size());
+ assertTrue(items instanceof HashSet);
+ items = (Collection<String>) config.get("typed2.hashset", Collection.class);
+ assertNotNull(items);
+ assertFalse(items.isEmpty());
+ assertEquals(10, items.size());
+ assertTrue(items instanceof HashSet);
+ }
+
+ @Test
+ public void testCollection_TreeSet(){
+ Configuration config = ConfigurationProvider.getConfiguration();
+ Collection<String> items = config.get("typed2.treeset", new TypeLiteral<Collection<String>>(){});
+ assertNotNull(items);
+ assertFalse(items.isEmpty());
+ assertEquals(10, items.size());
+ assertTrue(items instanceof TreeSet);
+ items = (Collection<String>) config.get("typed2.treeset", Collection.class);
+ assertNotNull(items);
+ assertFalse(items.isEmpty());
+ assertEquals(10, items.size());
+ assertTrue(items instanceof TreeSet);
+ }
+
+ @Test
+ public void testCollection_ArrayList(){
+ Configuration config = ConfigurationProvider.getConfiguration();
+ Collection<String> items = config.get("typed2.arraylist", new TypeLiteral<Collection<String>>(){});
+ assertNotNull(items);
+ assertFalse(items.isEmpty());
+ assertEquals(10, items.size());
+ assertTrue(items instanceof ArrayList);
+ items = (Collection<String>) config.get("typed2.arraylist", Collection.class);
+ assertNotNull(items);
+ assertFalse(items.isEmpty());
+ assertEquals(10, items.size());
+ assertTrue(items instanceof ArrayList);
+ }
+
+ @Test
+ public void testCollection_LinkedList(){
+ Configuration config = ConfigurationProvider.getConfiguration();
+ Collection<String> items = config.get("typed2.linkedlist", new TypeLiteral<Collection<String>>(){});
+ assertNotNull(items);
+ assertFalse(items.isEmpty());
+ assertEquals(10, items.size());
+ assertTrue(items instanceof LinkedList);
+ items = (Collection<String>) config.get("typed2.linkedlist", Collection.class);
+ assertNotNull(items);
+ assertFalse(items.isEmpty());
+ assertEquals(10, items.size());
+ assertTrue(items instanceof LinkedList);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/314ad28d/modules/collections/src/test/java/org/apache/tamaya/collections/MyUpperCaseConverter.java
----------------------------------------------------------------------
diff --git a/modules/collections/src/test/java/org/apache/tamaya/collections/MyUpperCaseConverter.java b/modules/collections/src/test/java/org/apache/tamaya/collections/MyUpperCaseConverter.java
new file mode 100644
index 0000000..1c95261
--- /dev/null
+++ b/modules/collections/src/test/java/org/apache/tamaya/collections/MyUpperCaseConverter.java
@@ -0,0 +1,33 @@
+/*
+ * 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.collections;
+
+import org.apache.tamaya.spi.ConversionContext;
+import org.apache.tamaya.spi.PropertyConverter;
+
+/**
+ * Example converter that is used for testing the custom parsing functionality. It sorrounds values with () and
+ * converts them to uppercase.
+ */
+public class MyUpperCaseConverter implements PropertyConverter<String>{
+ @Override
+ public String convert(String value, ConversionContext context) {
+ return "("+value.toUpperCase()+")";
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/314ad28d/modules/collections/src/test/resources/META-INF/javaconfiguration.properties
----------------------------------------------------------------------
diff --git a/modules/collections/src/test/resources/META-INF/javaconfiguration.properties b/modules/collections/src/test/resources/META-INF/javaconfiguration.properties
new file mode 100644
index 0000000..e9a234c
--- /dev/null
+++ b/modules/collections/src/test/resources/META-INF/javaconfiguration.properties
@@ -0,0 +1,73 @@
+#
+# 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.
+#
+# Similar to etcd all keys starting with a _ are hidden by default (only directly accessible).
+
+# Config for base tests (no combination policy)
+base.items=1,2,3,4,5,6,7,8,9,0
+base.map=1::a, 2::b, 3::c, [4:: ]
+
+# Config for tests with explcit implementation types
+typed2.arraylist=1,2,3,4,5,6,7,8,9,0
+_typed2.arraylist.collection-type=ArrayList
+_typed2.arraylist.read-only=false
+typed2.linkedlist=1,2,3,4,5,6,7,8,9,0
+_typed2.linkedlist.collection-type=java.util.LinkedList
+_typed2.linkedlist.read-only=false
+typed2.hashset=1,2,3,4,5,6,7,8,9,0
+_typed2.hashset.collection-type=HashSet
+_typed2.hashset.read-only=false
+typed2.treeset=1,2,3,4,5,6,7,8,9,0
+_typed2.treeset.collection-type=TreeSet
+_typed2.treeset.read-only=false
+typed2.hashmap=1::a, 2::b, 3::c, [4:: ]
+_typed2.hashmap.collection-type=java.util.HashMap
+_typed2.hashmap.read-only=false
+typed2.treemap=1::a, 2::b, 3::c, [4:: ]
+_typed2.treemap.collection-type=TreeMap
+_typed2.treemap.read-only=false
+
+# Config for tests with combination policy, writable
+typed.arraylist=1,2,3,4,5,6,7,8,9,0
+_typed.arraylist.collection-type=ArrayList
+typed.linkedlist=1,2,3,4,5,6,7,8,9,0
+_typed.linkedlist.collection-type=java.util.LinkedList
+typed.hashset=1,2,3,4,5,6,7,8,9,0
+_typed.hashset.collection-type=HashSet
+typed.treeset=1,2,3,4,5,6,7,8,9,0
+_typed.treeset.collection-type=TreeSet
+typed.hashmap=1::a, 2::b, 3::c, [4:: ]
+_typed.hashmap.collection-type=java.util.HashMap
+typed.treemap=1::a, 2::b, 3::c, [4:: ]
+_typed.treemap.collection-type=TreeMap
+
+# Config for advanced tests
+sep-list=a,b,c|d,e,f|g,h,i
+_sep-list.collection-type=List
+_sep-list.item-separator=|
+currency-list=CHF,USD,USS
+_currency-list.collection-type=List
+
+parser-list=a,b,c
+_parser-list.collection-type=List
+_parser-list.item-converter=org.apache.tamaya.collections.MyUpperCaseConverter
+
+redefined-map=0==none | 1==single | 2==any
+_redefined-map.map-entry-separator===
+_redefined-map.item-separator=|
+
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/314ad28d/sandbox/collections/pom.xml
----------------------------------------------------------------------
diff --git a/sandbox/collections/pom.xml b/sandbox/collections/pom.xml
deleted file mode 100644
index d5ed30b..0000000
--- a/sandbox/collections/pom.xml
+++ /dev/null
@@ -1,75 +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-sandbox</artifactId>
- <version>0.2-incubating-SNAPSHOT</version>
- <relativePath>..</relativePath>
- </parent>
-
- <artifactId>tamaya-collections</artifactId>
- <name>Apache Tamaya Modules - Collections Support</name>
- <packaging>bundle</packaging>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.tamaya</groupId>
- <artifactId>tamaya-core</artifactId>
- <version>${project.version}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.tamaya</groupId>
- <artifactId>tamaya-api</artifactId>
- <version>${project.version}</version>
- </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>
- <Import-Package>
- org.apache.tamaya,
- org.apache.tamaya.spi,
- javax.annotation,
- *
- </Import-Package>
- <Private-Package>
- org.apache.tamaya.collections.internal
- </Private-Package>
- </instructions>
- </configuration>
- </plugin>
- </plugins>
- </build>
-
-</project>
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/314ad28d/sandbox/collections/src/main/java/org/apache/tamaya/collections/internal/AdaptiveCombinationPolicy.java
----------------------------------------------------------------------
diff --git a/sandbox/collections/src/main/java/org/apache/tamaya/collections/internal/AdaptiveCombinationPolicy.java b/sandbox/collections/src/main/java/org/apache/tamaya/collections/internal/AdaptiveCombinationPolicy.java
deleted file mode 100644
index 3234e37..0000000
--- a/sandbox/collections/src/main/java/org/apache/tamaya/collections/internal/AdaptiveCombinationPolicy.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.collections.internal;
-
-import org.apache.tamaya.ConfigurationProvider;
-import org.apache.tamaya.spi.PropertySource;
-import org.apache.tamaya.spi.PropertyValue;
-import org.apache.tamaya.spi.PropertyValueCombinationPolicy;
-
-import javax.annotation.Priority;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-/**
- * PropertyValueCombinationPolicy that allows to configure a PropertyValueCombinationPolicy for each key
- * individually, by adding a configured entry of the form
- * {@code _key.combination-policy=collect|override|fqPolicyClassName}.
- */
-@Priority(100)
-public class AdaptiveCombinationPolicy implements PropertyValueCombinationPolicy {
- /** Logger. */
- private static final Logger LOG = Logger.getLogger(AdaptiveCombinationPolicy.class.getName());
-
- /**
- * Collecting combination policy using (optional) {@code item-separator} parameter for determining the sparator
- * to combine multiple config entries found.
- */
- private static final PropertyValueCombinationPolicy COLLECTING_POLICY = new PropertyValueCombinationPolicy(){
- @Override
- public Map<String, String> collect(Map<String, String> currentValue, String key, PropertySource propertySource) {
- // check for default collection combination policies for lists, sets, maps etc.
- final String SEPARATOR = ConfigurationProvider.getConfiguration().getOrDefault('_' + key+".item-separator", ",");
- PropertyValue newValue = propertySource.get(key);
- if(newValue!=null){
- Map<String,String> newMapValue = new HashMap<>();
- if(currentValue!=null){
- newMapValue.putAll(currentValue);
- }
- String oldVal = newMapValue.get(key);
- newMapValue.putAll(newValue.getConfigEntries());
- if(oldVal!=null){
- newMapValue.put(key,oldVal + SEPARATOR + newValue.getValue());
- }
- return newMapValue;
- }else{
- if(currentValue!=null){
- return currentValue;
- }
- return Collections.emptyMap();
- }
- }
- };
-
- /** Cache for loaded custom combination policies. */
- private Map<Class, PropertyValueCombinationPolicy> configuredPolicies = new ConcurrentHashMap<>();
-
- @Override
- public Map<String,String> collect(Map<String,String> currentValue, String key, PropertySource propertySource){
- if(key.startsWith("_")){
- PropertyValue newValue = propertySource.get(key);
- if(newValue!=null){
- return newValue.getConfigEntries();
- }
- return currentValue;
- }
- String adaptiveCombinationPolicyClass = ConfigurationProvider.getConfiguration().getOrDefault(
- '_' + key+".combination-policy", "override");
- PropertyValueCombinationPolicy combinationPolicy = null;
- switch(adaptiveCombinationPolicyClass){
- case "collect":
- case "COLLECT":
- if(LOG.isLoggable(Level.FINEST)){
- LOG.finest("Using collecting combination policy for key: " + key + ".");
- }
- combinationPolicy = COLLECTING_POLICY;
- break;
- case "override":
- case "OVERRIDE":
- if(LOG.isLoggable(Level.FINEST)){
- LOG.finest("Using default (overriding) combination policy for key: " + key + ".");
- }
- combinationPolicy = PropertyValueCombinationPolicy.DEFAULT_OVERRIDING_COLLECTOR;
- break;
- default:
- try{
- Class<PropertyValueCombinationPolicy> clazz = (Class<PropertyValueCombinationPolicy>)
- Class.forName(adaptiveCombinationPolicyClass);
- combinationPolicy = configuredPolicies.get(clazz);
- if(combinationPolicy==null){
- combinationPolicy = clazz.newInstance();
- configuredPolicies.put(clazz, combinationPolicy);
- }
- if(LOG.isLoggable(Level.FINEST)){
- LOG.finest("Using custom combination policy "+adaptiveCombinationPolicyClass+" for " +
- "key: " + key + ".");
- }
- }
- catch(Exception e){
- LOG.log(Level.SEVERE, "Error loading configured PropertyValueCombinationPolicy for " +
- "key: " + key + ", using default (overriding) policy.", e);
- combinationPolicy = PropertyValueCombinationPolicy.DEFAULT_OVERRIDING_COLLECTOR;
- }
- }
- return combinationPolicy.collect(currentValue, key, propertySource);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/314ad28d/sandbox/collections/src/main/java/org/apache/tamaya/collections/internal/ArrayListConverter.java
----------------------------------------------------------------------
diff --git a/sandbox/collections/src/main/java/org/apache/tamaya/collections/internal/ArrayListConverter.java b/sandbox/collections/src/main/java/org/apache/tamaya/collections/internal/ArrayListConverter.java
deleted file mode 100644
index 8281395..0000000
--- a/sandbox/collections/src/main/java/org/apache/tamaya/collections/internal/ArrayListConverter.java
+++ /dev/null
@@ -1,64 +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.collections.internal;
-
-import org.apache.tamaya.ConfigurationProvider;
-import org.apache.tamaya.TypeLiteral;
-import org.apache.tamaya.spi.ConversionContext;
-import org.apache.tamaya.spi.PropertyConverter;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-/**
- * PropertyConverter for gnerating ArrayList representation of a values.
- */
-public class ArrayListConverter implements PropertyConverter<ArrayList> {
-
- private static final Logger LOG = Logger.getLogger(ArrayListConverter.class.getName());
-
- /** The shared instance, used by other collection converters in this package.*/
- private static ArrayListConverter INSTANCE = new ArrayListConverter();
-
- /**
- * Provide a shared instance, used by other collection converters in this package.
- * @return the shared instance, never null.
- */
- static ArrayListConverter getInstance(){
- return INSTANCE;
- }
-
- @Override
- public ArrayList convert(String value, ConversionContext context) {
- List<String> rawList = ItemTokenizer.split(value, context);
- ArrayList<Object> mlist = new ArrayList<>();
- for(String raw:rawList){
- Object convValue = ItemTokenizer.convertValue(raw, context);
- if (convValue != null) {
- mlist.add(convValue);
- }else{
- LOG.log(Level.SEVERE, "Failed to convert collection value type for '"+raw+"'.");
- }
- }
- return mlist;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/314ad28d/sandbox/collections/src/main/java/org/apache/tamaya/collections/internal/CollectionConverter.java
----------------------------------------------------------------------
diff --git a/sandbox/collections/src/main/java/org/apache/tamaya/collections/internal/CollectionConverter.java b/sandbox/collections/src/main/java/org/apache/tamaya/collections/internal/CollectionConverter.java
deleted file mode 100644
index 0d9a799..0000000
--- a/sandbox/collections/src/main/java/org/apache/tamaya/collections/internal/CollectionConverter.java
+++ /dev/null
@@ -1,63 +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.collections.internal;
-
-import org.apache.tamaya.spi.ConversionContext;
-import org.apache.tamaya.spi.PropertyConverter;
-
-import java.util.Collection;
-import java.util.Collections;
-
-/**
- * PropertyConverter for gnerating a LIST representation of values.
- */
-public class CollectionConverter implements PropertyConverter<Collection> {
-
- @Override
- public Collection convert(String value, ConversionContext context) {
- String collectionType = context.getConfiguration().getOrDefault('_' + context.getKey()+".collection-type", "List");
- if(collectionType.startsWith("java.util.")){
- collectionType = collectionType.substring("java.util.".length());
- }
- Collection result = null;
- switch(collectionType){
- case "List":
- case "ArrayList":
- default:
- result = ArrayListConverter.getInstance().convert(value, context);
- break;
- case "LinkedList":
- result = LinkedListConverter.getInstance().convert(value, context);
- break;
- case "Set":
- case "HashSet":
- result = HashSetConverter.getInstance().convert(value, context);
- break;
- case "SortedSet":
- case "TreeSet":
- result = TreeSetConverter.getInstance().convert(value, context);
- break;
- }
- if(context.getConfiguration().getOrDefault('_' + context.getKey()+".read-only",
- Boolean.class, Boolean.TRUE)){
- return Collections.unmodifiableCollection(result);
- }
- return result;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/314ad28d/sandbox/collections/src/main/java/org/apache/tamaya/collections/internal/ConcurrentHashMapConverter.java
----------------------------------------------------------------------
diff --git a/sandbox/collections/src/main/java/org/apache/tamaya/collections/internal/ConcurrentHashMapConverter.java b/sandbox/collections/src/main/java/org/apache/tamaya/collections/internal/ConcurrentHashMapConverter.java
deleted file mode 100644
index 131b41c..0000000
--- a/sandbox/collections/src/main/java/org/apache/tamaya/collections/internal/ConcurrentHashMapConverter.java
+++ /dev/null
@@ -1,65 +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.collections.internal;
-
-import org.apache.tamaya.TypeLiteral;
-import org.apache.tamaya.spi.ConversionContext;
-import org.apache.tamaya.spi.PropertyConverter;
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-/**
- * PropertyConverter for gnerating ConcurrentHashMap representation of a values.
- */
-public class ConcurrentHashMapConverter implements PropertyConverter<ConcurrentHashMap> {
- private static final Logger LOG = Logger.getLogger(ConcurrentHashMapConverter.class.getName());
-
- /** The shared instance, used by other collection converters in this package.*/
- private static ConcurrentHashMapConverter INSTANCE = new ConcurrentHashMapConverter();
-
- /**
- * Provide a shared instance, used by other collection converters in this package.
- * @return the shared instance, never null.
- */
- static ConcurrentHashMapConverter getInstance(){
- return INSTANCE;
- }
-
- @Override
- public ConcurrentHashMap convert(String value, ConversionContext context) {
- List<String> rawList = ItemTokenizer.split(value, context);
- ConcurrentHashMap result = new ConcurrentHashMap(rawList.size());
- for(String raw:rawList){
- String[] items = ItemTokenizer.splitMapEntry(raw, context);
- Object convValue = ItemTokenizer.convertValue(items[1], context);
- if(convValue!=null){
- result.put(items[0], convValue);
- }else{
- LOG.log(Level.SEVERE, "Failed to convert collection value type for '"+raw+"'.");
- }
- }
- return result;
- }
-
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/314ad28d/sandbox/collections/src/main/java/org/apache/tamaya/collections/internal/HashMapConverter.java
----------------------------------------------------------------------
diff --git a/sandbox/collections/src/main/java/org/apache/tamaya/collections/internal/HashMapConverter.java b/sandbox/collections/src/main/java/org/apache/tamaya/collections/internal/HashMapConverter.java
deleted file mode 100644
index 6a3ac97..0000000
--- a/sandbox/collections/src/main/java/org/apache/tamaya/collections/internal/HashMapConverter.java
+++ /dev/null
@@ -1,64 +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.collections.internal;
-
-import org.apache.tamaya.TypeLiteral;
-import org.apache.tamaya.spi.ConversionContext;
-import org.apache.tamaya.spi.PropertyConverter;
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-/**
- * PropertyConverter for gnerating HashMap representation of a values.
- */
-public class HashMapConverter implements PropertyConverter<HashMap> {
- private static final Logger LOG = Logger.getLogger(HashMapConverter.class.getName());
-
- /** The shared instance, used by other collection converters in this package.*/
- private static HashMapConverter INSTANCE = new HashMapConverter();
-
- /**
- * Provide a shared instance, used by other collection converters in this package.
- * @return the shared instance, never null.
- */
- static HashMapConverter getInstance(){
- return INSTANCE;
- }
-
- @Override
- public HashMap convert(String value, ConversionContext context) {
- List<String> rawList = ItemTokenizer.split(value, context);
- HashMap result = new HashMap(rawList.size());
- for(String raw:rawList){
- String[] items = ItemTokenizer.splitMapEntry(raw, context);
- Object convValue = ItemTokenizer.convertValue(items[1], context);
- if(convValue!=null){
- result.put(items[0], convValue);
- }else{
- LOG.log(Level.SEVERE, "Failed to convert collection value type for '"+raw+"'.");
- }
- }
- return result;
- }
-
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/314ad28d/sandbox/collections/src/main/java/org/apache/tamaya/collections/internal/HashSetConverter.java
----------------------------------------------------------------------
diff --git a/sandbox/collections/src/main/java/org/apache/tamaya/collections/internal/HashSetConverter.java b/sandbox/collections/src/main/java/org/apache/tamaya/collections/internal/HashSetConverter.java
deleted file mode 100644
index 40b204f..0000000
--- a/sandbox/collections/src/main/java/org/apache/tamaya/collections/internal/HashSetConverter.java
+++ /dev/null
@@ -1,65 +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.collections.internal;
-
-import org.apache.tamaya.TypeLiteral;
-import org.apache.tamaya.spi.ConversionContext;
-import org.apache.tamaya.spi.PropertyConverter;
-
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-/**
- * PropertyConverter for gnerating HashSet representation of a values.
- */
-public class HashSetConverter implements PropertyConverter<HashSet> {
-
- private static final Logger LOG = Logger.getLogger(HashSetConverter.class.getName());
-
- /** The shared instance, used by other collection converters in this package.*/
- private static HashSetConverter INSTANCE = new HashSetConverter();
-
- /**
- * Provide a shared instance, used by other collection converters in this package.
- * @return the shared instance, never null.
- */
- static HashSetConverter getInstance(){
- return INSTANCE;
- }
-
- @Override
- public HashSet convert(String value, ConversionContext context) {
- List<String> rawList = ItemTokenizer.split(value, context);
- HashSet<Object> result = new HashSet<>();
- for(String raw:rawList){
- String[] items = ItemTokenizer.splitMapEntry(raw, context);
- Object convValue = ItemTokenizer.convertValue(items[1], context);
- if(convValue!=null){
- result.add(convValue);
- }else{
- LOG.log(Level.SEVERE, "Failed to convert collection value type for '"+raw+"'.");
- }
- }
- return result;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/314ad28d/sandbox/collections/src/main/java/org/apache/tamaya/collections/internal/ItemTokenizer.java
----------------------------------------------------------------------
diff --git a/sandbox/collections/src/main/java/org/apache/tamaya/collections/internal/ItemTokenizer.java b/sandbox/collections/src/main/java/org/apache/tamaya/collections/internal/ItemTokenizer.java
deleted file mode 100644
index 98831e1..0000000
--- a/sandbox/collections/src/main/java/org/apache/tamaya/collections/internal/ItemTokenizer.java
+++ /dev/null
@@ -1,171 +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.collections.internal;
-
-import org.apache.tamaya.ConfigurationProvider;
-import org.apache.tamaya.TypeLiteral;
-import org.apache.tamaya.spi.ConversionContext;
-import org.apache.tamaya.spi.PropertyConverter;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-/**
- * Helper class that implements the tokenizing of the entries of a configuration value.
- */
-final class ItemTokenizer {
-
- private static final Logger LOG = Logger.getLogger(ItemTokenizer.class.getName());
-
- /**
- * Private singleton.
- */
- private ItemTokenizer(){}
-
- /**
- * Splits the given value using the given separator. Matcjhing is done by traversing the String value using
- * {@code indexOf} calls, one by one. The last unresolvable item (without any next separator token)
- * is added at the end of the list.
- * @param value the value, not null.
- * @param context the conversion context.
- * @return the tokenized value as list, in order of occurrence.
- */
- public static List<String> split(String value, ConversionContext context){
- return split(value, ConfigurationProvider.getConfiguration().getOrDefault(
- '_' + context.getKey()+"." +
- "item-separator", ","));
- }
-
- /**
- * Splits the given value using the given separator. Matcjhing is done by traversing the String value using
- * {@code indexOf} calls, one by one. The last unresolvable item (without any next separator token)
- * is added at the end of the list.
- * @param value the value, not null.
- * @param separator the separator to be used.
- * @return the tokenized value as list, in order of occurrence.
- */
- public static List<String> split(String value, final String separator) {
- ArrayList<String> result = new ArrayList<>();
- int start = 0;
- int end = value.indexOf(separator,start);
- while(end>0) {
- if (end>0 && (value.charAt(end - 1) != '\\')) {
- result.add(value.substring(start, end));
- start = end + separator.length();
- end = value.indexOf(separator,start);
- }else{
- end = value.indexOf(separator,end + separator.length());
- }
- end = value.indexOf(separator,start);
- }
- if(start < value.length()){
- result.add(value.substring(start));
- }
- return result;
- }
-
- /**
- * plits the given String value as a map entry, splitting it into key and value part with the given separator.
- * If the value cannot be split then {@code key = value = mapEntry} is used for further processing. key or value
- * parts are normally trimmed, unless they are enmcosed with brackets {@code []}.
- * @param mapEntry the entry, not null.
- * @param context the conversion context.
- * @return an array of length 2, with the trimmed and parsed key/value pair.
- */
- public static String[] splitMapEntry(String mapEntry, ConversionContext context){
- return splitMapEntry(mapEntry, ConfigurationProvider.getConfiguration().getOrDefault(
- '_' + context.getKey()+".map-entry-separator", "::"));
- }
-
- /**
- * Splits the given String value as a map entry, splitting it into key and value part with the given separator.
- * If the value cannot be split then {@code key = value = mapEntry} is used for further processing. key or value
- * parts are normally trimmed, unless they are enmcosed with brackets {@code []}.
- * @param mapEntry the entry, not null.
- * @param separator the separator, not null.
- * @return an array of length 2, with the trimmed and parsed key/value pair.
- */
- public static String[] splitMapEntry(final String mapEntry, final String separator) {
- int index = mapEntry.indexOf(separator);
- String[] items;
- if(index<0) {
- items = new String[]{mapEntry, mapEntry};
- }else {
- items = new String[]{mapEntry.substring(0,index),
- mapEntry.substring(index+separator.length())};
- }
- if(items[0].trim().startsWith("[")){
- items[0]= items[0].trim();
- items[0] = items[0].substring(1);
- }else{
- items[0]= items[0].trim();
- }
- if(items[1].trim().endsWith("]")){
- items[1] = items[1].substring(0,items[1].length()-1);
- }else{
- items[1]= items[1].trim();
- }
- return items;
- }
-
- /**
- * Parses the given value into the required collection target type, defined by the context.
- * @param value the raw String value.
- * @param context the context
- * @return the parsed value, or null.
- */
- public static Object convertValue(String value, ConversionContext context) {
- String converterClass = context.getConfiguration().get('_' + context.getKey() + ".item-converter");
- List<PropertyConverter<Object>> valueConverters = new ArrayList<>(1);
- if (converterClass != null) {
- try {
- valueConverters.add((PropertyConverter<Object>) Class.forName(converterClass).newInstance());
- } catch (Exception e) {
- LOG.log(Level.SEVERE, "Error convertion config to ArrayList type.", e);
- }
- }
- if (TypeLiteral.getTypeParameters(context.getTargetType().getType()).length>0) {
- valueConverters.addAll(context.getConfigurationContext().getPropertyConverters(
- TypeLiteral.of(TypeLiteral.getTypeParameters(context.getTargetType().getType())[0])));
- }
- ConversionContext ctx = new ConversionContext.Builder(context.getConfiguration(),
- context.getConfigurationContext(), context.getKey(),
- TypeLiteral.of(context.getTargetType().getType())).build();
- Object result = null;
- if (valueConverters.isEmpty()) {
- return value;
- } else {
- for (PropertyConverter<Object> conv : valueConverters) {
- try {
- result = conv.convert(value, ctx);
- if (result != null) {
- return result;
- }
- } catch (Exception e) {
- LOG.log(Level.SEVERE, "Error convertion config to ArrayList type.", e);
- }
- }
- }
- LOG.log(Level.SEVERE, "Failed to convert collection value type for '" + value + "'.");
- return null;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/314ad28d/sandbox/collections/src/main/java/org/apache/tamaya/collections/internal/LinkedListConverter.java
----------------------------------------------------------------------
diff --git a/sandbox/collections/src/main/java/org/apache/tamaya/collections/internal/LinkedListConverter.java b/sandbox/collections/src/main/java/org/apache/tamaya/collections/internal/LinkedListConverter.java
deleted file mode 100644
index 4389a54..0000000
--- a/sandbox/collections/src/main/java/org/apache/tamaya/collections/internal/LinkedListConverter.java
+++ /dev/null
@@ -1,64 +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.collections.internal;
-
-import org.apache.tamaya.TypeLiteral;
-import org.apache.tamaya.spi.ConversionContext;
-import org.apache.tamaya.spi.PropertyConverter;
-
-import java.util.LinkedList;
-import java.util.List;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-/**
- * PropertyConverter for gnerating LinkedList representation of a values.
- */
-public class LinkedListConverter implements PropertyConverter<LinkedList> {
- private static final Logger LOG = Logger.getLogger(LinkedListConverter.class.getName());
-
- /** The shared instance, used by other collection converters in this package.*/
- private static LinkedListConverter INSTANCE = new LinkedListConverter();
-
- /**
- * Provide a shared instance, used by other collection converters in this package.
- * @return the shared instance, never null.
- */
- static LinkedListConverter getInstance(){
- return INSTANCE;
- }
-
- @Override
- public LinkedList convert(String value, ConversionContext context) {
- List<String> rawList = ItemTokenizer.split(value, context);
- LinkedList<Object> result = new LinkedList<>();
- for(String raw:rawList){
- String[] items = ItemTokenizer.splitMapEntry(raw, context);
- Object convValue = ItemTokenizer.convertValue(items[1], context);
- if(convValue!=null){
- result.add(convValue);
- continue;
- }else{
- LOG.log(Level.SEVERE, "Failed to convert collection value type for '"+raw+"'.");
- }
- }
- return result;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/314ad28d/sandbox/collections/src/main/java/org/apache/tamaya/collections/internal/ListConverter.java
----------------------------------------------------------------------
diff --git a/sandbox/collections/src/main/java/org/apache/tamaya/collections/internal/ListConverter.java b/sandbox/collections/src/main/java/org/apache/tamaya/collections/internal/ListConverter.java
deleted file mode 100644
index 65fc54e..0000000
--- a/sandbox/collections/src/main/java/org/apache/tamaya/collections/internal/ListConverter.java
+++ /dev/null
@@ -1,55 +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.collections.internal;
-
-import org.apache.tamaya.spi.ConversionContext;
-import org.apache.tamaya.spi.PropertyConverter;
-
-import java.util.Collections;
-import java.util.List;
-
-/**
- * PropertyConverter for gnerating a LIST representation of values.
- */
-public class ListConverter implements PropertyConverter<List> {
-
- @Override
- public List convert(String value, ConversionContext context) {
- String collectionType = context.getConfiguration().getOrDefault('_' + context.getKey()+".collection-type", "List");
- if(collectionType.startsWith("java.util.")){
- collectionType = collectionType.substring("java.util.".length());
- }
- List result = null;
- switch(collectionType){
- case "List":
- case "ArrayList":
- default:
- result = ArrayListConverter.getInstance().convert(value, context);
- break;
- case "LinkedList":
- result = LinkedListConverter.getInstance().convert(value, context);
- break;
- }
- if(context.getConfiguration().getOrDefault('_' + context.getKey()+".read-only",
- Boolean.class, Boolean.TRUE)){
- return Collections.unmodifiableList(result);
- }
- return result;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/314ad28d/sandbox/collections/src/main/java/org/apache/tamaya/collections/internal/MapConverter.java
----------------------------------------------------------------------
diff --git a/sandbox/collections/src/main/java/org/apache/tamaya/collections/internal/MapConverter.java b/sandbox/collections/src/main/java/org/apache/tamaya/collections/internal/MapConverter.java
deleted file mode 100644
index 606e14f..0000000
--- a/sandbox/collections/src/main/java/org/apache/tamaya/collections/internal/MapConverter.java
+++ /dev/null
@@ -1,59 +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.collections.internal;
-
-import org.apache.tamaya.spi.ConversionContext;
-import org.apache.tamaya.spi.PropertyConverter;
-
-import java.util.Collections;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * PropertyConverter for gnerating HashMap representation of a values.
- */
-public class MapConverter implements PropertyConverter<Map> {
-
- @Override
- public Map convert(String value, ConversionContext context) {
- String collectionType = context.getConfiguration().getOrDefault('_' + context.getKey()+".collection-type", "Map");
- if(collectionType.startsWith("java.util.")){
- collectionType = collectionType.substring("java.util.".length());
- }
- Map result = null;
- switch(collectionType){
- case "Map":
- case "HashMap":
- default:
- result = HashMapConverter.getInstance().convert(value, context);
- break;
- case "TreeMap":
- result = TreeMapConverter.getInstance().convert(value, context);
- break;
- case "ConcurrentHashMap":
- result = ConcurrentHashMapConverter.getInstance().convert(value, context);
- break;
- }
- if(context.getConfiguration().getOrDefault('_' + context.getKey()+".read-only",
- Boolean.class, Boolean.TRUE)){
- return Collections.unmodifiableMap(result);
- }
- return result;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/314ad28d/sandbox/collections/src/main/java/org/apache/tamaya/collections/internal/SetConverter.java
----------------------------------------------------------------------
diff --git a/sandbox/collections/src/main/java/org/apache/tamaya/collections/internal/SetConverter.java b/sandbox/collections/src/main/java/org/apache/tamaya/collections/internal/SetConverter.java
deleted file mode 100644
index 75301bc..0000000
--- a/sandbox/collections/src/main/java/org/apache/tamaya/collections/internal/SetConverter.java
+++ /dev/null
@@ -1,55 +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.collections.internal;
-
-import org.apache.tamaya.spi.ConversionContext;
-import org.apache.tamaya.spi.PropertyConverter;
-
-import java.util.Collections;
-import java.util.Set;
-
-/**
- * PropertyConverter for gnerating a LIST representation of values.
- */
-public class SetConverter implements PropertyConverter<Set> {
-
- @Override
- public Set convert(String value, ConversionContext context) {
- String collectionType = context.getConfiguration().getOrDefault('_' + context.getKey()+".collection-type", "Set");
- if(collectionType.startsWith("java.util.")){
- collectionType = collectionType.substring("java.util.".length());
- }
- Set result = null;
- switch(collectionType){
- case "Set":
- case "HashSet":
- default:
- result = HashSetConverter.getInstance().convert(value, context);
- break;
- case "TreeSet":
- result = TreeSetConverter.getInstance().convert(value, context);
- break;
- }
- if(context.getConfiguration().getOrDefault('_' + context.getKey()+".read-only",
- Boolean.class, Boolean.TRUE)){
- return Collections.unmodifiableSet(result);
- }
- return result;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/314ad28d/sandbox/collections/src/main/java/org/apache/tamaya/collections/internal/SortedMapConverter.java
----------------------------------------------------------------------
diff --git a/sandbox/collections/src/main/java/org/apache/tamaya/collections/internal/SortedMapConverter.java b/sandbox/collections/src/main/java/org/apache/tamaya/collections/internal/SortedMapConverter.java
deleted file mode 100644
index 1015751..0000000
--- a/sandbox/collections/src/main/java/org/apache/tamaya/collections/internal/SortedMapConverter.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.collections.internal;
-
-import org.apache.tamaya.spi.ConversionContext;
-import org.apache.tamaya.spi.PropertyConverter;
-
-import java.util.Collections;
-import java.util.SortedMap;
-import java.util.SortedSet;
-
-/**
- * PropertyConverter for gnerating a LIST representation of values.
- */
-public class SortedMapConverter implements PropertyConverter<SortedMap> {
-
- @Override
- public SortedMap convert(String value, ConversionContext context) {
- return Collections.unmodifiableSortedMap(TreeMapConverter.getInstance().convert(value, context));
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/314ad28d/sandbox/collections/src/main/java/org/apache/tamaya/collections/internal/SortedSetConverter.java
----------------------------------------------------------------------
diff --git a/sandbox/collections/src/main/java/org/apache/tamaya/collections/internal/SortedSetConverter.java b/sandbox/collections/src/main/java/org/apache/tamaya/collections/internal/SortedSetConverter.java
deleted file mode 100644
index c0b8065..0000000
--- a/sandbox/collections/src/main/java/org/apache/tamaya/collections/internal/SortedSetConverter.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.collections.internal;
-
-import org.apache.tamaya.spi.ConversionContext;
-import org.apache.tamaya.spi.PropertyConverter;
-
-import java.util.Collections;
-import java.util.SortedSet;
-
-/**
- * PropertyConverter for gnerating a LIST representation of values.
- */
-public class SortedSetConverter implements PropertyConverter<SortedSet> {
-
- @Override
- public SortedSet convert(String value, ConversionContext context) {
- return Collections.unmodifiableSortedSet(TreeSetConverter.getInstance().convert(value, context));
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/314ad28d/sandbox/collections/src/main/java/org/apache/tamaya/collections/internal/TreeMapConverter.java
----------------------------------------------------------------------
diff --git a/sandbox/collections/src/main/java/org/apache/tamaya/collections/internal/TreeMapConverter.java b/sandbox/collections/src/main/java/org/apache/tamaya/collections/internal/TreeMapConverter.java
deleted file mode 100644
index fef25fe..0000000
--- a/sandbox/collections/src/main/java/org/apache/tamaya/collections/internal/TreeMapConverter.java
+++ /dev/null
@@ -1,62 +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.collections.internal;
-
-import org.apache.tamaya.spi.ConversionContext;
-import org.apache.tamaya.spi.PropertyConverter;
-
-import java.util.List;
-import java.util.TreeMap;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-/**
- * PropertyConverter for gnerating HashMap representation of a values.
- */
-public class TreeMapConverter implements PropertyConverter<TreeMap> {
- /** Logger used. */
- private static final Logger LOG = Logger.getLogger(HashMapConverter.class.getName());
-
- /** The shared instance, used by other collection converters in this package.*/
- private static TreeMapConverter INSTANCE = new TreeMapConverter();
-
- /**
- * Provide a shared instance, used by other collection converters in this package.
- * @return the shared instance, never null.
- */
- static TreeMapConverter getInstance(){
- return INSTANCE;
- }
-
- @Override
- public TreeMap convert(String value, ConversionContext context) {
- List<String> rawList = ItemTokenizer.split(value, context);
- TreeMap result = new TreeMap();
- for(String raw:rawList){
- String[] items = ItemTokenizer.splitMapEntry(raw, context);
- Object convValue = ItemTokenizer.convertValue(items[1], context);
- if(convValue!=null){
- result.put(items[0], convValue);
- }else{
- LOG.log(Level.SEVERE, "Failed to convert collection value type for '"+raw+"'.");
- }
- }
- return result;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/314ad28d/sandbox/collections/src/main/java/org/apache/tamaya/collections/internal/TreeSetConverter.java
----------------------------------------------------------------------
diff --git a/sandbox/collections/src/main/java/org/apache/tamaya/collections/internal/TreeSetConverter.java b/sandbox/collections/src/main/java/org/apache/tamaya/collections/internal/TreeSetConverter.java
deleted file mode 100644
index 9206f07..0000000
--- a/sandbox/collections/src/main/java/org/apache/tamaya/collections/internal/TreeSetConverter.java
+++ /dev/null
@@ -1,64 +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.collections.internal;
-
-import org.apache.tamaya.TypeLiteral;
-import org.apache.tamaya.spi.ConversionContext;
-import org.apache.tamaya.spi.PropertyConverter;
-
-import java.util.List;
-import java.util.TreeSet;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-/**
- * PropertyConverter for gnerating HashSet representation of a values.
- */
-public class TreeSetConverter implements PropertyConverter<TreeSet> {
-
- private static final Logger LOG = Logger.getLogger(TreeSetConverter.class.getName());
-
- /** The shared instance, used by other collection converters in this package.*/
- private static TreeSetConverter INSTANCE = new TreeSetConverter();
-
- /**
- * Provide a shared instance, used by other collection converters in this package.
- * @return the shared instance, never null.
- */
- static TreeSetConverter getInstance(){
- return INSTANCE;
- }
-
- @Override
- public TreeSet convert(String value, ConversionContext context) {
- List<String> rawList = ItemTokenizer.split(value, context);
- TreeSet<Object> result = new TreeSet<>();
- for(String raw:rawList){
- String[] items = ItemTokenizer.splitMapEntry(raw, context);
- Object convValue = ItemTokenizer.convertValue(items[1], context);
- if(convValue!=null){
- result.add(convValue);
- continue;
- }else{
- LOG.log(Level.SEVERE, "Failed to convert collection value type for '"+raw+"'.");
- }
- }
- return result;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/314ad28d/sandbox/collections/src/main/resources/META-INF/services/org.apache.tamaya.spi.PropertyConverter
----------------------------------------------------------------------
diff --git a/sandbox/collections/src/main/resources/META-INF/services/org.apache.tamaya.spi.PropertyConverter b/sandbox/collections/src/main/resources/META-INF/services/org.apache.tamaya.spi.PropertyConverter
deleted file mode 100644
index 9a93a69..0000000
--- a/sandbox/collections/src/main/resources/META-INF/services/org.apache.tamaya.spi.PropertyConverter
+++ /dev/null
@@ -1,31 +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.
-#
-org.apache.tamaya.collections.internal.ArrayListConverter
-org.apache.tamaya.collections.internal.CollectionConverter
-org.apache.tamaya.collections.internal.HashMapConverter
-org.apache.tamaya.collections.internal.ConcurrentHashMapConverter
-org.apache.tamaya.collections.internal.HashSetConverter
-org.apache.tamaya.collections.internal.LinkedListConverter
-org.apache.tamaya.collections.internal.ListConverter
-org.apache.tamaya.collections.internal.MapConverter
-org.apache.tamaya.collections.internal.SetConverter
-org.apache.tamaya.collections.internal.SortedSetConverter
-org.apache.tamaya.collections.internal.SortedMapConverter
-org.apache.tamaya.collections.internal.TreeMapConverter
-org.apache.tamaya.collections.internal.TreeSetConverter
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/314ad28d/sandbox/collections/src/main/resources/META-INF/services/org.apache.tamaya.spi.PropertyValueCombinationPolicy
----------------------------------------------------------------------
diff --git a/sandbox/collections/src/main/resources/META-INF/services/org.apache.tamaya.spi.PropertyValueCombinationPolicy b/sandbox/collections/src/main/resources/META-INF/services/org.apache.tamaya.spi.PropertyValueCombinationPolicy
deleted file mode 100644
index 6b7a67b..0000000
--- a/sandbox/collections/src/main/resources/META-INF/services/org.apache.tamaya.spi.PropertyValueCombinationPolicy
+++ /dev/null
@@ -1,19 +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.
-#
-org.apache.tamaya.collections.internal.AdaptiveCombinationPolicy
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/314ad28d/sandbox/collections/src/test/java/org/apache/tamaya/collections/CollectionAdvancedTests.java
----------------------------------------------------------------------
diff --git a/sandbox/collections/src/test/java/org/apache/tamaya/collections/CollectionAdvancedTests.java b/sandbox/collections/src/test/java/org/apache/tamaya/collections/CollectionAdvancedTests.java
deleted file mode 100644
index ddabb23..0000000
--- a/sandbox/collections/src/test/java/org/apache/tamaya/collections/CollectionAdvancedTests.java
+++ /dev/null
@@ -1,99 +0,0 @@
-package org.apache.tamaya.collections;
-
-import org.apache.tamaya.Configuration;
-import org.apache.tamaya.ConfigurationProvider;
-import org.apache.tamaya.TypeLiteral;
-import org.junit.Test;
-
-import java.util.Currency;
-import java.util.List;
-import java.util.Map;
-
-import static junit.framework.TestCase.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-
-/**
- * Created by atsticks on 16.02.16.
- */
-public class CollectionAdvancedTests {
-
- /**
- * Tests if a custom separator works, Config is
- * <pre>
- * sep-list=a,b,c|d,e,f|g,h,i
- * _sep-list.collection-type=List
- * _sep-list.collection-separator=|
- * </pre>
- */
- @Test
- public void testCustomSeparator(){
- Configuration config = ConfigurationProvider.getConfiguration();
- List<String> items = config.get("sep-list", new TypeLiteral<List<String>>(){});
- assertNotNull(items);
- assertFalse(items.isEmpty());
- assertEquals(3, items.size());
- assertEquals("a,b,c", items.get(0));
- assertEquals("d,e,f", items.get(1));
- assertEquals("g,h,i", items.get(2));
- }
-
- /**
- * Test typed content.
- * <pre>
- * currency-list=CHF,USD,YEN
- * _currency-list.collection-type=List
- * </pre>
- */
- @Test
- public void testTypedContent(){
- Configuration config = ConfigurationProvider.getConfiguration();
- List<Currency> items = config.get("currency-list", new TypeLiteral<List<Currency>>(){});
- assertNotNull(items);
- assertFalse(items.isEmpty());
- assertEquals(3, items.size());
- assertEquals("CHF", items.get(0).getCurrencyCode());
- assertEquals("USD", items.get(1).getCurrencyCode());
- assertEquals("USS", items.get(2).getCurrencyCode());
- }
-
- /**
- * Tests if a custom parser works, Config is
- * <pre>
- * parser-list=a,b,c
- * _parser-list.collection-type=List
- * _parser-list.item-converter=org.apache.tamaya.collections.MyUpperCaseConverter
- * </pre>
- */
- @Test
- public void testCustomParser(){
- Configuration config = ConfigurationProvider.getConfiguration();
- List<String> items = config.get("parser-list", new TypeLiteral<List<String>>(){});
- assertNotNull(items);
- assertFalse(items.isEmpty());
- assertEquals(3, items.size());
- assertEquals("(A)", items.get(0));
- assertEquals("(B)", items.get(1));
- assertEquals("(C)", items.get(2));
- }
-
- /**
- * Redefined map format parsing, Config is as follows:
- * <pre>
- * redefined-map=0==none | 1==single | 2==any
- * _redefined-map.map-entry-separator===
- * _redefined-map.item-separator=|
- * </pre>
- */
- @Test
- public void testCustomMapParser(){
- Configuration config = ConfigurationProvider.getConfiguration();
- Map<String,String> items = config.get("redefined-map", Map.class);
- assertNotNull(items);
- assertFalse(items.isEmpty());
- assertEquals(3, items.size());
- assertEquals("none", items.get("0"));
- assertEquals("single", items.get("1"));
- assertEquals("any", items.get("2"));
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/314ad28d/sandbox/collections/src/test/java/org/apache/tamaya/collections/CollectionsBaseTests.java
----------------------------------------------------------------------
diff --git a/sandbox/collections/src/test/java/org/apache/tamaya/collections/CollectionsBaseTests.java b/sandbox/collections/src/test/java/org/apache/tamaya/collections/CollectionsBaseTests.java
deleted file mode 100644
index 34c82cb..0000000
--- a/sandbox/collections/src/test/java/org/apache/tamaya/collections/CollectionsBaseTests.java
+++ /dev/null
@@ -1,227 +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.collections;
-
-import org.apache.tamaya.Configuration;
-import org.apache.tamaya.ConfigurationProvider;
-import org.apache.tamaya.TypeLiteral;
-import org.junit.Test;
-
-import java.util.*;
-
-import static junit.framework.TestCase.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-
-/**
- * Basic tests for Tamaya collection support. Relevant configs for this tests:
- * <pre>base.items=1,2,3,4,5,6,7,8,9,0
- * base.map=1::a, 2::b, 3::c, [4:: ]
- * </pre>
- */
-public class CollectionsBaseTests {
-
- @Test
- public void testList_String(){
- Configuration config = ConfigurationProvider.getConfiguration();
- List<String> items = config.get("base.items", new TypeLiteral<List<String>>(){});
- assertNotNull(items);
- assertFalse(items.isEmpty());
- assertEquals(10, items.size());
- items = (List<String>) config.get("base.items", List.class);
- assertNotNull(items);
- assertFalse(items.isEmpty());
- assertEquals(10, items.size());
- }
-
- @Test
- public void testArrayList_String(){
- Configuration config = ConfigurationProvider.getConfiguration();
- ArrayList<String> items = config.get("base.items", new TypeLiteral<ArrayList<String>>(){});
- assertNotNull(items);
- assertFalse(items.isEmpty());
- assertEquals(10, items.size());
- items = (ArrayList<String>) config.get("base.items", ArrayList.class);
- assertNotNull(items);
- assertFalse(items.isEmpty());
- assertEquals(10, items.size());
- }
-
- @Test
- public void testLinkedList_String(){
- Configuration config = ConfigurationProvider.getConfiguration();
- LinkedList<String> items = config.get("base.items", new TypeLiteral<LinkedList<String>>(){});
- assertNotNull(items);
- assertFalse(items.isEmpty());
- assertEquals(10, items.size());
- items = (LinkedList<String>) config.get("base.items", LinkedList.class);
- assertNotNull(items);
- assertFalse(items.isEmpty());
- assertEquals(10, items.size());
- }
-
- @Test
- public void testSet_String(){
- Configuration config = ConfigurationProvider.getConfiguration();
- Set<String> items = config.get("base.items", new TypeLiteral<Set<String>>(){});
- assertNotNull(items);
- assertFalse(items.isEmpty());
- assertEquals(10, items.size());
- items = (Set<String>) config.get("base.items", Set.class);
- assertNotNull(items);
- assertFalse(items.isEmpty());
- assertEquals(10, items.size());
- }
-
- @Test
- public void testSortedSet_String(){
- Configuration config = ConfigurationProvider.getConfiguration();
- Set<String> items = config.get("base.items", new TypeLiteral<SortedSet<String>>(){});
- assertNotNull(items);
- assertFalse(items.isEmpty());
- assertEquals(10, items.size());
- items = (SortedSet<String>) config.get("base.items", SortedSet.class);
- assertNotNull(items);
- assertFalse(items.isEmpty());
- assertEquals(10, items.size());
- }
-
- @Test
- public void testHashSet_String(){
- Configuration config = ConfigurationProvider.getConfiguration();
- Set<String> items = config.get("base.items", new TypeLiteral<HashSet<String>>(){});
- assertNotNull(items);
- assertFalse(items.isEmpty());
- assertEquals(10, items.size());
- items = (HashSet<String>) config.get("base.items", HashSet.class);
- assertNotNull(items);
- assertFalse(items.isEmpty());
- assertEquals(10, items.size());
- }
-
- @Test
- public void testTreeSet_String(){
- Configuration config = ConfigurationProvider.getConfiguration();
- TreeSet<String> items = config.get("base.items", new TypeLiteral<TreeSet<String>>(){});
- assertNotNull(items);
- assertFalse(items.isEmpty());
- assertEquals(10, items.size());
- items = (TreeSet<String>) config.get("base.items", TreeSet.class);
- assertNotNull(items);
- assertFalse(items.isEmpty());
- assertEquals(10, items.size());
- }
-
- @Test
- public void testMap_String(){
- Configuration config = ConfigurationProvider.getConfiguration();
- Map<String,String> items = config.get("base.map", new TypeLiteral<Map<String,String>>(){});
- assertNotNull(items);
- assertFalse(items.isEmpty());
- assertEquals(4, items.size());
- assertEquals("a", items.get("1"));
- assertEquals("b", items.get("2"));
- assertEquals("c", items.get("3"));
- assertEquals(" ", items.get("4"));
- items = (Map<String,String>) config.get("base.map", Map.class);
- assertNotNull(items);
- assertFalse(items.isEmpty());
- assertEquals(4, items.size());
- assertEquals("a", items.get("1"));
- assertEquals("b", items.get("2"));
- assertEquals("c", items.get("3"));
- assertEquals(" ", items.get("4"));
- }
-
- @Test
- public void testHashMap_String(){
- Configuration config = ConfigurationProvider.getConfiguration();
- Map<String,String> items = config.get("base.map", new TypeLiteral<HashMap<String,String>>(){});
- assertNotNull(items);
- assertFalse(items.isEmpty());
- assertEquals(4, items.size());
- assertEquals("a", items.get("1"));
- assertEquals("b", items.get("2"));
- assertEquals("c", items.get("3"));
- assertEquals(" ", items.get("4"));
- items = (HashMap<String,String>) config.get("base.map", HashMap.class);
- assertNotNull(items);
- assertFalse(items.isEmpty());
- assertEquals(4, items.size());
- assertEquals("a", items.get("1"));
- assertEquals("b", items.get("2"));
- assertEquals("c", items.get("3"));
- assertEquals(" ", items.get("4"));
- }
-
- @Test
- public void testSortedMap_String(){
- Configuration config = ConfigurationProvider.getConfiguration();
- Map<String,String> items = config.get("base.map", new TypeLiteral<SortedMap<String,String>>(){});
- assertNotNull(items);
- assertFalse(items.isEmpty());
- assertEquals(4, items.size());
- assertEquals("a", items.get("1"));
- assertEquals("b", items.get("2"));
- assertEquals("c", items.get("3"));
- assertEquals(" ", items.get("4"));
- items = (Map<String,String>) config.get("base.map", SortedMap.class);
- assertNotNull(items);
- assertFalse(items.isEmpty());
- assertEquals(4, items.size());
- assertEquals("a", items.get("1"));
- assertEquals("b", items.get("2"));
- assertEquals("c", items.get("3"));
- assertEquals(" ", items.get("4"));
- }
-
- @Test
- public void testTreeMap_String(){
- Configuration config = ConfigurationProvider.getConfiguration();
- TreeMap<String,String> items = config.get("base.map", new TypeLiteral<TreeMap<String,String>>(){});
- assertNotNull(items);
- assertFalse(items.isEmpty());
- assertEquals(4, items.size());
- assertEquals("a", items.get("1"));
- assertEquals("b", items.get("2"));
- assertEquals("c", items.get("3"));
- assertEquals(" ", items.get("4"));
- items = config.get("base.map", TreeMap.class);
- assertNotNull(items);
- assertFalse(items.isEmpty());
- assertEquals(4, items.size());
- assertEquals("a", items.get("1"));
- assertEquals("b", items.get("2"));
- assertEquals("c", items.get("3"));
- assertEquals(" ", items.get("4"));
- }
-
- @Test
- public void testCollection_String(){
- Configuration config = ConfigurationProvider.getConfiguration();
- Collection<String> items = config.get("base.items", new TypeLiteral<Collection<String>>(){});
- assertNotNull(items);
- assertFalse(items.isEmpty());
- assertEquals(10, items.size());
- items = (Collection<String>) config.get("base.items", Collection.class);
- assertNotNull(items);
- assertFalse(items.isEmpty());
- assertEquals(10, items.size());
- }
-}
[5/6] incubator-tamaya git commit: Added ref to ALv2 licenced
snakeyaml.
Posted by an...@apache.org.
Added ref to ALv2 licenced snakeyaml.
Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/commit/03016f8b
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/tree/03016f8b
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/diff/03016f8b
Branch: refs/heads/master
Commit: 03016f8b1db5da76f2117aa8763abdba0ea968f0
Parents: a1388e2
Author: anatole <an...@apache.org>
Authored: Sat Feb 27 22:39:00 2016 +0100
Committer: anatole <an...@apache.org>
Committed: Sat Feb 27 22:39:00 2016 +0100
----------------------------------------------------------------------
NOTICE | 5 +++++
1 file changed, 5 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/03016f8b/NOTICE
----------------------------------------------------------------------
diff --git a/NOTICE b/NOTICE
index 15f3597..ed9f187 100644
--- a/NOTICE
+++ b/NOTICE
@@ -3,3 +3,8 @@ Copyright 2014-2015 The Apache Software Foundation.
This product includes software developed at
The Apache Software Foundation (http://www.apache.org/).
+
+---
+
+modules/yaml is depending on (http://www.snakeyaml.org/) licenced under
+Apache License, Version 2.0.
[4/6] incubator-tamaya git commit: Moved collections module from
sandbox to modules.
Posted by an...@apache.org.
Moved collections module from sandbox to modules.
Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/commit/a1388e22
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/tree/a1388e22
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/diff/a1388e22
Branch: refs/heads/master
Commit: a1388e222745b7b948b659fb9b69d1c0f769499e
Parents: 314ad28
Author: anatole <an...@apache.org>
Authored: Sat Feb 27 22:13:36 2016 +0100
Committer: anatole <an...@apache.org>
Committed: Sat Feb 27 22:13:36 2016 +0100
----------------------------------------------------------------------
modules/pom.xml | 1 +
sandbox/pom.xml | 3 ---
2 files changed, 1 insertion(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/a1388e22/modules/pom.xml
----------------------------------------------------------------------
diff --git a/modules/pom.xml b/modules/pom.xml
index 33704a4..71154cb 100644
--- a/modules/pom.xml
+++ b/modules/pom.xml
@@ -53,6 +53,7 @@ under the License.
<module>classloader-support</module>
<module>integration</module>
<module>filter</module>
+ <module>collections</module>
</modules>
<build>
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/a1388e22/sandbox/pom.xml
----------------------------------------------------------------------
diff --git a/sandbox/pom.xml b/sandbox/pom.xml
index 249c18a..ba43998 100644
--- a/sandbox/pom.xml
+++ b/sandbox/pom.xml
@@ -39,9 +39,6 @@ under the License.
<module>metamodels</module>
<module>jodatime</module>
<module>sysprops</module>
- <module>environment</module>
- <module>collections</module>
- <module>mutable-config</module>
<module>ui</module>
</modules>