001package com.box.sdkgen.schemas.searchresults; 002 003import com.box.sdkgen.internal.NullableFieldTracker; 004import com.box.sdkgen.internal.SerializableObject; 005import com.box.sdkgen.schemas.searchresultitem.SearchResultItem; 006import com.box.sdkgen.serialization.json.EnumWrapper; 007import com.fasterxml.jackson.annotation.JsonFilter; 008import com.fasterxml.jackson.annotation.JsonProperty; 009import com.fasterxml.jackson.databind.annotation.JsonDeserialize; 010import com.fasterxml.jackson.databind.annotation.JsonSerialize; 011import java.util.List; 012import java.util.Objects; 013 014/** A list of files, folders and web links that matched the search query. */ 015@JsonFilter("nullablePropertyFilter") 016public class SearchResults extends SerializableObject { 017 018 /** 019 * One greater than the offset of the last entry in the search results. The total number of 020 * entries in the collection may be less than `total_count`. 021 */ 022 @JsonProperty("total_count") 023 protected Long totalCount; 024 025 /** 026 * The limit that was used for this search. This will be the same as the `limit` query parameter 027 * unless that value exceeded the maximum value allowed. 028 */ 029 protected Long limit; 030 031 /** 032 * The 0-based offset of the first entry in this set. This will be the same as the `offset` query 033 * parameter used. 034 */ 035 protected Long offset; 036 037 /** Specifies the response as search result items without shared links. */ 038 @JsonDeserialize(using = SearchResultsTypeField.SearchResultsTypeFieldDeserializer.class) 039 @JsonSerialize(using = SearchResultsTypeField.SearchResultsTypeFieldSerializer.class) 040 protected EnumWrapper<SearchResultsTypeField> type; 041 042 /** The search results for the query provided. */ 043 protected List<SearchResultItem> entries; 044 045 public SearchResults() { 046 super(); 047 this.type = 048 new EnumWrapper<SearchResultsTypeField>(SearchResultsTypeField.SEARCH_RESULTS_ITEMS); 049 } 050 051 protected SearchResults(Builder builder) { 052 super(); 053 this.totalCount = builder.totalCount; 054 this.limit = builder.limit; 055 this.offset = builder.offset; 056 this.type = builder.type; 057 this.entries = builder.entries; 058 markNullableFieldsAsSet(builder.getExplicitlySetNullableFields()); 059 } 060 061 public Long getTotalCount() { 062 return totalCount; 063 } 064 065 public Long getLimit() { 066 return limit; 067 } 068 069 public Long getOffset() { 070 return offset; 071 } 072 073 public EnumWrapper<SearchResultsTypeField> getType() { 074 return type; 075 } 076 077 public List<SearchResultItem> getEntries() { 078 return entries; 079 } 080 081 @Override 082 public boolean equals(Object o) { 083 if (this == o) { 084 return true; 085 } 086 if (o == null || getClass() != o.getClass()) { 087 return false; 088 } 089 SearchResults casted = (SearchResults) o; 090 return Objects.equals(totalCount, casted.totalCount) 091 && Objects.equals(limit, casted.limit) 092 && Objects.equals(offset, casted.offset) 093 && Objects.equals(type, casted.type) 094 && Objects.equals(entries, casted.entries); 095 } 096 097 @Override 098 public int hashCode() { 099 return Objects.hash(totalCount, limit, offset, type, entries); 100 } 101 102 @Override 103 public String toString() { 104 return "SearchResults{" 105 + "totalCount='" 106 + totalCount 107 + '\'' 108 + ", " 109 + "limit='" 110 + limit 111 + '\'' 112 + ", " 113 + "offset='" 114 + offset 115 + '\'' 116 + ", " 117 + "type='" 118 + type 119 + '\'' 120 + ", " 121 + "entries='" 122 + entries 123 + '\'' 124 + "}"; 125 } 126 127 public static class Builder extends NullableFieldTracker { 128 129 protected Long totalCount; 130 131 protected Long limit; 132 133 protected Long offset; 134 135 protected EnumWrapper<SearchResultsTypeField> type; 136 137 protected List<SearchResultItem> entries; 138 139 public Builder() { 140 super(); 141 } 142 143 public Builder totalCount(Long totalCount) { 144 this.totalCount = totalCount; 145 return this; 146 } 147 148 public Builder limit(Long limit) { 149 this.limit = limit; 150 return this; 151 } 152 153 public Builder offset(Long offset) { 154 this.offset = offset; 155 return this; 156 } 157 158 public Builder type(SearchResultsTypeField type) { 159 this.type = new EnumWrapper<SearchResultsTypeField>(type); 160 return this; 161 } 162 163 public Builder type(EnumWrapper<SearchResultsTypeField> type) { 164 this.type = type; 165 return this; 166 } 167 168 public Builder entries(List<SearchResultItem> entries) { 169 this.entries = entries; 170 return this; 171 } 172 173 public SearchResults build() { 174 if (this.type == null) { 175 this.type = 176 new EnumWrapper<SearchResultsTypeField>(SearchResultsTypeField.SEARCH_RESULTS_ITEMS); 177 } 178 return new SearchResults(this); 179 } 180 } 181}