// Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/factory/ReplyEnumFactory.java
// public enum ReplyEnumFactory {
//     TEXT("text", new TextReplyBuilder()),
//     NEWS("news", new NewsReplyBuilder()),
//     MUSIC("music", new MusicReplyBuilder()),
//     IMAGE("image", new ImageReplyBuilder()),
//     VOICE("voice", new VoiceReplyBuilder()),
//     VIDEO("video", new VideoReplyBuilder());
// 
//     private String replyType;
//     private ReplyBuilder replyBuilder;
// 
//     private ReplyEnumFactory(String replyType, ReplyBuilder replyBuilder) {
//         this.replyType = replyType;
//         this.replyBuilder = replyBuilder;
//     }
// 
//     public String getReplyType() {
//         return replyType;
//     }
// 
//     public Reply buildReply(List<ReplyDetail> replyDetails) {
//         if (replyDetails == null || replyDetails.isEmpty()) {
//             return null;
//         }
// 
//         return replyBuilder.buildReply(replyDetails);
//     }
// 
// }
// 
// Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/vo/push/Push.java
// @XmlRootElement(name = "xml")
// @XmlAccessorType(XmlAccessType.FIELD)
// public abstract class Push extends AbstractToStringBuilder{
//     @XmlElement(name = "ToUserName")
//     private String toUserName;
// 
//     @XmlElement(name = "FromUserName")
//     private String fromUserName;
// 
//     @XmlElement(name = "CreateTime")
//     private long createTime;
// 
//     @XmlElement(name = "MsgType")
//     private String msgType;
// 
//     @XmlElement(name = "MsgId")
//     private String msgId;
// 
//     public String getToUserName() {
//         return toUserName;
//     }
// 
//     public void setToUserName(String toUserName) {
//         this.toUserName = toUserName;
//     }
// 
//     public String getFromUserName() {
//         return fromUserName;
//     }
// 
//     public void setFromUserName(String fromUserName) {
//         this.fromUserName = fromUserName;
//     }
// 
//     public long getCreateTime() {
//         return createTime;
//     }
// 
//     public void setCreateTime(long createTime) {
//         this.createTime = createTime;
//     }
// 
//     public String getMsgType() {
//         return msgType;
//     }
// 
//     public void setMsgType(String msgType) {
//         this.msgType = msgType;
//     }
// 
//     public String getMsgId() {
//         return msgId;
//     }
// 
//     public void setMsgId(String msgId) {
//         this.msgId = msgId;
//     }
// 
// }


import java.util.Arrays;
import org.apache.commons.beanutils.BeanUtils;
import org.apache.commons.lang3.EnumUtils;
import org.apache.commons.lang3.StringUtils;
import org.usc.wechat.mp.sdk.factory.ReplyEnumFactory;
import org.usc.wechat.mp.sdk.vo.ReplyDetail;
import org.usc.wechat.mp.sdk.vo.ReplyDetailWarpper;
import org.usc.wechat.mp.sdk.vo.message.reply.Reply;
import org.usc.wechat.mp.sdk.vo.push.Push;
package org.usc.wechat.mp.sdk.util;



/**
 *
 * @author Shunli
 */
public class ReplyUtil {
    public static Reply buildReply(Reply reply, Push push) {
        try {
            if (reply != null) {
                // keep is new instance
                Reply newReply = (Reply) BeanUtils.cloneBean(reply);

                newReply.setCreateTime(getUnixTimeStamp());
                newReply.setToUserName(push.getFromUserName());
                newReply.setFromUserName(push.getToUserName());

                return newReply;
            }
        } catch (Exception e) {
        }

        return null;
    }

    public static long getUnixTimeStamp() {
        return System.currentTimeMillis() / 1000;
    }

    public static Reply parseReplyDetailWarpper(ReplyDetailWarpper replyDetailWarpper) {
        if (replyDetailWarpper == null) {
            return null;
        }

        String replyType = replyDetailWarpper.getReplyType();
// Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/factory/ReplyEnumFactory.java
// public enum ReplyEnumFactory {
//     TEXT("text", new TextReplyBuilder()),
//     NEWS("news", new NewsReplyBuilder()),
//     MUSIC("music", new MusicReplyBuilder()),
//     IMAGE("image", new ImageReplyBuilder()),
//     VOICE("voice", new VoiceReplyBuilder()),
//     VIDEO("video", new VideoReplyBuilder());
// 
//     private String replyType;
//     private ReplyBuilder replyBuilder;
// 
//     private ReplyEnumFactory(String replyType, ReplyBuilder replyBuilder) {
//         this.replyType = replyType;
//         this.replyBuilder = replyBuilder;
//     }
// 
//     public String getReplyType() {
//         return replyType;
//     }
// 
//     public Reply buildReply(List<ReplyDetail> replyDetails) {
//         if (replyDetails == null || replyDetails.isEmpty()) {
//             return null;
//         }
// 
//         return replyBuilder.buildReply(replyDetails);
//     }
// 
// }
// 
// Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/vo/push/Push.java
// @XmlRootElement(name = "xml")
// @XmlAccessorType(XmlAccessType.FIELD)
// public abstract class Push extends AbstractToStringBuilder{
//     @XmlElement(name = "ToUserName")
//     private String toUserName;
// 
//     @XmlElement(name = "FromUserName")
//     private String fromUserName;
// 
//     @XmlElement(name = "CreateTime")
//     private long createTime;
// 
//     @XmlElement(name = "MsgType")
//     private String msgType;
// 
//     @XmlElement(name = "MsgId")
//     private String msgId;
// 
//     public String getToUserName() {
//         return toUserName;
//     }
// 
//     public void setToUserName(String toUserName) {
//         this.toUserName = toUserName;
//     }
// 
//     public String getFromUserName() {
//         return fromUserName;
//     }
// 
//     public void setFromUserName(String fromUserName) {
//         this.fromUserName = fromUserName;
//     }
// 
//     public long getCreateTime() {
//         return createTime;
//     }
// 
//     public void setCreateTime(long createTime) {
//         this.createTime = createTime;
//     }
// 
//     public String getMsgType() {
//         return msgType;
//     }
// 
//     public void setMsgType(String msgType) {
//         this.msgType = msgType;
//     }
// 
//     public String getMsgId() {
//         return msgId;
//     }
// 
//     public void setMsgId(String msgId) {
//         this.msgId = msgId;
//     }
// 
// }


// Path: wechat-mp-sdk/src/main/java/org/usc/wechat/mp/sdk/util/ReplyUtil.java
import java.util.Arrays;
import org.apache.commons.beanutils.BeanUtils;
import org.apache.commons.lang3.EnumUtils;
import org.apache.commons.lang3.StringUtils;
import org.usc.wechat.mp.sdk.factory.ReplyEnumFactory;
import org.usc.wechat.mp.sdk.vo.ReplyDetail;
import org.usc.wechat.mp.sdk.vo.ReplyDetailWarpper;
import org.usc.wechat.mp.sdk.vo.message.reply.Reply;
import org.usc.wechat.mp.sdk.vo.push.Push;

package org.usc.wechat.mp.sdk.util;



/**
 *
 * @author Shunli
 */
public class ReplyUtil {
    public static Reply buildReply(Reply reply, Push push) {
        try {
            if (reply != null) {
                // keep is new instance
                Reply newReply = (Reply) BeanUtils.cloneBean(reply);

                newReply.setCreateTime(getUnixTimeStamp());
                newReply.setToUserName(push.getFromUserName());
                newReply.setFromUserName(push.getToUserName());

                return newReply;
            }
        } catch (Exception e) {
        }

        return null;
    }

    public static long getUnixTimeStamp() {
        return System.currentTimeMillis() / 1000;
    }

    public static Reply parseReplyDetailWarpper(ReplyDetailWarpper replyDetailWarpper) {
        if (replyDetailWarpper == null) {
            return null;
        }

        String replyType = replyDetailWarpper.getReplyType();
        ReplyEnumFactory replyEnumFactory = EnumUtils.getEnum(ReplyEnumFactory.class, StringUtils.upperCase(replyType));