All Downloads are FREE. Search and download functionalities are using the official Maven repository.

cn.ennwifi.webframe.codes.ErrorCode Maven / Gradle / Ivy

There is a newer version: 2.3.0
Show newest version
package cn.ennwifi.webframe.codes;


/**
 * 错误代码条目.
 *
 * @author zhangjianshe
 */
public class ErrorCode {

    /**
     * The code.
     */
    public Integer code;

    /**
     * The message.
     */
    public String message;

    /**
     * Instantiates a new error code.
     *
     * @param code    the code
     * @param message the message
     */
    public ErrorCode(Integer code, String message) {
    this.code = code;
    this.message = message;
  }


    /**
     * Bind.
     *
     * @param objects the objects
     * @return the error code
     */
    public ErrorCode bind(Object... objects) {
    if (objects == null) {
      return this;
    }

    String str = message;
    for (int i = 0; i < objects.length; i++) {
      Object object = objects[i];
      if (object == null) {
        object = "null";
      }
      str = str.replaceAll("\\$\\{" + i + "\\}", object.toString());
    }
    return new ErrorCode(code, str);
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy