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.registry; 015 016import java.io.Serializable; 017import java.util.Objects; 018 019import jakarta.annotation.Nullable; 020 021import io.swagger.v3.oas.annotations.media.Schema; 022import lombok.Getter; 023import lombok.NoArgsConstructor; 024import lombok.Setter; 025 026/** 027 * Approximate record counts for a dataset, sourced from the dataset search index. 028 * Values are snapshots taken at index time and may lag live occurrence or checklist data. 029 */ 030@Schema( 031 description = 032 "Approximate record counts for this dataset, sourced from the dataset search index. " 033 + "Values are snapshots taken at index time and may lag live occurrence or checklist data. " 034 + "Useful to avoid extra calls for occurrence and name-usage totals; not authoritative.") 035@NoArgsConstructor 036@Getter 037@Setter 038public class ApproximateCounts implements Serializable { 039 040 @Schema(description = "Approximate number of occurrence records indexed for this dataset.") 041 @Nullable 042 private Long occurrenceCount; 043 044 @Schema( 045 description = 046 "Approximate number of name usages for checklist datasets; typically null otherwise.") 047 @Nullable 048 private Long nameUsageCount; 049 050 public ApproximateCounts(Long occurrenceCount, Long nameUsageCount) { 051 this.occurrenceCount = occurrenceCount; 052 this.nameUsageCount = nameUsageCount; 053 } 054 055 @Override 056 public boolean equals(Object o) { 057 if (this == o) { 058 return true; 059 } 060 if (!(o instanceof ApproximateCounts)) { 061 return false; 062 } 063 ApproximateCounts that = (ApproximateCounts) o; 064 return Objects.equals(occurrenceCount, that.occurrenceCount) 065 && Objects.equals(nameUsageCount, that.nameUsageCount); 066 } 067 068 @Override 069 public int hashCode() { 070 return Objects.hash(occurrenceCount, nameUsageCount); 071 } 072 073 @Override 074 public String toString() { 075 return "ApproximateCounts{occurrenceCount=" 076 + occurrenceCount 077 + ", nameUsageCount=" 078 + nameUsageCount 079 + '}'; 080 } 081}