
com.cherokeesoft.db.utils.api.GetModel 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 java.util.Collection;
public interface GetModel {
Collection batchGet(DataGraph dataGraph) throws DataException;
default M get(DataGraph dataGraph) throws DataException {
Collection advertises = batchGet(dataGraph);
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 - 2025 Weber Informatics LLC | Privacy Policy