com.cherokeesoft.db.utils.api.GetModelDao Maven / Gradle / Ivy
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 org.springframework.transaction.annotation.Transactional;
import java.util.Collection;
@Deprecated
public interface GetModelDao {
Collection batchGet(FILTER filter, int offset, int limit) throws DataException;
default MODEL get(FILTER filter) throws DataException {
Collection advertises = batchGet(filter, 0, Integer.MAX_VALUE);
if(CollectionUtils.isEmpty(advertises) || advertises.size() == 1) {
return CollectionUtils.isEmpty(advertises) ? null : advertises.iterator().next();
} else {
throw new DataException("Incorrect result");
}
}
}