com.soento.core.lang.BaseObject Maven / Gradle / Ivy
package com.soento.core.lang;
import com.soento.core.util.BeanUtil;
import com.soento.core.util.JsonUtil;
import com.soento.core.util.StringUtil;
import java.io.Serializable;
import java.util.Map;
/**
* @author yantao.zeng
*/
public abstract class BaseObject implements Serializable {
private static final long serialVersionUID = -4593981250226117054L;
@Override
public String toString() {
return StringUtil.toSimpleString(this);
}
public Map toMap() {
try {
return (Map) BeanUtil.describe(this);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
public String toJson() {
return JsonUtil.toJson(this);
}
public String prettyJson() {
return JsonUtil.prettyJson(this);
}
public String toJsonp(String function) {
return JsonUtil.toJsonp(function, this);
}
}