Browse Source

配置类的工具方法

pull/11/head
richie 5 years ago
parent
commit
25bdfff02d
  1. 75
      src/main/java/com/fanruan/api/conf/HolderKit.java
  2. 19
      src/main/java/com/fanruan/api/conf/impl/ColConf.java
  3. 19
      src/main/java/com/fanruan/api/conf/impl/MapConf.java
  4. 16
      src/main/java/com/fanruan/api/conf/impl/ObjConf.java
  5. 22
      src/main/java/com/fanruan/api/conf/impl/ObjectColConf.java
  6. 26
      src/main/java/com/fanruan/api/conf/impl/ObjectMapConf.java
  7. 17
      src/main/java/com/fanruan/api/conf/impl/SimConf.java

75
src/main/java/com/fanruan/api/conf/HolderKit.java

@ -1,7 +1,13 @@
package com.fanruan.api.conf;
import com.fanruan.api.conf.impl.ObjConf;
import com.fanruan.api.conf.impl.ObjectColConf;
import com.fanruan.api.conf.impl.ObjectMapConf;
import com.fanruan.api.conf.impl.SimConf;
import com.fr.config.holder.Conf;
import com.fr.config.holder.factory.Holders;
import java.util.Collection;
import java.util.Map;
/**
* @author richie
@ -11,11 +17,74 @@ import com.fr.config.holder.factory.Holders;
*/
public class HolderKit {
/**
* 初始化一个基本对象类型的配置
* @param t 初始值
* @param <T> 类型
* @return 配置对象
*/
public static <T> Conf<T> simple(T t) {
return Holders.simple(t);
return new SimConf<>(t);
}
/**
* 初始化一个对象类型的配置
* @param t 初始值
* @param type 对象class类
* @param <T> 类型
* @return 配置对象
*/
public static <T> Conf<T> obj(T t, Class<T> type) {
return Holders.obj(t, type);
return new ObjConf<>(t, type);
}
/**
* 初始化一个集合类型的配置
* @param collection 初始值
* @param type 对象class类型
* @param <T> 类型
* @return 配置对象
*/
public static <T> ObjectColConf<Collection<T>> objCollection(Collection<T> collection, Class<T> type) {
return new ObjectColConf<>(collection, type);
}
/**
* 初始化一个集合类型的配置
* @param collection 初始值
* @param type 对象class类型
* @param order 是否是有序的配置
* @param <T> 类型
* @return 配置对象
*/
public static <T> ObjectColConf<Collection<T>> objCollection(Collection<T> collection, Class<T> type, boolean order) {
return new ObjectColConf<>(collection, type, order);
}
/**
* 初始化一个字典类型的配置
* @param map 初始值
* @param keyType 键class类型
* @param valueType 值class类型
* @param <K> 键类型
* @param <V> 值类型
* @return 配置对象
*/
public static <K, V> ObjectMapConf<Map<K, V>> objMap(Map<K, V> map, Class<K> keyType, Class<V> valueType) {
return new ObjectMapConf<>(map, keyType, valueType);
}
/**
* 初始化一个字典类型的配置
* @param map 初始值
* @param keyType 键class类型
* @param valueType 值class类型
* @param order 是否是有序配置
* @param <K> 键类型
* @param <V> 值类型
* @return 配置对象
*/
public static <K, V> ObjectMapConf<Map<K, V>> objMap(Map<K, V> map, Class<K> keyType, Class<V> valueType, boolean order) {
return new ObjectMapConf<>(map, keyType, valueType, order);
}
}

19
src/main/java/com/fanruan/api/conf/impl/ColConf.java

@ -0,0 +1,19 @@
package com.fanruan.api.conf.impl;
import java.util.Collection;
/**
* @author richie
* @version 10.0
* Created by richie on 2019-08-19
*/
public class ColConf<T extends Collection> extends com.fr.config.holder.impl.ColConf<Collection> {
public ColConf(String property, Collection collection, Class valueType) {
super(property, collection, valueType);
}
public ColConf(Collection collection, Class valueType) {
super(collection, valueType);
}
}

19
src/main/java/com/fanruan/api/conf/impl/MapConf.java

@ -0,0 +1,19 @@
package com.fanruan.api.conf.impl;
import java.util.Map;
/**
* @author richie
* @version 10.0
* Created by richie on 2019-08-19
*/
public class MapConf<T extends Map> extends com.fr.config.holder.impl.MapConf<Map> {
public MapConf(String property, Map map, Class keyType, Class valueType) {
super(property, map, keyType, valueType);
}
public MapConf(Map map, Class keyType, Class valueType) {
super(map, keyType, valueType);
}
}

16
src/main/java/com/fanruan/api/conf/impl/ObjConf.java

@ -0,0 +1,16 @@
package com.fanruan.api.conf.impl;
/**
* @author richie
* @version 10.0
* Created by richie on 2019-08-19
*/
public class ObjConf<T> extends com.fr.config.holder.impl.ObjConf<T> {
public ObjConf(String property, T t, Class classType) {
super(property, t, classType);
}
public ObjConf(T t, Class classType) {
super(t, classType);
}
}

22
src/main/java/com/fanruan/api/conf/impl/ObjectColConf.java

@ -0,0 +1,22 @@
package com.fanruan.api.conf.impl;
import java.util.Collection;
/**
* @author richie
* @version 10.0
* Created by richie on 2019-08-19
*/
public class ObjectColConf<T extends Collection> extends com.fr.config.holder.impl.ObjectColConf<Collection> {
public ObjectColConf(String property, Collection collection, Class valueType) {
super(property, collection, valueType);
}
public ObjectColConf(Collection collection, Class valueType) {
super(collection, valueType);
}
public ObjectColConf(Collection collection, Class valueType, boolean order) {
super(collection, valueType, order);
}
}

26
src/main/java/com/fanruan/api/conf/impl/ObjectMapConf.java

@ -0,0 +1,26 @@
package com.fanruan.api.conf.impl;
import java.util.Map;
/**
* @author richie
* @version 10.0
* Created by richie on 2019-08-19
*/
public class ObjectMapConf<T extends Map> extends com.fr.config.holder.impl.ObjectMapConf<Map> {
public ObjectMapConf(String property, Map map, Class keyType, Class valueType) {
super(property, map, keyType, valueType);
}
public ObjectMapConf(String property, Map map, Class keyType, Class valueType, boolean order) {
super(property, map, keyType, valueType, order);
}
public ObjectMapConf(Map map, Class keyType, Class valueType, boolean order) {
super(map, keyType, valueType, order);
}
public ObjectMapConf(Map map, Class keyType, Class valueType) {
super(map, keyType, valueType);
}
}

17
src/main/java/com/fanruan/api/conf/impl/SimConf.java

@ -0,0 +1,17 @@
package com.fanruan.api.conf.impl;
/**
* @author richie
* @version 10.0
* Created by richie on 2019-08-19
*/
public class SimConf<T> extends com.fr.config.holder.impl.SimConf<T> {
public SimConf(T t) {
super(t);
}
public SimConf(String property, T t) {
super(property, t);
}
}
Loading…
Cancel
Save