com.blazebit.persistence.BinaryPredicateBuilder Maven / Gradle / Ivy
/*
* Copyright 2014 - 2019 Blazebit.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.blazebit.persistence;
/**
* The interface for binary predicate builders.
* The left hand side and the operator are already known to the builder and the methods of this builder terminate the building process.
*
* @param The builder type that is returned on terminal operations
* @author Christian Beikov
* @author Moritz Becker
* @since 1.0.0
*/
public interface BinaryPredicateBuilder {
/**
* Uses the given value as right hand side for the binary predicate.
* Finishes the binary predicate and adds it to the parent predicate container represented by the type T
.
*
* @param value The value to use for the right hand side of the binary predicate
* @return The parent predicate container builder
*/
public T value(Object value);
/**
* Uses the given value as right hand side for the binary predicate rendered as literal.
* Finishes the binary predicate and adds it to the parent predicate container represented by the type T
.
*
* @param value The value to use for the right hand side of the binary predicate
* @return The parent predicate container builder
* @since 1.4.0
*/
public T literal(Object value);
/**
* Uses the given expression as right hand side for the binary predicate.
* Finishes the binary predicate and adds it to the parent predicate container represented by the type T
.
*
* @param expression The expression to use for the right hand side of the binary predicate
* @return The parent predicate container builder
*/
public T expression(String expression);
/**
* Starts a {@link MultipleSubqueryInitiator} that uses the given expression as right hand side for the binary predicate.
*
*
* All occurrences of subsequently defined subqueryAlias
es in expression
will be replaced by the respective subquery.
* When the builder finishes, the predicate is added to the parent predicate container represented by the type T
.
*
*
* @param expression The expression to use for the right hand side of the binary predicate
* @return The subquery initiator for building multiple subqueries for their respective subqueryAliases
* @since 1.2.0
*/
public MultipleSubqueryInitiator subqueries(String expression);
/**
* Starts a {@link RestrictionBuilder} to create a when expression with a single predicate
* in which {@code expression} will be on the left hand side of the predicate.
*
* @param expression The left hand side expression for a when predicate
* @return The restriction builder for the given expression
*
* @see CaseWhenStarterBuilder#when(java.lang.String) More details about this method
*/
public RestrictionBuilder>> caseWhen(String expression);
/**
* Starts a {@link SubqueryInitiator} to create a when expression with a single predicate
* in which the left hand side will be a subquery.
*
*
* When the subquery builder and the restriction builder for the right hand side are finished, the when predicate in conjunction
* with its then expression are added to the case when builder.
*
*
* @return The subquery initiator for building a subquery
*
* @see CaseWhenStarterBuilder#whenSubquery() More details about this method
*/
public SubqueryInitiator>>> caseWhenSubquery();
/**
* Starts a {@link SubqueryInitiator} to create a when expression with a single predicate
* in which the left hand side will be a subquery.
*
*
* When the subquery builder and the restriction builder for the right hand side are finished, the when predicate in conjunction
* with its then expression are added to the case when builder.
*
*
* @param subqueryAlias The alias for the subquery which will be replaced by the actual subquery
* @param expression The expression which will be used as left hand side of a predicate.
* This expression contains the {@code subqueryAlias} to define the insertion points for the subquery.
* @return The subquery initiator for building a subquery
*
* @see CaseWhenStarterBuilder#whenSubquery(java.lang.String, java.lang.String) More details about this method
*/
public SubqueryInitiator>>> caseWhenSubquery(String subqueryAlias, String expression);
/**
* Starts a {@link SubqueryBuilder} based on the given criteria builder to create a when expression with a single predicate
* in which the left hand side will be a subquery.
*
*
* When the subquery builder and the restriction builder for the right hand side are finished, the when predicate in conjunction
* with its then expression are added to the case when builder.
*
*
* @param criteriaBuilder The criteria builder to base the subquery on
* @return The subquery builder for building a subquery
* @since 1.2.0
*
* @see CaseWhenStarterBuilder#whenSubquery() More details about this method
*/
public SubqueryBuilder>>> caseWhenSubquery(FullQueryBuilder, ?> criteriaBuilder);
/**
* Starts a {@link SubqueryBuilder} based on the given criteria builder to create a when expression with a single predicate
* in which the left hand side will be a subquery.
*
*
* When the subquery builder and the restriction builder for the right hand side are finished, the when predicate in conjunction
* with its then expression are added to the case when builder.
*
*
* @param subqueryAlias The alias for the subquery which will be replaced by the actual subquery
* @param expression The expression which will be used as left hand side of a predicate.
* This expression contains the {@code subqueryAlias} to define the insertion points for the subquery.
* @param criteriaBuilder The criteria builder to base the subquery on
* @return The subquery builder for building a subquery
* @since 1.2.0
*
* @see CaseWhenStarterBuilder#whenSubquery(java.lang.String, java.lang.String) More details about this method
*/
public SubqueryBuilder>>> caseWhenSubquery(String subqueryAlias, String expression, FullQueryBuilder, ?> criteriaBuilder);
/**
* Starts a {@link SubqueryInitiator} for the left hand side of a when predicate.
*
*
* All occurrences of subsequently defined subqueryAlias
es in expression
will be replaced by the respective subquery.
* When the builder finishes, the select item is added to the parent container represented by the type X
.
*
*
* @param expression The expression which will be added as select item.
* This expression contains the {@code subqueryAlias} to define the insertion points for the subquery.
* @return The subquery initiator for building a subquery
* @since 1.2.0
*/
public MultipleSubqueryInitiator>>> caseWhenSubqueries(String expression);
/**
* Starts a {@link SubqueryInitiator} to create a when expression with a single exists predicate.
*
*
* When the builder finishes, the when predicate in conjunction with its then expression are added to the case when builder.
*
*
* @return The subquery initiator for building a subquery
*
* @see CaseWhenStarterBuilder#whenExists() More details about this method
*/
public SubqueryInitiator>> caseWhenExists();
/**
* Starts a {@link SubqueryInitiator} to create a when expression with a single negated exists predicate.
*
*
* When the builder finishes, the when predicate in conjunction with its then expression are added to the case when builder.
*
*
* @return The subquery initiator for building a subquery
*
* @see CaseWhenStarterBuilder#whenNotExists() More details about this method
*/
public SubqueryInitiator>> caseWhenNotExists();
/**
* Starts a {@link SubqueryInitiator} to create a when expression with a single exists predicate.
*
*
* When the builder finishes, the when predicate in conjunction with its then expression are added to the case when builder.
*
*
* @param criteriaBuilder The criteria builder to base the subquery on
* @return The subquery builder for building a subquery
* @since 1.2.0
*
* @see CaseWhenStarterBuilder#whenExists() More details about this method
*/
public SubqueryBuilder>> caseWhenExists(FullQueryBuilder, ?> criteriaBuilder);
/**
* Starts a {@link SubqueryInitiator} to create a when expression with a single negated exists predicate.
*
*
* When the builder finishes, the when predicate in conjunction with its then expression are added to the case when builder.
*
*
* @param criteriaBuilder The criteria builder to base the subquery on
* @return The subquery builder for building a subquery
* @since 1.2.0
*
* @see CaseWhenStarterBuilder#whenNotExists() More details about this method
*/
public SubqueryBuilder>> caseWhenNotExists(FullQueryBuilder, ?> criteriaBuilder);
/**
* Starts a {@link CaseWhenAndThenBuilder} for building a when expression
* with conjunctively connected predicates.
*
*
* When the builder finishes, the when predicate in conjunction with its then expression are added to the case when builder.
*
*
* @return The and predicate builder for the when expression
*
* @see CaseWhenStarterBuilder#whenAnd() More details about this method
*/
public CaseWhenAndThenBuilder> caseWhenAnd();
/**
* Starts a {@link CaseWhenOrThenBuilder} for building a when expression
* with disjunctively connected predicates.
*
*
*
* When the builder finishes, the when predicate in conjunction with its then expression are added to the case when builder.
*
*
* @return The or predicate builder for the when expression
*
* @see CaseWhenStarterBuilder#whenOr() More details about this method
*/
public CaseWhenOrThenBuilder> caseWhenOr();
/**
* Starts a {@link SimpleCaseWhenBuilder} for building a simple case when expression.
*
*
* When the builder finishes, the when predicate in conjunction with its then expression are added to the case when builder.
*
*
* @param caseOperand The case operand
* @return The or predicate builder for the when expression
*
* @see SimpleCaseWhenStarterBuilder#when(java.lang.String, java.lang.String) More details about this method
*/
public SimpleCaseWhenBuilder simpleCase(String caseOperand);
}