You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

73 lines
1.4 KiB

package com.community.pocket.ui.main.ui.share;
import android.content.Context;
import androidx.annotation.Nullable;
/**
* 响应体父类
*
* @param <T>
*/
public abstract class Response<T> {
//成功描述
@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;
}
}