Add IOMv1 proxy
[yangtools.git] / common / util / src / main / java / org / opendaylight / yangtools / util / UIOMv1.java
1 /*
2  * Copyright (c) 2022 PANTHEON.tech, s.r.o. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.yangtools.util;
9
10 import com.google.common.collect.ImmutableList;
11 import org.eclipse.jdt.annotation.NonNull;
12 import org.opendaylight.yangtools.util.ImmutableOffsetMap.Unordered;
13
14 /**
15  * Serialization proxy for {@link Unordered}.
16  */
17 final class UIOMv1 extends IOMv1<Unordered<?, ?>> {
18     private static final long serialVersionUID = 1;
19
20     @SuppressWarnings("checkstyle:RedundantModifier")
21     public UIOMv1() {
22         // For Externalizable
23     }
24
25     UIOMv1(final @NonNull Unordered<?, ?> map) {
26         super(map);
27     }
28
29     @Override
30     Unordered<?, ?> readReplace(final ImmutableList<Object> keys, final Object[] values) {
31         final var newOffsets = OffsetMapCache.unorderedOffsets(keys);
32         return new Unordered<>(newOffsets, OffsetMapCache.adjustedArray(newOffsets, keys, values));
33     }
34 }