/** * Add a sub {@code criteria} to the Criteria that is building. A sub * criteria is one that is wrapped in parenthesis. * * @param criteria * @return the builder */ public BuildableStartState group(Criteria criteria) { this.criteria.add(criteria); return new BuildableStartState(this.criteria); }
/** * Build a conjunctive clause onto the {@link Criteria} that is building. * * @return the builder */ public StartState and() { criteria.add(ConjunctionSymbol.AND); return new StartState(criteria); }
/** * Build a disjunctive clause onto the {@link Criteria} that is building. * * @return the builder */ public StartState or() { criteria.add(ConjunctionSymbol.OR); return new StartState(criteria); }
/** * Add the specified {@code operator} to the {@link Criteria} that is * building. * * @param operator * @return the builder */ public OperatorState operator(Operator operator) { criteria.add(new OperatorSymbol(operator)); return new OperatorState(criteria); }
/** * Add the specified {@code value} to the {@link Criteria} that is building. * * @param value * @return the builder */ public ValueState value(Object value) { criteria.add(new ValueSymbol(value)); return new ValueState(criteria); }
/** * Add the specified {@code value} to the {@link Criteria} that is building. * * @param value * @return the builder */ public ValueState value(Object value) { criteria.add(new ValueSymbol(value)); return new ValueState(criteria); }
/** * Add a {@code key} to the Criteria that is building. * * @param key * @return the builder */ public KeyState key(String key) { criteria.add(new KeySymbol(key)); return new KeyState(criteria); }
/** * Add the specified {@code timestamp} to the {@link Criteria} that is * building. * * @param timestamp * @return the builder */ public TimestampState at(Timestamp timestamp) { criteria.add(new TimestampSymbol(timestamp.getMicros())); return new TimestampState(criteria); }
/** * Translate the {@code tcriteria} to its Java analog. * * @param tcriteria * @return the analogous Java {@link Criteria} */ public static Criteria translateFromThriftCriteria(TCriteria tcriteria) { Criteria criteria = new Criteria(); for (TSymbol tsymbol : tcriteria.getSymbols()) { criteria.add(translateFromThriftSymbol(tsymbol)); } return criteria; }
@Test(expected = IllegalStateException.class) public void testCannotAddSymbolToBuiltCriteria() { Criteria criteria = Criteria.where().key("foo") .operator(Operator.EQUALS).value("bar").build(); criteria.add(new KeySymbol("baz")); }