01 /*
02 * SPDX-License-Identifier: Apache-2.0
03 *
04 * Copyright 2020-2022 Agorapulse.
05 *
06 * Licensed under the Apache License, Version 2.0 (the "License");
07 * you may not use this file except in compliance with the License.
08 * You may obtain a copy of the License at
09 *
10 * https://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 */
18 package com.agorapulse.micronaut.bigquery;
19
20 import java.util.Map;
21
22 /**
23 * Parametrized SQL contains the statement and the map of the named parameters.
24 */
25 public final class ParameterizedSql {
26
27 /**
28 * Creates the named parameters from the map of named parameters and a SQL statement
29 * @param namedParameters the map of the named parameters
30 * @param sql the sql statement, must contain <code>@</code> as named parameter prefix
31 * @return
32 */
33 public static ParameterizedSql from(Map<String, ?> namedParameters, String sql) {
34 return new ParameterizedSql(namedParameters, sql);
35 }
36
37 private ParameterizedSql(Map<String, ?> namedParameters, String sql) {
38 this.namedParameters = namedParameters;
39 this.sql = sql;
40 }
41
42 /**
43 * @return the map of the named parameters
44 */
45 public Map<String, ?> getNamedParameters() {
46 return namedParameters;
47 }
48
49 /**
50 * @return the SQL statement
51 */
52 public String getSql() {
53 return sql;
54 }
55
56 private final Map<String, ?> namedParameters;
57 private final String sql;
58 }
|