/**
 * 
 */
package com.infogen.util;

import java.io.IOException;
import java.util.HashMap;

import org.apache.log4j.Logger;

import com.fasterxml.jackson.core.type.TypeReference;
import com.infogen.tools.Tool_Jackson;

/**
 * 接口返回值封装
 * 
 * @author larry
 * @email larry.lv.word@gmail.com
 * @version 创建时间 2013-4-11 下午7:57:11
 */
public class Return extends HashMap<String, Object> {
	private static final long serialVersionUID = 2203513787220720192L;
	public static final Logger logger = Logger.getLogger(Return.class.getName());

	public enum Return_Fields {
		success, code, note
	}

	public static Return create(String json) {
		Return jo = new Return();
		HashMap<String, Object> fromJson;
		try {
			fromJson = Tool_Jackson.toObject(json, new TypeReference<HashMap<String, Object>>() {
			});
			fromJson.forEach((k, v) -> {
				jo.put(k, v);
			});
		} catch (IOException e) {
			logger.error("Return.create 解析 JSON 失败", e);
		}
		return jo;
	}

	public static Return SUCCESS(Integer code, String note) {
		Return jo = new Return();
		jo.put(Return_Fields.success.name(), true);
		jo.put(Return_Fields.note.name(), note);
		jo.put(Return_Fields.code.name(), code);
		return jo;
	}

	public static Return FAIL(Integer code, String note) {
		Return jo = new Return();
		jo.put(Return_Fields.success.name(), false);
		jo.put(Return_Fields.note.name(), note);
		jo.put(Return_Fields.code.name(), code);
		return jo;
	}

	public Return put(String key, Object value) {
		super.put(key, value);
		return this;
	}

	public Boolean get_success() {
		return (Boolean) this.getOrDefault(Return_Fields.success.name(), false);
	}

	public Integer get_code() {
		return (Integer) this.getOrDefault(Return_Fields.code.name(), CODE._500.code);
	}

	public String get_note() {
		return (String) this.getOrDefault(Return_Fields.note.name(), "");
	}

	public String toJson() {
		try {
			return Tool_Jackson.toJson(this);
		} catch (Exception e) {
			logger.error("json 解析失败:", e);
			return Tool_Jackson.toJson(Return.FAIL(CODE._510.code, CODE._510.name()));
		}
	}

}

@@ -92,16 +92,96 @@
 ashMap;%0D
+%0Aimport java.util.Iterator;%0D%0Aimport java.util.Map.Entry;%0D%0Aimport java.util.Set;%0D
 %0A%0D%0Aimpor
@@ -764,16 +764,22 @@
 urn();%0D%0A
+%09%09/*%0D%0A
 %09%09HashMa
@@ -966,16 +966,16 @@
 k, v);%0D%0A
-
 %09%09%09%7D);%0D%0A
@@ -1057,16 +1057,497 @@
 ;%0D%0A%09%09%7D%0D%0A
+%09%09*/%0D%0A%09%09HashMap%3CString, Object%3E fromJsons;%0D%0A%09%09try %7B%0D%0A%09%09%09fromJsons = Tool_Jackson.toObject(json, new TypeReference%3CHashMap%3CString, Object%3E%3E() %7B%0D%0A%09%09%09%7D);%0D%0A%09%09%09Iterator%3CEntry%3CString, Object%3E%3E iter = fromJsons.entrySet().iterator(); %0D%0A%0D%0A%09%09%09while(iter.hasNext())%7B %0D%0A%09%09%09%09HashMap.Entry entry = (HashMap.Entry)iter.next();%0D%0A%09%09%09%09Object key = entry.getKey(); %0D%0A%09%09%09%09Object val = entry.getValue(); %0D%0A%09%09%09%7D %0D%0A%09%09%09%0D%0A%09%09%7D catch (IOException e) %7B%0D%0A%09%09%09logger.error(%22Return.create %E8%A7%A3%E6%9E%90 JSON %E5%A4%B1%E8%B4%A5%22, e);%0D%0A%09%09%7D%0D%0A
 %09%09return

修改return中的lambda表达式，换成普通的循环