<commit_before>package au.com.noojee.acceloapi.filter;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.Optional;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import au.com.noojee.acceloapi.AcceloApi;
import au.com.noojee.acceloapi.AcceloException;
import au.com.noojee.acceloapi.entities.AcceloEntity;
import au.com.noojee.acceloapi.entities.meta.fieldTypes.FilterField;
import au.com.noojee.acceloapi.entities.meta.fieldTypes.OrderByField.Order;
import au.com.noojee.acceloapi.entities.types.AgainstType;

public class AcceloFilter<E extends AcceloEntity<E>>
{
	public static Logger logger = LogManager.getLogger();
	public static final String ALL = "_ALL";
	
	// Used by limit(int) to remove any limit on the
	// no. of rows returned.
	public static final int UNLIMITED = -1;

	private Optional<Expression> expression = Optional.empty();

	private Optional<Search> search = Optional.empty();

	private boolean refreshCache = false;

	public AcceloFilter<E> copy()
	{
		AcceloFilter<E> filter = new AcceloFilter<>();

		this.expression.ifPresent(e -> filter.expression = Optional.of(e.copy()));
		this.expression = this.expression.map(Expression::copy);
		// this.search = this.search.map(Search::copy);/
		this.search.ifPresent(s -> filter.search = Optional.of(s.copy()));
		filter.refreshCache = this.refreshCache;
		filter.limit = this.limit;
		filter.offset = this.offset;
		filter.orderBy = this.orderBy.map(OrderBy::copy);
		return filter;
	}

	/**
	 * Limits the no. of pages returned during a query. A page can contain up to 50 rows. We default to 1 page (50 rows)
	 * unless the caller explicitly over-rides the default.
	 */
	private int limit = 1;

	/**
	 * Used with limit to iterate through a large list of entities. Defaults to 0 so we get the first page. The offset
	 * is the page to start from (0 based). Increment the offset each time you call getByFilter to move forward a page
	 * at a time.
	 */
	private int offset = 0;

	/**
	 * List of order by clauses.
	 */
	// private List<OrderBy<E>> orderByList = new ArrayList<>();

	private Optional<OrderBy> orderBy = Optional.empty();

	public void where(Search search) throws AcceloException
	{
		if (expression.isPresent())
			throw new AcceloException("You may not combine filters and searches");

		this.search = Optional.of(search);
<commit_msg>removed warning.<commit_after>package au.com.noojee.acceloapi.filter;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.Optional;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import au.com.noojee.acceloapi.AcceloApi;
import au.com.noojee.acceloapi.AcceloException;
import au.com.noojee.acceloapi.entities.AcceloEntity;
import au.com.noojee.acceloapi.entities.meta.fieldTypes.FilterField;
import au.com.noojee.acceloapi.entities.meta.fieldTypes.OrderByField.Order;
import au.com.noojee.acceloapi.entities.types.AgainstType;

public class AcceloFilter<E extends AcceloEntity<E>>
{
	public static Logger logger = LogManager.getLogger();
	public static final String ALL = "_ALL";
	
	// Used by limit(int) to remove any limit on the
	// no. of rows returned.
	public static final int UNLIMITED = -1;

	private Optional<Expression> expression = Optional.empty();

	private Optional<Search> search = Optional.empty();

	private boolean refreshCache = false;

	public AcceloFilter<E> copy()
	{
		AcceloFilter<E> filter = new AcceloFilter<>();

		this.expression.ifPresent(e -> filter.expression = Optional.of(e.copy()));
		this.expression = this.expression.map(Expression::copy);
		// this.search = this.search.map(Search::copy);/
		this.search.ifPresent(s -> filter.search = Optional.of(s.copy()));
		filter.refreshCache = this.refreshCache;
		filter.limit = this.limit;
		filter.offset = this.offset;
		filter.orderBy = this.orderBy.map(OrderBy::copy);
		return filter;
	}

	/**
	 * Limits the no. of pages returned during a query. A page can contain up to 50 rows. We default to 1 page (50 rows)
	 * unless the caller explicitly over-rides the default.
	 */
	private int limit = 1;

	/**
	 * Used with limit to iterate through a large list of entities. Defaults to 0 so we get the first page. The offset
	 * is the page to start from (0 based). Increment the offset each time you call getByFilter to move forward a page
	 * at a time.
	 */
	private int offset = 0;

	/**
	 * List of order by clauses.
	 */
	// private List<OrderBy<E>> orderByList = new ArrayList<>();

	@SuppressWarnings("rawtypes")
	private Optional<OrderBy> orderBy = Optional.empty();

	public void where(Search search) throws AcceloException
	{
		if (expression.isPresent())
			throw new AcceloException("You may not combine filters and searches");

		this.search = Optional.of(search);

{'fraction_non_alphanumeric': 0.11434511434511435, 'fraction_numerical': 0.00498960498960499, 'mean_word_length': 4.269441401971522, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 29, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3138865', 'n_tokens_mistral': 1579, 'n_tokens_neox': 1469, 'n_words': 434}