|
20 | 20 |
|
21 | 21 | @FunctionalInterface
|
22 | 22 | public interface RenderableCondition<T> {
|
| 23 | + /** |
| 24 | + * Render a condition - typically a condition in a WHERE clause. |
| 25 | + * |
| 26 | + * <p>A rendered condition includes an SQL fragment, and any associated parameters. For example, |
| 27 | + * the <code>isEqual</code> condition should be rendered as "= ?" where "?" is a properly formatted |
| 28 | + * parameter marker (the parameter marker can be computed from the <code>RenderingContext</code>). |
| 29 | + * Note that a rendered condition should NOT include the left side of the phrase - that is rendered |
| 30 | + * by the {@link RenderableCondition#renderLeftColumn(RenderingContext, BindableColumn)} method. |
| 31 | + * |
| 32 | + * @param renderingContext the current rendering context |
| 33 | + * @param leftColumn the column related to this condition in a where clause |
| 34 | + * @return the rendered condition. Should NOT include the column. |
| 35 | + */ |
23 | 36 | FragmentAndParameters renderCondition(RenderingContext renderingContext, BindableColumn<T> leftColumn);
|
24 | 37 |
|
| 38 | + /** |
| 39 | + * Render the column in a column and condition phrase - typically in a WHERE clause. |
| 40 | + * |
| 41 | + * <p>By default, the column will be rendered as the column alias if it exists, or the column name. |
| 42 | + * This can be complicated if the column has a table qualifier, or if the "column" is a function or |
| 43 | + * part of a CASE expression. Columns know how to render themselves, so we just call their "render" |
| 44 | + * methods. |
| 45 | + * |
| 46 | + * @param renderingContext the current rendering context |
| 47 | + * @param leftColumn the column related to this condition in a where clause |
| 48 | + * @return the rendered column |
| 49 | + */ |
25 | 50 | default FragmentAndParameters renderLeftColumn(RenderingContext renderingContext, BindableColumn<T> leftColumn) {
|
26 | 51 | return leftColumn.alias()
|
27 | 52 | .map(FragmentAndParameters::fromFragment)
|
|
0 commit comments