2 * Copyright (c) 2019 PANTHEON.tech, s.r.o. and others. All rights reserved.
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
8 package org.opendaylight.controller.cluster.datastore.node.utils.stream;
10 import static java.util.Objects.requireNonNull;
12 import com.google.common.collect.ImmutableList;
13 import com.google.common.collect.ImmutableList.Builder;
14 import java.io.DataInput;
15 import java.io.IOException;
16 import org.eclipse.jdt.annotation.NonNull;
17 import org.opendaylight.yangtools.yang.common.QName;
18 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
20 abstract class AbstractNormalizedNodeDataInput extends ForwardingDataInput implements NormalizedNodeDataInput {
21 // Visible for subclasses
22 final @NonNull DataInput input;
24 AbstractNormalizedNodeDataInput(final DataInput input) {
25 this.input = requireNonNull(input);
29 final DataInput delegate() {
34 public final SchemaPath readSchemaPath() throws IOException {
35 final boolean absolute = input.readBoolean();
36 final int size = input.readInt();
38 final Builder<QName> qnames = ImmutableList.builderWithExpectedSize(size);
39 for (int i = 0; i < size; ++i) {
40 qnames.add(readQName());
42 return SchemaPath.create(qnames.build(), absolute);