]> git.basschouten.com Git - openhab-addons.git/blob
5a57938a492ea44a305b33d33928c09a75e9d842
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2023 Contributors to the openHAB project
3  *
4  * See the NOTICE file(s) distributed with this work for additional
5  * information.
6  *
7  * This program and the accompanying materials are made available under the
8  * terms of the Eclipse Public License 2.0 which is available at
9  * http://www.eclipse.org/legal/epl-2.0
10  *
11  * SPDX-License-Identifier: EPL-2.0
12  */
13 package org.openhab.binding.dbquery.internal.domain;
14
15 import java.util.Collections;
16 import java.util.HashMap;
17 import java.util.Map;
18
19 import org.eclipse.jdt.annotation.NonNullByDefault;
20 import org.eclipse.jdt.annotation.Nullable;
21
22 /**
23  * Query parameters
24  *
25  * @author Joan Pujol - Initial contribution
26  */
27 @NonNullByDefault
28 public class QueryParameters {
29     public static final QueryParameters EMPTY = new QueryParameters(Collections.emptyMap());
30     private final Map<String, @Nullable Object> params;
31
32     private QueryParameters() {
33         this.params = new HashMap<>();
34     }
35
36     public QueryParameters(Map<String, @Nullable Object> params) {
37         this.params = params;
38     }
39
40     public void setParameter(String name, @Nullable Object value) {
41         params.put(name, value);
42     }
43
44     public @Nullable Object getParameter(String paramName) {
45         return params.get(paramName);
46     }
47
48     public Map<String, @Nullable Object> getAll() {
49         return Collections.unmodifiableMap(params);
50     }
51
52     public int size() {
53         return params.size();
54     }
55 }