本文整理了Java中org.nutz.lang.Lang.map2Object()
方法的一些代码示例,展示了Lang.map2Object()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Lang.map2Object()
方法的具体详情如下:
包路径:org.nutz.lang.Lang
类名称:Lang
方法名:map2Object
[英]根据一个 Map,和给定的对象类型,创建一个新的 JAVA 对象
[中]根据一个 地图和给定的对象类型,创建一个新的 JAVA对象
代码示例来源:origin: nutzam/nutz
/**
* 根据指定的类的类型,把该记录转换成该类型的对象
*
* @param type 指定的类的类型
* @return 指定的类型的对象
*/
public <T> T toPojo(Class<T> type) {
return Lang.map2Object(map, type);
}
代码示例来源:origin: nutzam/nutz
@Override
public Object cast(Map src, Class<?> toType, String... args) throws FailToCastObjectException {
return Lang.map2Object(src, toType);
}
代码示例来源:origin: nutzam/nutz
v = map.get("events");
if (null != v) {
IocEventSet ies = Lang.map2Object((Map<?, ?>) v, IocEventSet.class);
iobj.setEvents(ies);
代码示例来源:origin: org.nutz/nutz
/**
* 根据指定的类的类型,把该记录转换成该类型的对象
*
* @param type 指定的类的类型
* @return 指定的类型的对象
*/
public <T> T toPojo(Class<T> type) {
return Lang.map2Object(map, type);
}
代码示例来源:origin: nutzam/nutzwx
public WxUser user() {
return Lang.map2Object(this, WxUser.class);
}
代码示例来源:origin: org.nutz/nutz
@Override
public Object cast(Map src, Class<?> toType, String... args) throws FailToCastObjectException {
return Lang.map2Object(src, toType);
}
代码示例来源:origin: nutzam/nutzwx
public List<WxGroup> listGroup() {
Map<String, Object> map = call("/groups/get", METHOD.GET, null);
List<Map<String, Object>> list = (List<Map<String, Object>>) map.get("groups");
List<WxGroup> groups = new ArrayList<WxGroup>();
for (Map<String, Object> e : list) {
groups.add(Lang.map2Object(e, WxGroup.class));
}
return groups;
}
代码示例来源:origin: nutzam/nutzwx
public WxUser fetchUser(String openid, String lang) {
if (lang == null)
lang = "zh_CN";
Map<String, Object> map = call("/user/info?openid=" + openid + "&lang=" + openid,
METHOD.GET,
null);
return Lang.map2Object(map, WxUser.class);
}
代码示例来源:origin: nutzam/nutzwx
public WxMenu fetchMenu() {
Map<String, Object> map = call("/menu/get", METHOD.GET, null);
return Lang.map2Object((Map<String, Object>) map.get("menu"), WxMenu.class);
}
代码示例来源:origin: nutzam/nutzwx
public <T> List<T> getTo(String key, Class<T> klass) {
List<Object> tmp = getList(key, Object.class);
if (tmp == null)
return null;
List<T> list = new ArrayList<T>();
for (Object obj : tmp) {
if (obj instanceof Map) {
list.add(Lang.map2Object((Map)obj, klass));
}
}
return list;
}
}
代码示例来源:origin: nutzam/nutzwx
public WxGroup group() {
Map map = getAs("group", Map.class);
if (map == null)
return null;
return Lang.map2Object(map, WxGroup.class);
}
代码示例来源:origin: nutzam/nutzwx
public List<WxGroup> groups() {
List<Map<String, Object>> list = getAs("groups", List.class);
List<WxGroup> groups = new ArrayList<WxGroup>();
for (Map<String, Object> e : list) {
groups.add(Lang.map2Object(e, WxGroup.class));
}
return groups;
}
代码示例来源:origin: nutzam/nutzwx
public WxAccessToken get() {
Map<String, String> map;
Jedis jedis = null;
try {
jedis = jedisAgent.getResource();
map = jedis.hgetAll(tokenKey);
} finally {
Streams.safeClose(jedis);
}
if (map == null || map.isEmpty())
return null;
return Lang.map2Object(map, WxAccessToken.class);
}
代码示例来源:origin: nutzam/nutzwx
@SuppressWarnings({ "unchecked", "rawtypes" })
public void setPath(String path) {
PropertiesProxy pp = new PropertiesProxy(path);
Map<String, Object> map = new LinkedHashMap(pp.toMap());
if (pp.get("openid") != null) {
String appid = pp.get("openid");
WxMaster def = Lang.map2Object(map, WxMaster.class);
masters.put(appid, def);
apis.put(appid, new WxApiImpl(def));
handlers.put(appid, new BasicWxHandler(def.getToken()));
}
for (Entry<String, Object> en : map.entrySet()) {
String key = en.getKey();
if (key.endsWith(".openid")) {
key = key.substring(0, key.indexOf('.'));
Map<String, Object> tmp = filter(map, key + ".", null, null, null);
String openid = tmp.get("openid").toString();
WxMaster one = Lang.map2Object(tmp, WxMaster.class);
masters.put(openid, one);
apis.put(openid, new WxApiImpl(one));
handlers.put(openid, new BasicWxHandler(one.getToken()));
}
}
}
代码示例来源:origin: nutzam/nutzwx
public WxGroup createGroup(WxGroup group) {
Map<String, Object> map = call("/groups/create",
METHOD.POST,
Json.toJson(new NutMap().setv("group", group)));
return Lang.map2Object((Map<String, Object>) map.get("group"), WxGroup.class);
}
代码示例来源:origin: nutzam/nutzwx
@Override
@SuppressWarnings("rawtypes")
public List<WxArticle> get_material_news(String media_id) {
try {
NutMap re = Json.fromJson(NutMap.class, get_material(media_id).getReader());
List<WxArticle> list = new ArrayList<WxArticle>();
for (Object obj : re.getAs("news_item", List.class)) {
list.add(Lang.map2Object((Map) obj, WxArticle.class));
}
return list;
}
catch (Exception e) {
throw Lang.wrapThrow(e);
}
}
代码示例来源:origin: nutzam/nutzwx
log.debug("Income >> \n" + Json.toJson(map));
T t = Lang.map2Object(map, klass);
if (t instanceof WxInMsg)
((WxInMsg) t).raw(raw);
代码示例来源:origin: org.nutz/nutz
v = map.get("events");
if (null != v) {
IocEventSet ies = Lang.map2Object((Map<?, ?>) v, IocEventSet.class);
iobj.setEvents(ies);
内容来源于网络,如有侵权,请联系作者删除!