Package de.calamanari.adl.sql.cnv
Record Class MatchCondition
java.lang.Object
java.lang.Record
de.calamanari.adl.sql.cnv.MatchCondition
- Record Components:
operator- comparison operator, equals in case of an IN-clauseisNegation- if true this shall later be a NOT resp. NOT INargNameLeft- name of the argument on the left, mandatorytableLeft- meta data of the table on the left, mandatorycolumnLeft- meta data of the column on the left, mandatoryargNameRight- name of the argument on the right in case of a reference match, null by defaulttableRight- meta data of the table on the right in case of a reference match, null by defaultcolumnRight- meta data of the column on the right in case of a reference match, null by defaultcolumnConditions- defines the parameters per column
- All Implemented Interfaces:
Serializable
public record MatchCondition(de.calamanari.adl.irl.MatchOperator operator, boolean isNegation, String argNameLeft, TableMetaInfo tableLeft, DataColumn columnLeft, String argNameRight, TableMetaInfo tableRight, DataColumn columnRight, List<ColumnCondition> columnConditions)
extends Record
implements Serializable
A
MatchCondition is an instruction to create an SQL term that either ...
- compares a column against a value.
- compares a column against multiple values.
- compares a column against another column.
Instances are deeply immutable.
- Author:
- Karl Eilebrecht
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionMatchCondition(de.calamanari.adl.irl.MatchOperator operator, boolean isNegation, String argNameLeft, TableMetaInfo tableLeft, DataColumn columnLeft, String argNameRight, TableMetaInfo tableRight, DataColumn columnRight, List<ColumnCondition> columnConditions) Creates an instance of aMatchConditionrecord class. -
Method Summary
Modifier and TypeMethodDescriptionReturns the value of theargNameLeftrecord component.Returns the value of theargNameRightrecord component.Returns the value of thecolumnConditionsrecord component.Returns the value of thecolumnLeftrecord component.Returns the value of thecolumnRightrecord component.static ColumnConditioncreateFilterColumnCondition(ColumnConditionType filterType, FilterColumn filterColumn, SqlConversionProcessContext ctx) Creates a single filter column condition (column or table filter)static MatchConditioncreateInClauseCondition(List<de.calamanari.adl.irl.SimpleExpression> expressions, SqlConversionProcessContext ctx) Assumes a list ofMatchExpressions orNegationExpressions all dealing with the same argName, EQUALS-operator and plain values, so the result will be an IN-clause in case of OR vs. a NOT IN clause in case of AND.static MatchConditioncreateSimpleCondition(de.calamanari.adl.irl.SimpleExpression expression, SqlConversionProcessContext ctx) Creates a simple (negated) match condition (against value, or IS NULL) from the given expressiondataColumnNameLeft(boolean qualified) Convenience method to obtain the effective data column namedataColumnNameRight(boolean qualified) Convenience method to obtain the effective data column namefinal booleanIndicates whether some other object is "equal to" this one.booleanfinal inthashCode()Returns a hash code value for this object.idColumnNameLeft(boolean qualified) Convenience method to obtain the effective ID column nameidColumnNameRight(boolean qualified) Convenience method to obtain the effective ID column namebooleanbooleanReturns the value of theisNegationrecord component.booleanbooleanbooleanstatic MatchConditionnegate(MatchCondition condition) de.calamanari.adl.irl.MatchOperatoroperator()Returns the value of theoperatorrecord component.static booleanshouldAlignDate(de.calamanari.adl.cnv.tps.AdlType type, AdlSqlType columnType, de.calamanari.adl.ProcessContext ctx) Tells whether we should perform an alignment of the given data to a higher resolution stamp before creating the query, to for example turn an equals into a range query.Returns the value of thetableLeftrecord component.Returns the value of thetableRightrecord component.final StringtoString()Returns a string representation of this record class.type()
-
Constructor Details
-
MatchCondition
public MatchCondition(de.calamanari.adl.irl.MatchOperator operator, boolean isNegation, String argNameLeft, TableMetaInfo tableLeft, DataColumn columnLeft, String argNameRight, TableMetaInfo tableRight, DataColumn columnRight, List<ColumnCondition> columnConditions) Creates an instance of aMatchConditionrecord class.- Parameters:
operator- the value for theoperatorrecord componentisNegation- the value for theisNegationrecord componentargNameLeft- the value for theargNameLeftrecord componenttableLeft- the value for thetableLeftrecord componentcolumnLeft- the value for thecolumnLeftrecord componentargNameRight- the value for theargNameRightrecord componenttableRight- the value for thetableRightrecord componentcolumnRight- the value for thecolumnRightrecord componentcolumnConditions- the value for thecolumnConditionsrecord component
-
-
Method Details
-
createSimpleCondition
public static MatchCondition createSimpleCondition(de.calamanari.adl.irl.SimpleExpression expression, SqlConversionProcessContext ctx) Creates a simple (negated) match condition (against value, or IS NULL) from the given expression- Parameters:
expression-ctx-- Returns:
- condition
-
shouldAlignDate
public static boolean shouldAlignDate(de.calamanari.adl.cnv.tps.AdlType type, AdlSqlType columnType, de.calamanari.adl.ProcessContext ctx) Tells whether we should perform an alignment of the given data to a higher resolution stamp before creating the query, to for example turn an equals into a range query.- Parameters:
type- source typecolumnType- destination typectx-- Returns:
- true if the date needs alignment
-
createFilterColumnCondition
public static ColumnCondition createFilterColumnCondition(ColumnConditionType filterType, FilterColumn filterColumn, SqlConversionProcessContext ctx) Creates a single filter column condition (column or table filter)- Parameters:
filterType-filterColumn-ctx-- Returns:
- filter column condition
-
negate
- Parameters:
condition-- Returns:
- copy of the the given condition with
isNegation==true
-
createInClauseCondition
public static MatchCondition createInClauseCondition(List<de.calamanari.adl.irl.SimpleExpression> expressions, SqlConversionProcessContext ctx) Assumes a list ofMatchExpressions orNegationExpressions all dealing with the same argName, EQUALS-operator and plain values, so the result will be an IN-clause in case of OR vs. a NOT IN clause in case of AND.- Parameters:
expressions- either the elements of an OR (IN, onlyMatchExpressions) or the elements of an AND (NOT IN, onlyNegationExpressions)ctx-- Returns:
- condition
- Throws:
IllegalArgumentException- if there are multiple argNames involved, multiple operands reference matches was detected.ClassCastException- if expressions are not all of the same type
-
dataColumnNameLeft
Convenience method to obtain the effective data column name- Parameters:
qualified- if true, we prepend the table name separated by a dot- Returns:
- sql identifier
-
dataColumnNameRight
Convenience method to obtain the effective data column name- Parameters:
qualified- if true, we prepend the table name separated by a dot- Returns:
- sql identifier
-
idColumnNameLeft
Convenience method to obtain the effective ID column name- Parameters:
qualified- if true, we prepend the table name separated by a dot- Returns:
- sql identifier
-
idColumnNameRight
Convenience method to obtain the effective ID column name- Parameters:
qualified- if true, we prepend the table name separated by a dot- Returns:
- sql identifier
-
isReferenceMatch
public boolean isReferenceMatch()- Returns:
- true if this condition matches two columns against each other
-
isSingleTableReferenceMatchInvolvingMultipleRows
public boolean isSingleTableReferenceMatchInvolvingMultipleRows()- Returns:
- true if this condition matches two columns of the same table against each other, and at least one of the columns is marked mult-row
-
isDualTableReferenceMatch
public boolean isDualTableReferenceMatch()- Returns:
- true if this condition matches two columns from different tables against each other
-
isNullMatch
public boolean isNullMatch()- Returns:
- true if this condition reflects an IS NULL (operator IS UNKNOWN)
-
getPrimaryColumnCondition
- Returns:
- the primary value comparison (e.g.,
color=blue) or null if this is a reference match.
-
type
- Returns:
- type of the main condition
-
hasAnyFilterColumnConditions
public boolean hasAnyFilterColumnConditions()- Returns:
- true if there are any additional filter conditions besides the primary match condition
-
getLeftFilterColumnConditions
- Returns:
- list with optional filter column conditions related to the left column
-
getRightFilterColumnConditions
- Returns:
- list with optional filter column conditions related to the right column in case of a reference match
-
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with '=='. -
operator
public de.calamanari.adl.irl.MatchOperator operator()Returns the value of theoperatorrecord component.- Returns:
- the value of the
operatorrecord component
-
isNegation
public boolean isNegation()Returns the value of theisNegationrecord component.- Returns:
- the value of the
isNegationrecord component
-
argNameLeft
Returns the value of theargNameLeftrecord component.- Returns:
- the value of the
argNameLeftrecord component
-
tableLeft
Returns the value of thetableLeftrecord component.- Returns:
- the value of the
tableLeftrecord component
-
columnLeft
Returns the value of thecolumnLeftrecord component.- Returns:
- the value of the
columnLeftrecord component
-
argNameRight
Returns the value of theargNameRightrecord component.- Returns:
- the value of the
argNameRightrecord component
-
tableRight
Returns the value of thetableRightrecord component.- Returns:
- the value of the
tableRightrecord component
-
columnRight
Returns the value of thecolumnRightrecord component.- Returns:
- the value of the
columnRightrecord component
-
columnConditions
Returns the value of thecolumnConditionsrecord component.- Returns:
- the value of the
columnConditionsrecord component
-