为WxError加入builder模式支持
This commit is contained in:
@@ -5,8 +5,7 @@ import me.chanjar.weixin.common.util.json.WxGsonBuilder;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 微信错误码说明
|
||||
* http://mp.weixin.qq.com/wiki/index.php?title=全局返回码说明
|
||||
* 微信错误码说明,请阅读: <a href="http://mp.weixin.qq.com/wiki/10/6380dc743053a91c544ffd2b7c959166.html">全局返回码说明</a>
|
||||
* @author Daniel Qian
|
||||
*
|
||||
*/
|
||||
@@ -54,4 +53,30 @@ public class WxError implements Serializable {
|
||||
return "微信错误: errcode=" + errorCode + ", errmsg=" + errorMsg + "\njson:" + json;
|
||||
}
|
||||
|
||||
public static Builder newBuilder(){
|
||||
return new Builder();
|
||||
}
|
||||
|
||||
public static class Builder{
|
||||
private int errorCode;
|
||||
private String errorMsg;
|
||||
|
||||
public Builder setErrorCode(int errorCode) {
|
||||
this.errorCode = errorCode;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setErrorMsg(String errorMsg) {
|
||||
this.errorMsg = errorMsg;
|
||||
return this;
|
||||
}
|
||||
|
||||
public WxError build(){
|
||||
WxError wxError = new WxError();
|
||||
wxError.setErrorCode(this.errorCode);
|
||||
wxError.setErrorMsg(this.errorMsg);
|
||||
return wxError;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user