2 * ============LICENSE_START==========================================
4 * ===================================================================
5 * Copyright (c) 2017-2019 AT&T Intellectual Property
6 * ===================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
19 * ============LICENSE_END=============================================
20 * ====================================================================
23 package org.onap.music.datastore;
25 import java.util.ArrayList;
26 import java.util.List;
33 public class PreparedQueryObject {
36 private List<Object> values;
37 private StringBuilder query;
38 private String consistency;
39 private String keyspaceName;
40 private String tableName;
41 private String operation;
42 private String primaryKeyValue;
46 * Create PreparedQueryObject
48 public PreparedQueryObject() {
49 this.values = new ArrayList<>();
50 this.query = new StringBuilder();
54 * Create PreparedQueryObject
55 * @param query query portion of the prepared query
57 public PreparedQueryObject(String query) {
58 this.values = new ArrayList<>();
59 this.query = new StringBuilder(query);
63 * Create PreparedQueryObject
64 * @param query query portion of the prepared query
65 * @param values to be added to the query string as prepared query
67 public PreparedQueryObject(String query, Object...values) {
68 this.query = new StringBuilder(query);
69 this.values = new ArrayList<>();
70 for (Object value: values) {
71 this.values.add(value);
75 public String getKeyspaceName() {
79 public void setKeyspaceName(String keyspaceName) {
80 this.keyspaceName = keyspaceName;
83 public String getTableName() {
87 public void setTableName(String tableName) {
88 this.tableName = tableName;
91 public String getOperation() {
95 public void setOperation(String operation) {
96 this.operation = operation;
99 public String getPrimaryKeyValue() {
100 return primaryKeyValue;
103 public void setPrimaryKeyValue(String primaryKeyValue) {
104 this.primaryKeyValue = primaryKeyValue;
107 public String getConsistency() {
111 public void setConsistency(String consistency) {
112 this.consistency = consistency;
116 * @return values to be set as part of the prepared query
118 public List<Object> getValues() {
123 * @param o object to be added as a value to the prepared query, in order
125 public void addValue(Object o) {
130 * Add values to the preparedQuery
131 * @param objs ordered list of objects to be added as values to the prepared query
133 public void addValues(Object... objs) {
134 for (Object obj: objs) {
135 this.values.add(obj);
142 public void appendQueryString(String s) {
143 this.query.append(s);
145 public void replaceQueryString(String s) {
146 this.query.replace(0, query.length(), s);
152 public String getQuery() {
153 return this.query.toString();