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 2014/12/12 14:28:25 UTC
incubator-tamaya git commit: TAMAYA-22: Removed ConfigOperator
Repository: incubator-tamaya
Updated Branches:
refs/heads/master 8b4ecc988 -> cca3d6f12
TAMAYA-22: Removed ConfigOperator
Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/commit/cca3d6f1
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/tree/cca3d6f1
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/diff/cca3d6f1
Branch: refs/heads/master
Commit: cca3d6f12d0debd82c503dc81b2eacb644ce738f
Parents: 8b4ecc9
Author: anatole <an...@apache.org>
Authored: Fri Dec 12 14:28:19 2014 +0100
Committer: anatole <an...@apache.org>
Committed: Fri Dec 12 14:28:19 2014 +0100
----------------------------------------------------------------------
.../java/org/apache/tamaya/ConfigOperator.java | 37 --------------------
.../java/org/apache/tamaya/Configuration.java | 5 +--
.../tamaya/annotation/WithConfigOperator.java | 5 +--
.../tamaya/core/config/ConfigFunctions.java | 17 ++++-----
4 files changed, 15 insertions(+), 49 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/cca3d6f1/api/src/main/java/org/apache/tamaya/ConfigOperator.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/tamaya/ConfigOperator.java b/api/src/main/java/org/apache/tamaya/ConfigOperator.java
deleted file mode 100644
index edbc9dc..0000000
--- a/api/src/main/java/org/apache/tamaya/ConfigOperator.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;
-
-
-/**
- * Interface for an filter/operator that converts a configured String into another String. One typical
- * use case would the the decryption current an encrypted configuration value.
- */
-@FunctionalInterface
-public interface ConfigOperator{
-
- /**
- * Method that creates a Configuration fromMap another Configuration. This can be used for implementing
- * views, security constraints or for overriding/inheriting current configuration.
- * @param config The target configuration to be operated, never nnull.
- * @return the operated configuration, never null.
- */
- Configuration operate(Configuration config);
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/cca3d6f1/api/src/main/java/org/apache/tamaya/Configuration.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/tamaya/Configuration.java b/api/src/main/java/org/apache/tamaya/Configuration.java
index e076ea0..7b5b146 100644
--- a/api/src/main/java/org/apache/tamaya/Configuration.java
+++ b/api/src/main/java/org/apache/tamaya/Configuration.java
@@ -23,6 +23,7 @@ import com.sun.javafx.scene.control.behavior.OptionalBoolean;
import java.beans.PropertyChangeListener;
import java.util.*;
import java.util.function.Predicate;
+import java.util.function.UnaryOperator;
import java.util.stream.Collectors;
/**
@@ -235,8 +236,8 @@ public interface Configuration extends PropertyProvider{
* combining configurations.
* @return the new adjusted configuration, never {@code null}.
*/
- default Configuration with(ConfigOperator operator){
- return operator.operate(this);
+ default Configuration with(UnaryOperator<Configuration> operator){
+ return operator.apply(this);
}
/**
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/cca3d6f1/api/src/main/java/org/apache/tamaya/annotation/WithConfigOperator.java
----------------------------------------------------------------------
diff --git a/api/src/main/java/org/apache/tamaya/annotation/WithConfigOperator.java b/api/src/main/java/org/apache/tamaya/annotation/WithConfigOperator.java
index d1b28be..28bf814 100644
--- a/api/src/main/java/org/apache/tamaya/annotation/WithConfigOperator.java
+++ b/api/src/main/java/org/apache/tamaya/annotation/WithConfigOperator.java
@@ -18,12 +18,13 @@
*/
package org.apache.tamaya.annotation;
-import org.apache.tamaya.ConfigOperator;
+import org.apache.tamaya.Configuration;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
+import java.util.function.UnaryOperator;
/**
* Annotation to define an configuration operator to be used before accessing a configured value.
@@ -39,6 +40,6 @@ public @interface WithConfigOperator {
* general org.apache.tamaya.core.internal registered. If no adapter is defined (default) and no corresponding adapter is
* registered, it is handled as a deployment error.
*/
- Class<? extends ConfigOperator> value();
+ Class<? extends UnaryOperator<Configuration>> value();
}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/cca3d6f1/core/src/main/java/org/apache/tamaya/core/config/ConfigFunctions.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/tamaya/core/config/ConfigFunctions.java b/core/src/main/java/org/apache/tamaya/core/config/ConfigFunctions.java
index 473cd40..5ee8160 100644
--- a/core/src/main/java/org/apache/tamaya/core/config/ConfigFunctions.java
+++ b/core/src/main/java/org/apache/tamaya/core/config/ConfigFunctions.java
@@ -18,7 +18,7 @@
*/
package org.apache.tamaya.core.config;
-import org.apache.tamaya.ConfigOperator;
+import org.apache.tamaya.Configuration;
import org.apache.tamaya.PropertyProviderBuilder;
import java.util.*;
@@ -43,7 +43,7 @@ public final class ConfigFunctions {
* @param areaKey the area key, not null
* @return the area configuration, with the areaKey stripped away.
*/
- public static ConfigOperator selectArea(String areaKey) {
+ public static UnaryOperator<Configuration> selectArea(String areaKey) {
return selectArea(areaKey, true);
}
@@ -55,7 +55,7 @@ public final class ConfigFunctions {
* @param stripKeys if set to true, the area key is stripped away fromMap the resulting key.
* @return the area configuration, with the areaKey stripped away.
*/
- public static ConfigOperator selectArea(String areaKey, boolean stripKeys) {
+ public static UnaryOperator<Configuration> selectArea(String areaKey, boolean stripKeys) {
return config -> {
Map<String, String> area = new HashMap<>();
area.putAll(
@@ -89,7 +89,7 @@ public final class ConfigFunctions {
* @param areaKey the area key, not null
* @return the area configuration, with the areaKey stripped away.
*/
- public static ConfigOperator selectAreaRecursive(String areaKey) {
+ public static UnaryOperator<Configuration> selectAreaRecursive(String areaKey) {
return selectAreaRecursive(areaKey, true);
}
@@ -101,7 +101,7 @@ public final class ConfigFunctions {
* @param stripKeys if set to true, the area key is stripped away fromMap the resulting key.
* @return the area configuration, with the areaKey stripped away.
*/
- public static ConfigOperator selectAreaRecursive(String areaKey, boolean stripKeys) {
+ public static UnaryOperator<Configuration> selectAreaRecursive(String areaKey, boolean stripKeys) {
return config -> {
Map<String, String> area = new HashMap<>();
String lookupKey = areaKey + '.';
@@ -121,22 +121,23 @@ public final class ConfigFunctions {
* 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 ConfigOperator mapArea(String areaKey, String mappedAreaKey) {
+ public static UnaryOperator<Configuration> mapArea(String areaKey, String mappedAreaKey) {
return mapKeys(key -> key.startsWith(areaKey + '.')?
mappedAreaKey + key.substring(areaKey.length()):key);
}
/**
- * Creates a {@link ConfigOperator} that creates a {@link org.apache.tamaya.Configuration} that maps any keys as
+ * Creates a {@link 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 value, 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 ConfigOperator mapKeys(UnaryOperator<String> keyMapper) {
+ public static UnaryOperator<Configuration> mapKeys(UnaryOperator<String> keyMapper) {
return (c) -> new MappedConfiguration(c, keyMapper);
}