Class CriterionRenderer
java.lang.Object
org.mybatis.dynamic.sql.where.render.CriterionRenderer
- All Implemented Interfaces:
SqlCriterionVisitor<Optional<RenderedCriterion>>
public class CriterionRenderer
extends Object
implements SqlCriterionVisitor<Optional<RenderedCriterion>>
Renders a
SqlCriterion
to a RenderedCriterion
. The process is complex because all conditions
may or may not be a candidate for rendering. For example, "isEqualWhenPresent" will not render when the value
is null. It is also complex because SqlCriterion may or may not include sub-criteria.
Rendering is a recursive process. The renderer will recurse into each sub-criteria - which may also contain further sub-criteria - until all possible sub-criteria are rendered into a single fragment. So, for example, the fragment may end up looking like:
col1 = ? and (col2 = ? or (col3 = ? and col4 = ?))
It is also possible that the end result will be empty if all criteria and sub-criteria are not valid for rendering.
- Author:
- Jeff Butler
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionrender
(List<AndOrCriteriaGroup> subCriteria, Function<FragmentCollector, String> fragmentCalculator) render
(SqlCriterion initialCriterion, List<AndOrCriteriaGroup> subCriteria, Function<FragmentCollector, String> fragmentCalculator) visit
(ColumnAndConditionCriterion<T> criterion) visit
(CriteriaGroup criterion) visit
(ExistsCriterion criterion) visit
(NotCriterion criterion)
-
Constructor Details
-
CriterionRenderer
-
-
Method Details
-
visit
- Specified by:
visit
in interfaceSqlCriterionVisitor<Optional<RenderedCriterion>>
-
visit
- Specified by:
visit
in interfaceSqlCriterionVisitor<Optional<RenderedCriterion>>
-
visit
- Specified by:
visit
in interfaceSqlCriterionVisitor<Optional<RenderedCriterion>>
-
visit
- Specified by:
visit
in interfaceSqlCriterionVisitor<Optional<RenderedCriterion>>
-
render
public Optional<RenderedCriterion> render(SqlCriterion initialCriterion, List<AndOrCriteriaGroup> subCriteria, Function<FragmentCollector, String> fragmentCalculator) -
render
public Optional<RenderedCriterion> render(List<AndOrCriteriaGroup> subCriteria, Function<FragmentCollector, String> fragmentCalculator)
-