001package com.avaje.ebean;
002
003/**
004 * Represents a Conjunction or a Disjunction.
005 * <p>
006 * Basically with a Conjunction you join together many expressions with AND, and
007 * with a Disjunction you join together many expressions with OR.
008 * </p>
009 * <p>
010 * Note: where() always takes you to the top level WHERE expression list.
011 * </p>
012 * 
013 * <pre class="code">
014 * Query q =
015 *     Ebean.find(Person.class)
016 *         .where().disjunction()
017 *         .like(&quot;name&quot;, &quot;Rob%&quot;)
018 *         .eq(&quot;status&quot;, Status.NEW)
019 * 
020 *         // where() returns us to the top level expression list
021 *         .where().gt(&quot;id&quot;, 10);
022 * 
023 * // read as...
024 * // where ( ((name like Rob%) or (status = NEW)) AND (id &gt; 10) )
025 * </pre>
026 * 
027 * <p>
028 * Note: endJunction() takes you to the parent expression list
029 * </p>
030 * 
031 * <pre class="code">
032 * Query q =
033 *     Ebean.find(Person.class)
034 *         .where().disjunction()
035 *         .like(&quot;name&quot;, &quot;Rob%&quot;)
036 *         .eq(&quot;status&quot;, Status.NEW)
037 *         .endJunction()
038 * 
039 *         // endJunction().. takes us to the 'parent' expression list
040 *         // which in this case is the top level (same as where())
041 * 
042 *         .gt(&quot;id&quot;, 10);
043 * 
044 * // read as...
045 * // where ( ((name like Rob%) or (status = NEW)) AND (id &gt; 10) )
046 * </pre>
047 * 
048 * <p>
049 * Example of a nested disjunction.
050 * </p>
051 * 
052 * <pre class="code">
053 * Query&lt;Customer&gt; q = 
054 *  Ebean.find(Customer.class)
055 *      .where()
056 *          .disjunction()
057 *              .conjunction()
058 *                  .startsWith(&quot;name&quot;, &quot;r&quot;)
059 *                  .eq(&quot;anniversary&quot;, onAfter)
060 *                  .endJunction()
061 *              .conjunction()
062 *                  .eq(&quot;status&quot;, Customer.Status.ACTIVE)
063 *                  .gt(&quot;id&quot;, 0)
064 *                  .endJunction()
065 *      .order().asc(&quot;name&quot;);
066 * 
067 * q.findList();
068 * String s = q.getGeneratedSql();
069 * 
070 *  // this produces an expression like:
071 *  
072 *  ( name like ? and c.anniversary = ? ) or (c.status = ?  and c.id &gt; ? )
073 * 
074 * </pre>
075 */
076public interface Junction<T> extends Expression, ExpressionList<T> {
077
078}