X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-clustering-commons%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcluster%2Fdatastore%2Fnode%2Futils%2Fstream%2FAbstractNormalizedNodeDataInput.java;fp=opendaylight%2Fmd-sal%2Fsal-clustering-commons%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcluster%2Fdatastore%2Fnode%2Futils%2Fstream%2FAbstractNormalizedNodeDataInput.java;h=f6ab7607773c1bb3d990df004ae7c26334695828;hb=ad7135c49d0ec5f7180b46fe3657349c5d81bc63;hp=0000000000000000000000000000000000000000;hpb=32de58ddec79025c40342566a93fb8bf52077334;p=controller.git diff --git a/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/stream/AbstractNormalizedNodeDataInput.java b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/stream/AbstractNormalizedNodeDataInput.java new file mode 100644 index 0000000000..f6ab760777 --- /dev/null +++ b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/stream/AbstractNormalizedNodeDataInput.java @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2019 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.controller.cluster.datastore.node.utils.stream; + +import static java.util.Objects.requireNonNull; + +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableList.Builder; +import java.io.DataInput; +import java.io.IOException; +import org.eclipse.jdt.annotation.NonNull; +import org.opendaylight.yangtools.yang.common.QName; +import org.opendaylight.yangtools.yang.model.api.SchemaPath; + +abstract class AbstractNormalizedNodeDataInput extends ForwardingDataInput implements NormalizedNodeDataInput { + // Visible for subclasses + final @NonNull DataInput input; + + AbstractNormalizedNodeDataInput(final DataInput input) { + this.input = requireNonNull(input); + } + + @Override + final DataInput delegate() { + return input; + } + + @Override + public final SchemaPath readSchemaPath() throws IOException { + final boolean absolute = input.readBoolean(); + final int size = input.readInt(); + + final Builder qnames = ImmutableList.builderWithExpectedSize(size); + for (int i = 0; i < size; ++i) { + qnames.add(readQName()); + } + return SchemaPath.create(qnames.build(), absolute); + } + +}