mirror of
https://github.com/LamGC/ContentGrabbingJi.git
synced 2025-04-30 06:37:36 +00:00
[Add] PixivSearchBuilder 增加equals, hashCode, toString方法的覆写;
[Update] PixivSearchBuilderTest 补充测试项;
This commit is contained in:
parent
ee1f066ee4
commit
b06702f367
@ -88,8 +88,74 @@ public class PixivSearchBuilder {
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
PixivSearchBuilder that = (PixivSearchBuilder) o;
|
||||
return page == that.page &&
|
||||
wgt == that.wgt &&
|
||||
hgt == that.hgt &&
|
||||
wlt == that.wlt &&
|
||||
hlt == that.hlt &&
|
||||
content.equals(that.content) &&
|
||||
searchArea == that.searchArea &&
|
||||
searchMode == that.searchMode &&
|
||||
searchType == that.searchType &&
|
||||
searchOrder == that.searchOrder &&
|
||||
searchContentOption == that.searchContentOption &&
|
||||
includeKeywords.equals(that.includeKeywords) &&
|
||||
excludeKeywords.equals(that.excludeKeywords) &&
|
||||
ratioOption == that.ratioOption &&
|
||||
Objects.equals(startDate, that.startDate) &&
|
||||
Objects.equals(endDate, that.endDate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(
|
||||
content,
|
||||
searchArea,
|
||||
searchMode,
|
||||
searchType,
|
||||
searchOrder,
|
||||
searchContentOption,
|
||||
includeKeywords,
|
||||
excludeKeywords,
|
||||
page,
|
||||
wgt,
|
||||
hgt,
|
||||
wlt,
|
||||
hlt,
|
||||
ratioOption,
|
||||
startDate,
|
||||
endDate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "PixivSearchBuilder{" +
|
||||
"content='" + content + '\'' +
|
||||
", searchArea=" + searchArea +
|
||||
", searchMode=" + searchMode +
|
||||
", searchType=" + searchType +
|
||||
", searchOrder=" + searchOrder +
|
||||
", searchContentOption=" + searchContentOption +
|
||||
", includeKeywords=" + includeKeywords +
|
||||
", excludeKeywords=" + excludeKeywords +
|
||||
", page=" + page +
|
||||
", wgt=" + wgt +
|
||||
", hgt=" + hgt +
|
||||
", wlt=" + wlt +
|
||||
", hlt=" + hlt +
|
||||
", ratioOption=" + ratioOption +
|
||||
", startDate=" + startDate +
|
||||
", endDate=" + endDate +
|
||||
'}';
|
||||
}
|
||||
|
||||
public PixivSearchBuilder setSearchArea(SearchArea searchArea) {
|
||||
this.searchArea = searchArea;
|
||||
this.searchArea = Objects.requireNonNull(searchArea);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
package net.lamgc.cgj.pixiv;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
public class PixivSearchBuilderTest {
|
||||
@ -12,4 +13,14 @@ public class PixivSearchBuilderTest {
|
||||
System.out.println(builder.buildURL());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void equalsTest() {
|
||||
Assert.assertEquals(new PixivSearchBuilder("风景"), new PixivSearchBuilder("风景"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void hashCodeTest() {
|
||||
Assert.assertEquals(new PixivSearchBuilder("风景").hashCode(), new PixivSearchBuilder("风景").hashCode());
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user