refactor(SearchUserBean.java): 使用 Kotlin 重写

This commit is contained in:
GoFly233 2020-08-13 20:24:35 +08:00 committed by HuanChengFly
parent a7a1942092
commit 2bb06f0b94
2 changed files with 52 additions and 102 deletions

View File

@ -1,132 +1,82 @@
package com.huanchengfly.tieba.api.models; package com.huanchengfly.tieba.api.models
import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.JsonAdapter
import com.google.gson.annotations.SerializedName; import com.google.gson.annotations.SerializedName
import com.huanchengfly.tieba.api.adapters.UserExactMatchAdapter; import com.huanchengfly.tieba.api.adapters.UserExactMatchAdapter
import com.huanchengfly.tieba.api.adapters.UserFuzzyMatchAdapter; import com.huanchengfly.tieba.api.adapters.UserFuzzyMatchAdapter
import com.huanchengfly.tieba.post.models.BaseBean; import com.huanchengfly.tieba.post.models.BaseBean
import java.util.List; class SearchUserBean : BaseBean() {
public class SearchUserBean extends BaseBean {
@SerializedName("no") @SerializedName("no")
private int errorCode; val errorCode: Int? = null
@SerializedName("error") @SerializedName("error")
private String errorMsg; val errorMsg: String? = null
private SearchUserDataBean data; val data: SearchUserDataBean? = null
public SearchUserDataBean getData() { class SearchUserDataBean {
return data;
}
public int getErrorCode() {
return errorCode;
}
public String getErrorMsg() {
return errorMsg;
}
public static class SearchUserDataBean {
@SerializedName("pn") @SerializedName("pn")
private int pageNum; val pageNum: Int? = null
@SerializedName("has_more") @SerializedName("has_more")
private int hasMore; val hasMore: Int? = null
@JsonAdapter(UserExactMatchAdapter.class)
private UserBean exactMatch;
@JsonAdapter(UserFuzzyMatchAdapter.class)
private List<UserBean> fuzzyMatch;
public int getPageNum() { @JsonAdapter(UserExactMatchAdapter::class)
return pageNum; val exactMatch: UserBean? = null
}
public int getHasMore() { @JsonAdapter(UserFuzzyMatchAdapter::class)
return hasMore; val fuzzyMatch: List<UserBean>? = null
}
public UserBean getExactMatch() {
return exactMatch;
}
public List<UserBean> getFuzzyMatch() {
return fuzzyMatch;
}
} }
public static class UserBean { class UserBean {
private String id; var id: String? = null
private String intro; var intro: String? = null
@SerializedName("user_nickname") @SerializedName("user_nickname")
private String userNickname; var userNickname: String? = null
private String name; var name: String? = null
private String portrait; var portrait: String? = null
@SerializedName("fans_num") @SerializedName("fans_num")
private String fansNum; var fansNum: String? = null
@SerializedName("has_concerned") @SerializedName("has_concerned")
private int hasConcerned; var hasConcerned = 0
public String getId() { fun setId(id: String?): UserBean {
return id; this.id = id
return this
} }
public UserBean setId(String id) { fun setIntro(intro: String?): UserBean {
this.id = id; this.intro = intro
return this; return this
} }
public String getIntro() { fun setUserNickname(userNickname: String?): UserBean {
return intro; this.userNickname = userNickname
return this
} }
public UserBean setIntro(String intro) { fun setName(name: String?): UserBean {
this.intro = intro; this.name = name
return this; return this
} }
public String getUserNickname() { fun setPortrait(portrait: String?): UserBean {
return userNickname; this.portrait = portrait
return this
} }
public UserBean setUserNickname(String userNickname) { fun setFansNum(fansNum: String?): UserBean {
this.userNickname = userNickname; this.fansNum = fansNum
return this; return this
} }
public String getName() { fun setHasConcerned(hasConcerned: Int): UserBean {
return name; this.hasConcerned = hasConcerned
} return this
public UserBean setName(String name) {
this.name = name;
return this;
}
public String getPortrait() {
return portrait;
}
public UserBean setPortrait(String portrait) {
this.portrait = portrait;
return this;
}
public String getFansNum() {
return fansNum;
}
public UserBean setFansNum(String fansNum) {
this.fansNum = fansNum;
return this;
}
public int getHasConcerned() {
return hasConcerned;
}
public UserBean setHasConcerned(int hasConcerned) {
this.hasConcerned = hasConcerned;
return this;
} }
} }
} }