]> git.basschouten.com Git - openhab-addons.git/blob
dfc7e0a6e3049596375ea25e5199792553e7e5e0
[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.icloud.internal.utilities;
14
15 import org.eclipse.jdt.annotation.NonNull;
16 import org.eclipse.jdt.annotation.NonNullByDefault;
17
18 /**
19  * Implementation of simple pair. Used mainly for HTTP header handling.
20  *
21  * @author Simon Spielmann - Initial contribution.
22  * @param <K> Type of first element
23  * @param <V> Type of second element
24  */
25 @NonNullByDefault
26 public class Pair<@NonNull K, @NonNull V> {
27
28     private K key;
29
30     private V value;
31
32     private Pair(K key, V value) {
33         this.key = key;
34         this.value = value;
35     }
36
37     /**
38      * Create pair with key and value. Both of type {@link String}.
39      *
40      * @param key Key
41      * @param value Value
42      * @return Pair with given key and value
43      */
44     public static Pair<String, String> of(String key, String value) {
45         return new Pair<>(key, value);
46     }
47
48     @Override
49     public String toString() {
50         return "Pair [key=" + this.key + ", value=" + this.value + "]";
51     }
52
53     /**
54      * @return key
55      */
56     public K getKey() {
57         return this.key;
58     }
59
60     /**
61      * @return value
62      */
63     public V getValue() {
64         return this.value;
65     }
66 }