// Path: dalesbred/src/main/java/org/dalesbred/internal/utils/CollectionUtils.java
// public static @NotNull <A,B> List<B> mapToList(@NotNull Collection<? extends A> xs, @NotNull Function<? super A, ? extends B> mapper) {
//     return xs.stream().map(mapper).collect(toListWithCapacity(xs.size()));
// }


import org.intellij.lang.annotations.Language;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.TestOnly;
import java.util.List;
import static org.dalesbred.internal.utils.CollectionUtils.mapToList;
/*
 * Copyright (c) 2017 Evident Solutions Oy
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */

package org.dalesbred.query;




final class NamedParameterSql {

    @Language("SQL")
    private final @NotNull String sql;

    private final @NotNull List<String> parameterNames;

    NamedParameterSql(@NotNull @Language("SQL") String sql, @NotNull List<String> parameterNames) {
        this.sql = sql;
        this.parameterNames = parameterNames;
    }

    public @NotNull SqlQuery toQuery(@NotNull VariableResolver variableResolver) {
        return SqlQuery.query(sql, resolveParameterValues(variableResolver));
    }

    private @NotNull List<?> resolveParameterValues(@NotNull VariableResolver variableResolver) {
// Path: dalesbred/src/main/java/org/dalesbred/internal/utils/CollectionUtils.java
// public static @NotNull <A,B> List<B> mapToList(@NotNull Collection<? extends A> xs, @NotNull Function<? super A, ? extends B> mapper) {
//     return xs.stream().map(mapper).collect(toListWithCapacity(xs.size()));
// }


// Path: dalesbred/src/main/java/org/dalesbred/query/NamedParameterSql.java
import org.intellij.lang.annotations.Language;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.TestOnly;
import java.util.List;
import static org.dalesbred.internal.utils.CollectionUtils.mapToList;

/*
 * Copyright (c) 2017 Evident Solutions Oy
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */

package org.dalesbred.query;




final class NamedParameterSql {

    @Language("SQL")
    private final @NotNull String sql;

    private final @NotNull List<String> parameterNames;

    NamedParameterSql(@NotNull @Language("SQL") String sql, @NotNull List<String> parameterNames) {
        this.sql = sql;
        this.parameterNames = parameterNames;
    }

    public @NotNull SqlQuery toQuery(@NotNull VariableResolver variableResolver) {
        return SqlQuery.query(sql, resolveParameterValues(variableResolver));
    }

    private @NotNull List<?> resolveParameterValues(@NotNull VariableResolver variableResolver) {
        return mapToList(parameterNames, variableResolver::getValue);