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