Add SSv1 27/102127/2
authorRobert Varga <robert.varga@pantheon.tech>
Wed, 17 Aug 2022 07:42:35 +0000 (09:42 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Wed, 17 Aug 2022 09:01:12 +0000 (11:01 +0200)
Add a serialization proxy for SingletonSet, so that we have explicit
control over the format.

Change-Id: Iedf53fe200215fbe1236464677e42b7d27d0caf5
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 3e086972fad7b1d81b8a9d3e4ed0f84f2e8822fe)

common/util/src/main/java/org/opendaylight/yangtools/util/SSv1.java [new file with mode: 0644]

diff --git a/common/util/src/main/java/org/opendaylight/yangtools/util/SSv1.java b/common/util/src/main/java/org/opendaylight/yangtools/util/SSv1.java
new file mode 100644 (file)
index 0000000..e0481b5
--- /dev/null
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2022 PANTHEON.tech, s.r.o. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.util;
+
+import java.io.Serializable;
+
+/**
+ * Serialization proxy for {@link SingletonSet}.
+ */
+final class SSv1 implements Serializable {
+    private static final long serialVersionUID = 1;
+
+    private final Object element;
+
+    SSv1(final Object element) {
+        this.element = element;
+    }
+
+    private Object readResolve() {
+        return SingletonSet.of(element);
+    }
+}