001/*
002 * Licensed under the Apache License, Version 2.0 (the "License");
003 * you may not use this file except in compliance with the License.
004 * You may obtain a copy of the License at
005 *
006 *     http://www.apache.org/licenses/LICENSE-2.0
007 *
008 * Unless required by applicable law or agreed to in writing, software
009 * distributed under the License is distributed on an "AS IS" BASIS,
010 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
011 * See the License for the specific language governing permissions and
012 * limitations under the License.
013 */
014package org.gbif.api.model.collections.search;
015
016import org.gbif.api.vocabulary.Country;
017
018import java.util.Objects;
019import java.util.Set;
020import java.util.UUID;
021
022/** Models the response for the Collections search. */
023public class CollectionsSearchResponse {
024
025  private String type;
026  private UUID key;
027  private String code;
028  private String name;
029  private UUID institutionKey;
030  private String institutionCode;
031  private String institutionName;
032
033  private boolean displayOnNHCPortal;
034
035  private Country country;
036
037  private Country mailingCountry;
038
039  private Set<Match> matches;
040
041  public String getType() {
042    return type;
043  }
044
045  public void setType(String type) {
046    this.type = type;
047  }
048
049  public UUID getKey() {
050    return key;
051  }
052
053  public void setKey(UUID key) {
054    this.key = key;
055  }
056
057  public String getCode() {
058    return code;
059  }
060
061  public void setCode(String code) {
062    this.code = code;
063  }
064
065  public String getName() {
066    return name;
067  }
068
069  public void setName(String name) {
070    this.name = name;
071  }
072
073  public UUID getInstitutionKey() {
074    return institutionKey;
075  }
076
077  public void setInstitutionKey(UUID institutionKey) {
078    this.institutionKey = institutionKey;
079  }
080
081  public String getInstitutionCode() {
082    return institutionCode;
083  }
084
085  public void setInstitutionCode(String institutionCode) {
086    this.institutionCode = institutionCode;
087  }
088
089  public String getInstitutionName() {
090    return institutionName;
091  }
092
093  public void setInstitutionName(String institutionName) {
094    this.institutionName = institutionName;
095  }
096
097  public boolean isDisplayOnNHCPortal() {
098    return displayOnNHCPortal;
099  }
100
101  public void setDisplayOnNHCPortal(boolean displayOnNHCPortal) {
102    this.displayOnNHCPortal = displayOnNHCPortal;
103  }
104
105  public Country getCountry() {
106    return country;
107  }
108
109  public void setCountry(Country country) {
110    this.country = country;
111  }
112
113  public Country getMailingCountry() {
114    return mailingCountry;
115  }
116
117  public void setMailingCountry(Country mailingCountry) {
118    this.mailingCountry = mailingCountry;
119  }
120
121  public Set<Match> getMatches() {
122    return matches;
123  }
124
125  public void setMatches(Set<Match> matches) {
126    this.matches = matches;
127  }
128
129  public static class Match {
130    private String field;
131    private String snippet;
132
133    public String getField() {
134      return field;
135    }
136
137    public void setField(String field) {
138      this.field = field;
139    }
140
141    public String getSnippet() {
142      return snippet;
143    }
144
145    public void setSnippet(String snippet) {
146      this.snippet = snippet;
147    }
148
149    @Override
150    public boolean equals(Object o) {
151      if (this == o) return true;
152      if (o == null || getClass() != o.getClass()) return false;
153      Match match = (Match) o;
154      return Objects.equals(field, match.field);
155    }
156
157    @Override
158    public int hashCode() {
159      return Objects.hash(field);
160    }
161  }
162
163  @Override
164  public boolean equals(Object o) {
165    if (this == o) {
166      return true;
167    }
168    if (o == null || getClass() != o.getClass()) {
169      return false;
170    }
171    CollectionsSearchResponse response = (CollectionsSearchResponse) o;
172    return Objects.equals(type, response.type)
173        && Objects.equals(key, response.key)
174        && Objects.equals(code, response.code)
175        && Objects.equals(name, response.name)
176        && Objects.equals(institutionKey, response.institutionKey)
177        && Objects.equals(institutionCode, response.institutionCode)
178        && Objects.equals(institutionName, response.institutionName)
179        && Objects.equals(displayOnNHCPortal, response.displayOnNHCPortal)
180        && Objects.equals(country, response.country)
181        && Objects.equals(mailingCountry, response.mailingCountry)
182        && Objects.equals(matches, response.matches);
183  }
184
185  @Override
186  public int hashCode() {
187    return Objects.hash(
188        type,
189        key,
190        code,
191        name,
192        institutionKey,
193        institutionCode,
194        institutionName,
195        displayOnNHCPortal,
196        country,
197        mailingCountry,
198        matches);
199  }
200}