SourceDescriptorLangFilter.java

/*
 * Copyright 2026 Global Crop Diversity Trust
 * Licensed under the Apache License, Version 2.0
 * See LICENSE file in project root folder or http://www.apache.org/licenses/LICENSE-2.0
 */

package org.gringlobal.service.filter;

import java.util.List;

import org.gringlobal.model.QSourceDescriptorLang;
import org.gringlobal.model.SourceDescriptor;
import org.gringlobal.model.SourceDescriptorLang;

import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;

import com.querydsl.core.types.Predicate;

@Getter
@Setter
@EqualsAndHashCode(callSuper = true)
@Accessors(fluent = true)
public class SourceDescriptorLangFilter extends CooperatorOwnedLangFilter<SourceDescriptorLangFilter, SourceDescriptorLang, SourceDescriptor, QSourceDescriptorLang> {

	private static final long serialVersionUID = 1674550807816705624L;

	public SourceDescriptorFilter sourceDescriptor;

	/**
	 * Builds the query.
	 *
	 * @return the predicate
	 */
	@Override
	public List<Predicate> collectPredicates() {
		return collectPredicates(QSourceDescriptorLang.sourceDescriptorLang);
	}

	/**
	 * Builds the query.
	 *
	 * @param sourceDescriptorLang the sourceDescriptorLang
	 * @return the predicate
	 */
	public List<Predicate> collectPredicates(QSourceDescriptorLang sourceDescriptorLang) {
		final List<Predicate> predicates = super.collectSuperPredicates(sourceDescriptorLang, sourceDescriptorLang._super);

		if (sourceDescriptor != null) {
			predicates.add(sourceDescriptor.nestedPredicate(sourceDescriptorLang.entity()));
		}

		return predicates;
	}
}