class AbstractGraphTemplate implements GraphTemplate {

    @Override
    public <T> Optional<T> singleResult(String gremlin) {
        List<T> entities = query(gremlin);
        if (entities.isEmpty()) {
            return Optional.empty();
        }
        if (entities.size() == 1) {
            return Optional.ofNullable(entities.get(0));
        }
        throw new NonUniqueResultException("The gremlin query returns more than one result: " + gremlin);

    }

}