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.predicate;
015
016import java.util.Collection;
017import java.util.Objects;
018
019import com.fasterxml.jackson.annotation.JsonCreator;
020import com.fasterxml.jackson.annotation.JsonProperty;
021
022import io.swagger.v3.oas.annotations.media.Schema;
023
024/**
025 * This predicate is "AND"-ing its subpredicates together.
026 */
027@Schema(
028  description = "A logical conjunction (“AND”) of a list of sub-predicates"
029)
030public class ConjunctionPredicate extends CompoundPredicate {
031
032  @JsonCreator
033  public ConjunctionPredicate(@JsonProperty("predicates") Collection<Predicate> predicates) {
034    super(predicates);
035  }
036
037  @Override
038  public boolean equals(Object obj) {
039    if (this == obj) {
040      return true;
041    }
042
043    if (!(obj instanceof ConjunctionPredicate)) {
044      return false;
045    }
046
047    CompoundPredicate that = (CompoundPredicate) obj;
048    return Objects.equals(this.getPredicates(), that.getPredicates());
049  }
050}