FilteredPage.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.api;
import java.io.Serializable;
import java.util.Iterator;
import org.genesys.blocks.model.filters.SuperModelFilter;
import org.springframework.data.domain.Page;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonUnwrapped;
/**
* The Class FilteredPage.
*
* @param <T> the generic type
*/
public class FilteredPage<T, F extends SuperModelFilter<?, ?, ?>> implements Iterable<T>, Serializable {
private static final long serialVersionUID = -4492566822810376766L;
/** The data is serialized on the base JSON level. */
@JsonUnwrapped
@JsonIgnoreProperties({ "pageable" })
public Page<T> page;
/** The filter. */
public F filter;
/** The filter code. */
@JsonInclude(JsonInclude.Include.NON_EMPTY)
public String filterCode;
/**
* Instantiates a new filtered page.
*
* @param filter the filter
* @param data the data
*/
public FilteredPage(final F filter, final Page<T> data) {
this.filter = filter;
this.page = data;
}
/**
* Instantiates a new filtered page.
*
* @param filterCode the filter code
* @param filter the filter
* @param data the data
*/
public FilteredPage(final String filterCode, final F filter, final Page<T> data) {
this.filterCode = filterCode;
this.filter = filter;
this.page = data;
}
@Override
public Iterator<T> iterator() {
return page.iterator();
}
}