Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Copyright (C) 2012 Clarion Media, LLC
   * 
   * 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.clarionmedia.infinitum.orm.criteria.criterion;
 

Provides static factory methods for creating new Criterion to add to com.clarionmedia.infinitum.orm.criteria.Criteria queries. Criterion act as conditions to restrict or refine the result sets of queries. They generally are not constructed directly but rather obtained through this class. However, it is possible to create new types of Criterion in which case they would need to be instantiated directly.

Author(s):
Tyler Treat
Version:
1.0 02/18/12
 
 public class Conditions {

Returns a new Criterion placing an "equals" condition on the java.lang.reflect.Field with the given name.

For example, to query for all models whose Field "foo" has a value "bar", calling Conditions.eq("foo", "bar") would essentially be the equivalent of doing WHERE foo = 'bar' in a SQL query.

Parameters:
fieldName the name of the Field to place the restriction on
value the value of the Field
Returns:
a Criterion matching this condition
 
 	public static BinaryExpression eq(String fieldNameObject value) {
 		return new BinaryExpression(fieldNamevalue.);
 	}

Returns a new Criterion placing a "not equal" condition on the java.lang.reflect.Field with the given name.

For example, to query for all models whose Field "foo" has a value other than "bar", calling Conditions.ne("foo", "bar") would essentially be the equivalent of doing WHERE foo <> 'bar' in a SQL query.

Parameters:
fieldName the name of the Field to place the restriction on
value the value of the Field
Returns:
a Criterion matching this condition
 
 	public static BinaryExpression ne(String fieldNameObject value) {
 		return new BinaryExpression(fieldNamevalue.);
 	}

Returns a new Criterion placing a "greater than" condition on the java.lang.reflect.Field with the given name.

For example, to query for all models whose Field "foo" has a value greater than 42, calling Conditions.gt("foo", 42) would essentially be the equivalent of doing WHERE foo > 42 in a SQL query.

Parameters:
fieldName the name of the Field to place the restriction on
value the value of the Field
Returns:
a Criterion matching this condition
 
 	public static BinaryExpression gt(String fieldNameObject value) {
 		return new BinaryExpression(fieldNamevalue.);
 	}

Returns a new Criterion placing a "less than" condition on the java.lang.reflect.Field with the given name.

For example, to query for all models whose Field "foo" has a value less than 42, calling Conditions.lt("foo", 42) would essentially be the equivalent of doing WHERE foo < 42 in a SQL query.

Parameters:
fieldName the name of the Field to place the restriction on
value the value of the Field
Returns:
a Criterion matching this condition
	public static BinaryExpression lt(String fieldNameObject value) {
		return new BinaryExpression(fieldNamevalue.);
	}

Returns a new Criterion placing a "greater than or equal to" condition on the java.lang.reflect.Field with the given name.

For example, to query for all models whose Field "foo" has a value greater than or equal to 42, calling Conditions.gte("foo", 42) would essentially be the equivalent of doing WHERE foo >= 42 in a SQL query.

Parameters:
fieldName the name of the Field to place the restriction on
value the value of the Field
Returns:
a Criterion matching this condition
	public static BinaryExpression gte(String fieldNameObject value) {
		return new BinaryExpression(fieldNamevalue.);
	}

Returns a new Criterion placing a "less than or equal to" condition on the java.lang.reflect.Field with the given name.

For example, to query for all models whose Field "foo" has a value less than or equal to 42, calling Conditions.lte("foo", 42) would essentially be the equivalent of doing WHERE foo <= 42 in a SQL query.

Parameters:
fieldName the name of the Field to place the restriction on
value the value of the Field
Returns:
a Criterion matching this condition
	public static BinaryExpression lte(String fieldNameObject value) {
		return new BinaryExpression(fieldNamevalue.);
	}

Returns a new Criterion placing a "between" condition on the java.lang.reflect.Field with the given name.

For example, to query for all models whose Field "foo" has a value between 0 and 42, calling Conditions.between("foo", 0, 42) would essentially be the equivalent of doing WHERE foo BETWEEN 0 and 42 in a SQL query.

Parameters:
fieldName the name of the Field to place the restriction on
value the value of the Field
Returns:
a Criterion matching this condition
	public static BetweenExpression between(String fieldNameObject lowObject high) {
		return new BetweenExpression(fieldNamelowhigh);
	}

Returns a new Criterion placing an "in" condition on the java.lang.reflect.Field with the given name.

For example, to query for all models whose Field "foo" has the value 2, 4, 6, or 8, calling Conditions.in("foo", new Integer[] 2, 4, 6, 8)} would essentially be the equivalent of doing WHERE foo IN (2, 4, 6, 8) in a SQL query.

Parameters:
fieldName the name of the Field to place the restriction on
value the value of the Field
Returns:
a Criterion matching this condition
	public static InExpression in(String fieldNameObject[] values) {
		return new InExpression(fieldNamevalues);
	}

Returns a new Criterion placing a "like" condition on the java.lang.reflect.Field with the given name.

For example, to query for all models whose Field "foo" has a value containing "bar", calling Conditions.like("foo", "%bar%") would essentially be the equivalent of doing WHERE foo LIKE '%bar%' in a SQL query.

Parameters:
fieldName the name of the Field to place the restriction on
value the value of the Field
Returns:
a Criterion matching this condition
	public static BinaryExpression like(String fieldNameObject value) {
		return new BinaryExpression(fieldNamevalue.);
	}

Returns a new Criterion placing an "is null" condition on the java.lang.reflect.Field with the given name.

For example, to query for all models whose Field "foo" has the value null, calling Conditions.isNull("foo") would essentially be the equivalent of doing WHERE foo IS NULL in a SQL query.

Parameters:
fieldName the name of the Field to place the restriction on
Returns:
a Criterion matching this condition
	public static NullExpression isNull(String fieldName) {
		return new NullExpression(fieldName);
	}

Returns a new Criterion placing an "is not null" condition on the java.lang.reflect.Field with the given name.

For example, to query for all models whose Field "foo" does not have the value null, calling Conditions.isNotNull("foo") would essentially be the equivalent of doing WHERE foo IS NOT NULL in a SQL query.

Parameters:
fieldName the name of the Field to place the restriction on
Returns:
a Criterion matching this condition
	public static NotNullExpression isNotNull(String fieldName) {
		return new NotNullExpression(fieldName);
	}

Returns a new Criterion consisting of the conjunction of the two given Criterion expressions.

Parameters:
lhs the left-hand side of the LogicalExpression
rhs the right-hand side of the LogicalExpression
Returns:
Criterion conjunctioned LogicalExpression
	public static LogicalExpression and(Criterion lhsCriterion rhs) {
		return new LogicalExpression(lhsrhs.);
	}

Returns a new Criterion consisting of the disjunction of the two given Criterion expressions.

Parameters:
lhs the left-hand side of the LogicalExpression
rhs the right-hand side of the LogicalExpression
Returns:
Criterion disjunctioned LogicalExpression
	public static LogicalExpression or(Criterion lhsCriterion rhs) {
		return new LogicalExpression(lhsrhs.);
	}

Returns a new Criterion consisting of the negation of the given Criterion expression.

Parameters:
expression the expression to negate
Returns:
Criterion negated Criterion
	public static Criterion not(Criterion expression) {
		return new NotExpression(expression);
	}
New to GrepCode? Check out our FAQ X