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

com.cherokeesoft.db.utils.api.GetGraphModelDao Maven / Gradle / Ivy

There is a newer version: 1.8.29
Show newest version
package com.cherokeesoft.db.utils.api;


import com.cherokeesoft.db.utils.exception.DataException;
import com.cherokeesoft.db.utils.graph.DataGraph;
import org.apache.commons.collections.CollectionUtils;

import java.util.Collection;

@Deprecated
public interface GetGraphModelDao {
    Collection batchGet(DataGraph dataGraph, FILTER filter, int offset, int limit) throws DataException;

    default MODEL get(DataGraph dataGraph, FILTER filter) throws DataException {
        Collection advertises = batchGet(dataGraph, filter, 0, Integer.MAX_VALUE);
        if(CollectionUtils.isEmpty(advertises) || advertises.size() == 1) {
            return CollectionUtils.isEmpty(advertises) ? null : advertises.iterator().next();
        } else {
            throw new DataException(String.format("Incorrect result. Expect 1 actual %s", advertises.size()));
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy