// Path: spring-cloud-spring-service-connector/src/main/java/org/springframework/cloud/service/MapServiceConnectionConfigurer.java
// public class MapServiceConnectionConfigurer<SC, SCC extends MapServiceConnectorConfig>
// 		implements ServiceConnectorConfigurer<SC, SCC> {
// 	@Override
// 	public SC configure(SC serviceConnector, SCC config) {
// 		if (config != null) {
// 			Map<String, Object> properties = config.getConnectionProperties();
// 			if (properties != null) {
// 				BeanWrapper target = new BeanWrapperImpl(serviceConnector);
// 				target.setPropertyValues(new MutablePropertyValues(properties), true);
// 			}
// 		}
// 		return serviceConnector;
// 	}
// }
// 
// Path: spring-cloud-spring-service-connector/src/main/java/org/springframework/cloud/service/PooledServiceConnectorConfig.java
// public class PooledServiceConnectorConfig implements ServiceConnectorConfig {
// 	private PoolConfig poolConfig;
// 
// 	public PooledServiceConnectorConfig(PoolConfig poolConfig) {
// 		this.poolConfig = poolConfig;
// 	}
// 
// 	public PoolConfig getPoolConfig() {
// 		return poolConfig;
// 	}
// 
// 	public static class PoolConfig {
// 		private int minPoolSize;
// 		private int maxPoolSize;
// 		private int maxWaitTime;
// 
// 		public PoolConfig(int minPoolSize, int maxPoolSize, int maxWaitTime) {
// 			this.minPoolSize = minPoolSize;
// 			this.maxPoolSize = maxPoolSize;
// 			this.maxWaitTime = maxWaitTime;
// 		}
// 
// 		public PoolConfig(int maxPoolSize, int maxWaitTime) {
// 			this(0, maxPoolSize, maxWaitTime);
// 		}
// 
// 		public PoolConfig(String poolSize, int maxWaitTime) {
// 			determinePoolSizeRange(poolSize);
// 			this.maxWaitTime = maxWaitTime;
// 		}
// 
// 		/**
// 		 * @return property corresponding to DBCP {@code initialSize}
// 		 */
// 		public int getInitialSize() {
// 			return minPoolSize;
// 		}
// 
// 		/**
// 		 * @return property corresponding to DBCP {@code minIdle}
// 		 */
// 		public int getMinIdle() {
// 			return minPoolSize;
// 		}
// 
// 		/**
// 		 * @return property corresponding to DBCP {@code maxActive}
// 		 */
// 		public int getMaxActive() {
// 			return maxPoolSize;
// 		}
// 
// 		/**
// 		 * @return property corresponding to DBCP {@code maxWait}
// 		 */
// 		public int getMaxWait() {
// 			return maxWaitTime;
// 		}
// 
// 		/**
// 		 * @return property corresponding to commons-pool {@code maxTotal}
// 		 */
// 		public int getMaxTotal() {
// 			return maxPoolSize;
// 		}
// 
// 		/**
// 		 * @return property corresponding to commons-pool {@code maxWaitMillis}
// 		 */
// 		public int getMaxWaitMillis() {
// 			return maxWaitTime;
// 		}
// 
// 		/**
// 		 * @return property corresponding to HikariCP {@code minimumIdle}
// 		 */
// 		public int getMinimumIdle() {
// 			return minPoolSize;
// 		}
// 
// 		/**
// 		 * @return property corresponding to HikariCP {@code maximumPoolSize}
// 		 */
// 		public int getMaximumPoolSize() {
// 			return maxPoolSize;
// 		}
// 
// 		private void determinePoolSizeRange(String poolSize) {
// 			if (StringUtils.hasText(poolSize)) {
// 				try {
// 					int minPoolSize;
// 					int maxPoolSize;
// 					int separatorIndex = poolSize.indexOf('-');
// 					if (separatorIndex != -1) {
// 						minPoolSize = Integer.valueOf(poolSize.substring(0, separatorIndex));
// 						maxPoolSize = Integer.valueOf(poolSize.substring(separatorIndex + 1, poolSize.length()));
// 						if (minPoolSize > maxPoolSize) {
// 							throw new IllegalArgumentException(
// 									"Lower bound of pool-size range must not exceed the upper bound");
// 						}
// 					} else {
// 						Integer value = Integer.valueOf(poolSize);
// 						minPoolSize = 0;
// 						maxPoolSize = value;
// 					}
// 					this.minPoolSize = Integer.valueOf(minPoolSize);
// 					this.maxPoolSize = Integer.valueOf(maxPoolSize);
// 				} catch (NumberFormatException ex) {
// 					throw new IllegalArgumentException("Invalid pool-size value [" + poolSize + "]: only single " +
// 							"maximum integer (e.g. \"5\") and minimum-maximum range (e.g. \"3-5\") are supported", ex);
// 				}
// 			}
// 		}
// 	}
// }


import org.apache.commons.pool2.impl.GenericObjectPoolConfig;
import org.springframework.data.redis.connection.lettuce.LettuceClientConfiguration.LettuceClientConfigurationBuilder;
import org.springframework.data.redis.connection.lettuce.LettucePoolingClientConfiguration.LettucePoolingClientConfigurationBuilder;
import org.springframework.beans.BeanWrapper;
import org.springframework.beans.BeanWrapperImpl;
import org.springframework.cloud.service.MapServiceConnectionConfigurer;
import org.springframework.cloud.service.MapServiceConnectorConfig;
import org.springframework.cloud.service.PooledServiceConnectorConfig;
import org.springframework.cloud.service.ServiceConnectorConfigurer;
import org.springframework.cloud.service.Util;
package org.springframework.cloud.service.keyval;



/**
 * 
 * @author Scott Frederick
 *
 */
public class RedisLettuceClientConfigurer implements ServiceConnectorConfigurer<LettuceClientConfigurationBuilder, RedisConnectionFactoryConfig> {
	private MapServiceConnectionConfigurer<LettuceClientConfigurationBuilder, MapServiceConnectorConfig> mapClientConfigurer =
			new MapServiceConnectionConfigurer<>();

	@Override
	public LettuceClientConfigurationBuilder configure(LettuceClientConfigurationBuilder clientConfiguration, RedisConnectionFactoryConfig config) {
		if (config != null) {
			configurePool(clientConfiguration, config);
			configureClient(clientConfiguration, config);
		}
// Path: spring-cloud-spring-service-connector/src/main/java/org/springframework/cloud/service/MapServiceConnectionConfigurer.java
// public class MapServiceConnectionConfigurer<SC, SCC extends MapServiceConnectorConfig>
// 		implements ServiceConnectorConfigurer<SC, SCC> {
// 	@Override
// 	public SC configure(SC serviceConnector, SCC config) {
// 		if (config != null) {
// 			Map<String, Object> properties = config.getConnectionProperties();
// 			if (properties != null) {
// 				BeanWrapper target = new BeanWrapperImpl(serviceConnector);
// 				target.setPropertyValues(new MutablePropertyValues(properties), true);
// 			}
// 		}
// 		return serviceConnector;
// 	}
// }
// 
// Path: spring-cloud-spring-service-connector/src/main/java/org/springframework/cloud/service/PooledServiceConnectorConfig.java
// public class PooledServiceConnectorConfig implements ServiceConnectorConfig {
// 	private PoolConfig poolConfig;
// 
// 	public PooledServiceConnectorConfig(PoolConfig poolConfig) {
// 		this.poolConfig = poolConfig;
// 	}
// 
// 	public PoolConfig getPoolConfig() {
// 		return poolConfig;
// 	}
// 
// 	public static class PoolConfig {
// 		private int minPoolSize;
// 		private int maxPoolSize;
// 		private int maxWaitTime;
// 
// 		public PoolConfig(int minPoolSize, int maxPoolSize, int maxWaitTime) {
// 			this.minPoolSize = minPoolSize;
// 			this.maxPoolSize = maxPoolSize;
// 			this.maxWaitTime = maxWaitTime;
// 		}
// 
// 		public PoolConfig(int maxPoolSize, int maxWaitTime) {
// 			this(0, maxPoolSize, maxWaitTime);
// 		}
// 
// 		public PoolConfig(String poolSize, int maxWaitTime) {
// 			determinePoolSizeRange(poolSize);
// 			this.maxWaitTime = maxWaitTime;
// 		}
// 
// 		/**
// 		 * @return property corresponding to DBCP {@code initialSize}
// 		 */
// 		public int getInitialSize() {
// 			return minPoolSize;
// 		}
// 
// 		/**
// 		 * @return property corresponding to DBCP {@code minIdle}
// 		 */
// 		public int getMinIdle() {
// 			return minPoolSize;
// 		}
// 
// 		/**
// 		 * @return property corresponding to DBCP {@code maxActive}
// 		 */
// 		public int getMaxActive() {
// 			return maxPoolSize;
// 		}
// 
// 		/**
// 		 * @return property corresponding to DBCP {@code maxWait}
// 		 */
// 		public int getMaxWait() {
// 			return maxWaitTime;
// 		}
// 
// 		/**
// 		 * @return property corresponding to commons-pool {@code maxTotal}
// 		 */
// 		public int getMaxTotal() {
// 			return maxPoolSize;
// 		}
// 
// 		/**
// 		 * @return property corresponding to commons-pool {@code maxWaitMillis}
// 		 */
// 		public int getMaxWaitMillis() {
// 			return maxWaitTime;
// 		}
// 
// 		/**
// 		 * @return property corresponding to HikariCP {@code minimumIdle}
// 		 */
// 		public int getMinimumIdle() {
// 			return minPoolSize;
// 		}
// 
// 		/**
// 		 * @return property corresponding to HikariCP {@code maximumPoolSize}
// 		 */
// 		public int getMaximumPoolSize() {
// 			return maxPoolSize;
// 		}
// 
// 		private void determinePoolSizeRange(String poolSize) {
// 			if (StringUtils.hasText(poolSize)) {
// 				try {
// 					int minPoolSize;
// 					int maxPoolSize;
// 					int separatorIndex = poolSize.indexOf('-');
// 					if (separatorIndex != -1) {
// 						minPoolSize = Integer.valueOf(poolSize.substring(0, separatorIndex));
// 						maxPoolSize = Integer.valueOf(poolSize.substring(separatorIndex + 1, poolSize.length()));
// 						if (minPoolSize > maxPoolSize) {
// 							throw new IllegalArgumentException(
// 									"Lower bound of pool-size range must not exceed the upper bound");
// 						}
// 					} else {
// 						Integer value = Integer.valueOf(poolSize);
// 						minPoolSize = 0;
// 						maxPoolSize = value;
// 					}
// 					this.minPoolSize = Integer.valueOf(minPoolSize);
// 					this.maxPoolSize = Integer.valueOf(maxPoolSize);
// 				} catch (NumberFormatException ex) {
// 					throw new IllegalArgumentException("Invalid pool-size value [" + poolSize + "]: only single " +
// 							"maximum integer (e.g. \"5\") and minimum-maximum range (e.g. \"3-5\") are supported", ex);
// 				}
// 			}
// 		}
// 	}
// }


// Path: spring-cloud-spring-service-connector/src/main/java/org/springframework/cloud/service/keyval/RedisLettuceClientConfigurer.java
import org.apache.commons.pool2.impl.GenericObjectPoolConfig;
import org.springframework.data.redis.connection.lettuce.LettuceClientConfiguration.LettuceClientConfigurationBuilder;
import org.springframework.data.redis.connection.lettuce.LettucePoolingClientConfiguration.LettucePoolingClientConfigurationBuilder;
import org.springframework.beans.BeanWrapper;
import org.springframework.beans.BeanWrapperImpl;
import org.springframework.cloud.service.MapServiceConnectionConfigurer;
import org.springframework.cloud.service.MapServiceConnectorConfig;
import org.springframework.cloud.service.PooledServiceConnectorConfig;
import org.springframework.cloud.service.ServiceConnectorConfigurer;
import org.springframework.cloud.service.Util;

package org.springframework.cloud.service.keyval;



/**
 * 
 * @author Scott Frederick
 *
 */
public class RedisLettuceClientConfigurer implements ServiceConnectorConfigurer<LettuceClientConfigurationBuilder, RedisConnectionFactoryConfig> {
	private MapServiceConnectionConfigurer<LettuceClientConfigurationBuilder, MapServiceConnectorConfig> mapClientConfigurer =
			new MapServiceConnectionConfigurer<>();

	@Override
	public LettuceClientConfigurationBuilder configure(LettuceClientConfigurationBuilder clientConfiguration, RedisConnectionFactoryConfig config) {
		if (config != null) {
			configurePool(clientConfiguration, config);
			configureClient(clientConfiguration, config);
		}
		return clientConfiguration;