Skip to content

armgit / core

Public Imported from GitHub
0

100% open-source IoT Platform - Integrate your devices, add intelligence, build custom apps

Added Pair<K,V> class to container util

Rich Turnercc2439211ac8
diff --git a/container/src/main/java/org/openremote/container/util/Pair.java b/container/src/main/java/org/openremote/container/util/Pair.java
new file mode 100644
index 000000000..352caba09
--- /dev/null
+++ b/container/src/main/java/org/openremote/container/util/Pair.java
@@ -0,0 +1,53 @@
+/*
+ * Copyright 2017, OpenRemote Inc.
+ *
+ * See the CONTRIBUTORS.txt file in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.openremote.container.util;
+
+import java.io.Serializable;
+
+public class Pair<K, V> implements Serializable {
+ public K key;
+ public V value;
+
+ public Pair(K key, V value) {
+ this.key = key;
+ this.value = value;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o instanceof Pair) {
+ Pair pair = (Pair) o;
+ return (key != null ? key.equals(pair.key) : pair.key == null)
+ && (value != null ? value.equals(pair.value) : pair.value == null);
+ }
+ return false;
+ }
+
+ @Override
+ public int hashCode() {
+ return key.hashCode() * 13 + (value == null ? 0 : value.hashCode());
+ }
+
+ @Override
+ public String toString() {
+ return key + "=" + value;
+ }
+}