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

This commit is contained in:
GoFly233 2020-08-13 20:17:08 +08:00 committed by HuanChengFly
parent 26f16b489e
commit 162064649c
2 changed files with 18 additions and 34 deletions

View File

@ -1,45 +1,29 @@
package com.huanchengfly.tieba.api.models; package com.huanchengfly.tieba.api.models
import java.util.Objects; import java.util.*
public class ParamBean { class ParamBean(var name: String, var value: String) {
private String name;
private String value;
public ParamBean(String name, String value) { fun setName(name: String): ParamBean {
this.name = name; this.name = name
this.value = value; return this
} }
public String getName() { fun setValue(value: String): ParamBean {
return name; this.value = value
return this
} }
public ParamBean setName(String name) { override fun equals(other: Any?): Boolean {
this.name = name; if (this === other) return true
return this; if (other !is ParamBean) return false
val paramBean = other
return name == paramBean.name &&
value == paramBean.value
} }
public String getValue() { override fun hashCode(): Int {
return value; return Objects.hash(name, value)
} }
public ParamBean setValue(String value) {
this.value = value;
return this;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof ParamBean)) return false;
ParamBean paramBean = (ParamBean) o;
return Objects.equals(getName(), paramBean.getName()) &&
Objects.equals(getValue(), paramBean.getValue());
}
@Override
public int hashCode() {
return Objects.hash(getName(), getValue());
}
} }