From 4cf1896c76f3fc48b2783a5cef9ba424f133f0fb Mon Sep 17 00:00:00 2001 From: richie Date: Thu, 15 Aug 2019 20:29:29 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=84=E5=88=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- readme.md | 2 +- .../java/com/fanruan/api/conf/HolderKit.java | 21 +++++++++++++++++++ .../com/fanruan/api/util/GeneralUtils.java | 18 ++++++++++++++++ 3 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 src/main/java/com/fanruan/api/conf/HolderKit.java diff --git a/readme.md b/readme.md index 827473f..2190522 100644 --- a/readme.md +++ b/readme.md @@ -24,7 +24,7 @@ SessionKit#getSession(@NotNull String sessionID); ## 提交新API要求 -* 所有的API方法的返回值和参数,仅允许使用基本类型或者接口类型。 +* 所有的API方法的返回值和参数,仅允许使用基本类型、接口类型或者使用了@API标记的对象类型。 * 所有的API方法均需要有单元测试覆盖。 diff --git a/src/main/java/com/fanruan/api/conf/HolderKit.java b/src/main/java/com/fanruan/api/conf/HolderKit.java new file mode 100644 index 0000000..cb93332 --- /dev/null +++ b/src/main/java/com/fanruan/api/conf/HolderKit.java @@ -0,0 +1,21 @@ +package com.fanruan.api.conf; + +import com.fr.config.holder.Conf; +import com.fr.config.holder.factory.Holders; + +/** + * @author richie + * @version 10.0 + * Created by richie on 2019-08-15 + * 配置对象操作类 + */ +public class HolderKit { + + public static Conf simple(T t) { + return Holders.simple(t); + } + + public static Conf obj(T t, Class type) { + return Holders.obj(t, type); + } +} diff --git a/src/main/java/com/fanruan/api/util/GeneralUtils.java b/src/main/java/com/fanruan/api/util/GeneralUtils.java index 1e9e8c3..1db7f3f 100644 --- a/src/main/java/com/fanruan/api/util/GeneralUtils.java +++ b/src/main/java/com/fanruan/api/util/GeneralUtils.java @@ -17,4 +17,22 @@ public class GeneralUtils { public static String getMacAddress() throws IOException { return com.fr.general.GeneralUtils.getMacAddress(); } + + /** + * 任意对象转换为文本值 + * @param obj 待转换的对象 + * @return 文本值 + */ + public static String objectToString(Object obj) { + return com.fr.general.GeneralUtils.objectToString(obj); + } + + /** + * 任意对象转换为数值 + * @param obj 待转换的对象 + * @return 数值 + */ + public static Number objectToNumber(Object obj) { + return com.fr.general.GeneralUtils.objectToNumber(obj); + } }