TemporalFilterBase.java

package org.genesys.blocks.model.filters;

import com.querydsl.core.BooleanBuilder;
import com.querydsl.core.types.dsl.TemporalExpression;

import lombok.Data;
import lombok.experimental.Accessors;

/**
 * 
 * @deprecated Use {@link TemporalFilter}<LocalDate> instead.
 */
@Deprecated
@Data
@Accessors(fluent = true)
public abstract class TemporalFilterBase<R extends TemporalFilterBase<R, T>, T extends Comparable<?>> implements PropertyFilter<R, TemporalExpression<T>> {

	private static final long serialVersionUID = 6223841814630999403L;

	/** Matches records where date is on or after "since" value. */
	// >=
	public T ge;

	/** The gt. */
	// >
	public T gt;

	/** Matches records where date is on or before "until" value. */
	// <=
	public T le;

	/** The lt. */
	// <
	public T lt;

	@Override
	public boolean isEmpty() {
		return ge == null && gt == null && le == null && lt == null;
	}

	/**
	 * Builds the query.
	 *
	 * @param path the date
	 * @return the predicate
	 */
	@Override
	public BooleanBuilder buildQuery(final TemporalExpression<T> path) {
		final BooleanBuilder and = new BooleanBuilder();
		if (ge != null) {
			and.and(path.isNotNull());
			and.and(path.goe(ge));
		}
		if (gt != null) {
			and.and(path.isNotNull());
			and.and(path.gt(gt));
		}
		if (le != null) {
			and.and(path.isNotNull());
			and.and(path.loe(le));
		}
		if (lt != null) {
			and.and(path.isNotNull());
			and.and(path.lt(lt));
		}
		return and;
	}

}