Skip to content

QRY_Condition.FieldCondition ​

Class

apex
global virtual class QRY_Condition.FieldCondition implements QRY_Condition.Evaluable, QRY_Condition.BindAware

Implements: QRY_Condition.Evaluable

Represents a condition in a SOQL WHERE clause based on a specific field, operator, and value.

Example

apex
QRY_Condition.FieldCondition condition = new QRY_Condition.FieldCondition(
    'Status__c', QRY_Condition.Operator.EQUALS, 'Active'
);

Methods ​

MethodDescription
global virtual QRY_Condition.FieldCondition contains(String compareValue)Sets the condition to a LIKE comparison that matches the value anywhere in the field (a contains match).
global virtual QRY_Condition.FieldCondition containsLiteral(String compareValue)Sets the condition to a LIKE comparison that matches the value literally anywhere in the field.

contains ​

apex
global virtual QRY_Condition.FieldCondition contains(String compareValue)

Sets the condition to a LIKE comparison that matches the value anywhere in the field (a contains match). This differs from the raw LIKE form (the Operator.LIKE_X constructor argument), which passes your pattern through verbatim and leaves every % and _ wildcard to you: contains owns the wildcards, wrapping the value in a leading and trailing % so callers never assemble '%' + value + '%' patterns by hand — the same contract as the query builder's contains().

Parameters

ParameterTypeDescription
compareValueStringThe text to match anywhere in the field.

Returns QRY_Condition.FieldCondition — The FieldCondition instance for method chaining.

Example

apex
QRY_Condition.OrCondition textMatch = new QRY_Condition.OrCondition();
textMatch.add(new QRY_Condition.FieldCondition(Account.Name).contains('Acme')); // Name LIKE '%Acme%'
textMatch.add(new QRY_Condition.FieldCondition(Account.Website).contains('acme'));

containsLiteral ​

apex
global virtual QRY_Condition.FieldCondition containsLiteral(String compareValue)

Sets the condition to a LIKE comparison that matches the value literally anywhere in the field. The three characters that carry meaning inside a LIKE pattern are escaped first: % (any run of characters), _ (any single character), and \ (the escape character itself). Use this whenever the value came from a person, such as a search box, a filter or a report parameter, because contains() deliberately leaves those characters their wildcard meaning: a search for "100%" otherwise matches every value containing "100", and a search for "UTIL_HttpClient" also matches "UTILxHttpClient". Use contains() when the pattern is yours and the wildcards are wanted. The escape travels with the bound value, which is the form every QRY_Builder query executes; it is not preserved if you render the condition to a SOQL string with toSoql() and run that string yourself.

Parameters

ParameterTypeDescription
compareValueStringThe text to match anywhere in the field, character for character.

Returns QRY_Condition.FieldCondition — The FieldCondition instance for method chaining.

Example

apex
QRY_Condition.OrCondition userSearch = new QRY_Condition.OrCondition();
userSearch.add(new QRY_Condition.FieldCondition(Account.Name).containsLiteral(searchBoxValue));
userSearch.add(new QRY_Condition.FieldCondition(Account.Website).containsLiteral(searchBoxValue));

Constructors ​

ConstructorDescription
global FieldCondition(SObjectField objectField)Constructor for FieldCondition with a specified SObjectField.
global FieldCondition(SObjectField objectField, QRY_Condition.Operator fieldOperator, Object fieldValue)Constructor for FieldCondition with a specified field, operator, and value.
global FieldCondition(String fieldName)Constructor for FieldCondition with a specified field.
global FieldCondition(String fieldName, QRY_Condition.Operator fieldOperator, Object fieldValue)Constructor for FieldCondition with a specified field, operator, and value.

FieldCondition(SObjectField objectField) ​

apex
global FieldCondition(SObjectField objectField)

Constructor for FieldCondition with a specified SObjectField. Pair with contains() to complete the condition, or use the field-operator-value constructor for other comparisons.

Parameters

ParameterTypeDescription
objectFieldSObjectFieldThe ObjectField to apply the condition to.

Example

apex
QRY_Condition.Evaluable condition = new QRY_Condition.FieldCondition(Account.Name).contains('Acme');

FieldCondition(SObjectField objectField, QRY_Condition.Operator fieldOperator, Object fieldValue) ​

apex
global FieldCondition(SObjectField objectField, QRY_Condition.Operator fieldOperator, Object fieldValue)

Constructor for FieldCondition with a specified field, operator, and value.

Parameters

ParameterTypeDescription
objectFieldSObjectFieldThe field to apply the condition to.
fieldOperatorQRY_Condition.OperatorThe operator for the condition.
fieldValueObjectThe value to compare against the field.

Example

apex
QRY_Condition.FieldCondition instance = new QRY_Condition.FieldCondition(Account.Name, new Operator(), 'value');

FieldCondition(String fieldName) ​

apex
global FieldCondition(String fieldName)

Constructor for FieldCondition with a specified field. Pair with contains() to complete the condition, or use the field-operator-value constructor for other comparisons.

Parameters

ParameterTypeDescription
fieldNameStringThe field to apply the condition to.

Example

apex
QRY_Condition.Evaluable condition = new QRY_Condition.FieldCondition('Name').contains('Acme');

FieldCondition(String fieldName, QRY_Condition.Operator fieldOperator, Object fieldValue) ​

apex
global FieldCondition(String fieldName, QRY_Condition.Operator fieldOperator, Object fieldValue)

Constructor for FieldCondition with a specified field, operator, and value.

Parameters

ParameterTypeDescription
fieldNameStringThe field to apply the condition to.
fieldOperatorQRY_Condition.OperatorThe operator for the condition.
fieldValueObjectThe value to compare against the field.

Example

apex
QRY_Condition.FieldCondition instance = new QRY_Condition.FieldCondition('myName', new Operator(), 'value');