
org.jnosql.artemis.column.ColumnPreparedStatementAsync Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of artemis-column Show documentation
Show all versions of artemis-column Show documentation
Eclipse JNoSQL Mapping, Artemis API, to column NoSQL databases
/*
* Copyright (c) 2017 Otávio Santana and others
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* and Apache License v2.0 which accompanies this distribution.
* The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
* and the Apache License v2.0 is available at http://www.opensource.org/licenses/apache2.0.php.
*
* You may elect to redistribute this code under either of these licenses.
*
* Contributors:
*
* Otavio Santana
*/
package org.jnosql.artemis.column;
import org.jnosql.artemis.PreparedStatementAsync;
import org.jnosql.diana.api.column.ColumnEntity;
import java.util.List;
import java.util.Optional;
import java.util.function.Consumer;
import static java.util.Objects.requireNonNull;
import static java.util.stream.Collectors.toList;
final class ColumnPreparedStatementAsync implements PreparedStatementAsync {
private final org.jnosql.diana.api.column.ColumnPreparedStatementAsync preparedStatementAsync;
private final ColumnEntityConverter converter;
ColumnPreparedStatementAsync(org.jnosql.diana.api.column.ColumnPreparedStatementAsync preparedStatementAsync,
ColumnEntityConverter converter) {
this.preparedStatementAsync = preparedStatementAsync;
this.converter = converter;
}
@Override
public PreparedStatementAsync bind(String name, Object value) {
preparedStatementAsync.bind(name, value);
return this;
}
@Override
public void getResultList(Consumer> callback) {
requireNonNull(callback, "callback is required");
Consumer> mapper = columnEntities -> callback.accept(columnEntities.stream().map(c -> (T) converter.toEntity(c))
.collect(toList()));
preparedStatementAsync.getResultList(mapper);
}
@Override
public void getSingleResult(Consumer> callback) {
requireNonNull(callback, "callback is required");
Consumer> mapper = columnEntity -> callback.accept(columnEntity.map(converter::toEntity));
preparedStatementAsync.getSingleResult(mapper);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy