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

org.xblackcat.sjpu.storage.consumer.SingletonConsumer Maven / Gradle / Ivy

Go to download

Service for generating DB access logic in simple way via interfaces and annotations

There is a newer version: 2.0
Show newest version
package org.xblackcat.sjpu.storage.consumer;

import org.xblackcat.sjpu.storage.ConsumeException;

/**
 * Default consumer for reading single row. If result set has more than
 *
 * @author xBlackCat
 */
public class SingletonConsumer implements IRowSetConsumer {
    private T obj;
    private boolean set = false;

    @Override
    public boolean consume(T o) throws ConsumeException {
        if (set) {
            throw new ConsumeException("Expected one or zero results on query ");
        }

        obj = o;
        set = true;

        return false;
    }

    public T getRowsHolder() {
        return obj;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy