All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.fluent.hibernate.builder.EqBuilder Maven / Gradle / Ivy

Go to download

A library to work with Hibernate by fluent API. This library hasn't dependencies except Hibernate dependencies. It requires Java 1.6 and above.

There is a newer version: 0.3.1
Show newest version
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