
com.github.fluent.hibernate.builder.EqBuilder Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of fluent-hibernate-core Show documentation
Show all versions of fluent-hibernate-core Show documentation
A library to work with Hibernate by fluent API. This library hasn't dependencies except Hibernate dependencies. It requires Java 1.6 and above.
package com.github.fluent.hibernate.builder;
import com.github.fluent.hibernate.request.HibernateRequest;
/**
* @author by alexey.pchelnikov.
*/
public class EqBuilder implements IBuilder {
private final String propertyName;
private final Object value;
// TODO mutually exclusive
private boolean ifNotNull;
private boolean orIsNull;
/*package*/EqBuilder(String propertyName, Object value) {
this.propertyName = propertyName;
this.value = value;
}
public IBuilder ifNotNull() {
ifNotNull = true;
return this;
}
@Override
public void build(HibernateRequest hibernateRequest) {
if (orIsNull) {
hibernateRequest.eqOrIsNull(propertyName, value);
} else if (!ifNotNull || value != null) {
hibernateRequest.eq(propertyName, value);
}
}
public IBuilder orIsNull() {
orIsNull = true;
return this;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy