You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tamaya.apache.org by st...@apache.org on 2014/12/27 14:58:14 UTC
[30/34] incubator-tamaya git commit: move intermediately changed
stuff to dormant as well
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/278a6c68/dormant/core/src/main/java/org/apache/tamaya/core/properties/PropertySourceFunctions.java
----------------------------------------------------------------------
diff --git a/dormant/core/src/main/java/org/apache/tamaya/core/properties/PropertySourceFunctions.java b/dormant/core/src/main/java/org/apache/tamaya/core/properties/PropertySourceFunctions.java
new file mode 100644
index 0000000..5fcf895
--- /dev/null
+++ b/dormant/core/src/main/java/org/apache/tamaya/core/properties/PropertySourceFunctions.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.core.properties;
+
+import org.apache.tamaya.PropertySource;
+
+import java.util.*;
+import java.util.function.Function;
+import java.util.function.Predicate;
+import java.util.function.UnaryOperator;
+import java.util.stream.Collectors;
+
+/**
+ * Accessor that provides useful functions along with configuration.
+ */
+public final class PropertySourceFunctions {
+ /**
+ * Private singleton constructor.
+ */
+ private PropertySourceFunctions() {
+ }
+
+ /**
+ * Creates a ConfigOperator that creates a Configuration containing only keys
+ * that are contained in the given area (non recursive). Hereby
+ * the area key is stripped away fromMap the resulting key.
+ *
+ * @param areaKey the area key, not null
+ * @param mappedAreaKey the target key, not null
+ * @return the area configuration, with the areaKey stripped away.
+ */
+ public static UnaryOperator<PropertySource> mapArea(String areaKey, String mappedAreaKey) {
+ return mapKeys(key -> key.startsWith(areaKey + '.') ?
+ mappedAreaKey + key.substring(areaKey.length()) : key);
+ }
+
+ /**
+ * Creates a {@link java.util.function.UnaryOperator} that creates a {@link org.apache.tamaya.Configuration} that maps any keys as
+ * defined by the {@code keyMapper} given. If the {@code keyMapper} returns
+ * {@code null} for a keys, it is removed from the resulting map.
+ *
+ * @param keyMapper the key mapper, not null
+ * @return the area configuration, with the areaKey stripped away.
+ */
+ public static UnaryOperator<PropertySource> mapKeys(UnaryOperator<String> keyMapper) {
+ return (c) -> new MappedPropertySource(c, keyMapper);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/278a6c68/dormant/core/src/main/resources/META-INF/services/org.apache.tamaya.core.properties.ConfigurationFormat
----------------------------------------------------------------------
diff --git a/dormant/core/src/main/resources/META-INF/services/org.apache.tamaya.core.properties.ConfigurationFormat b/dormant/core/src/main/resources/META-INF/services/org.apache.tamaya.core.properties.ConfigurationFormat
new file mode 100644
index 0000000..7aa2407
--- /dev/null
+++ b/dormant/core/src/main/resources/META-INF/services/org.apache.tamaya.core.properties.ConfigurationFormat
@@ -0,0 +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 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.core.internal.format.PropertiesFormat
+org.apache.tamaya.core.internal.format.PropertiesXmlFormat
+org.apache.tamaya.core.internal.format.IniFormat
\ No newline at end of file