org.ibatis.persist.impl.predicate.BooleanStaticAssertionPredicate Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jbatis Show documentation
Show all versions of jbatis Show documentation
The jBATIS persistence framework will help you to significantly reduce the amount of Java code that you normally need to access a relational database. iBATIS simply maps JavaBeans to SQL statements using a very simple XML descriptor.
The newest version!
package org.ibatis.persist.impl.predicate;
import org.ibatis.persist.impl.CriteriaBuilderImpl;
import org.ibatis.persist.impl.RenderingContext;
/**
* Predicate used to assert a static boolean condition.
*/
public class BooleanStaticAssertionPredicate
extends AbstractSimplePredicate {
private final Boolean assertedValue;
public BooleanStaticAssertionPredicate(
CriteriaBuilderImpl criteriaBuilder,
Boolean assertedValue) {
super( criteriaBuilder );
this.assertedValue = assertedValue;
}
public Boolean getAssertedValue() {
return assertedValue;
}
@Override
public void render(boolean isNegated, RenderingContext rc) {
boolean isTrue = getAssertedValue();
if (isNegated) {
isTrue = !isTrue;
}
rc.append(isTrue ? "1=1" : "0=1");
}
}