package com.community.pocket.ui.main.ui.share; import android.content.Context; import androidx.annotation.Nullable; /** * 响应体父类 * * @param */ public abstract class Response { //成功描述 @Nullable private Integer success; //失败描述 @Nullable private Integer error; private Object[] args; //响应体 private T body; @Nullable public Integer getSuccess() { return success; } public void setSuccess(@Nullable Integer success, Object... args) { this.success = success; this.args = args; } @Nullable public Integer getError() { return error; } public void setError(@Nullable Integer error, Object... args) { this.error = error; this.args = args; } public T getBody() { return body; } public void setBody(T body) { this.body = body; } public String ok(Context context) { if (success != null) { return context.getString(success, args); } return null; } public String fail(Context context) { if (error != null) { return context.getString(error, args); } return null; } public Object[] getArgs() { return args; } public void setArgs(Object[] args) { this.args = args; } }