cc901d6fee5732d73650f5d7f0a8ed359658f982
[controller.git] / opendaylight / md-sal / cds-access-api / src / main / java / org / opendaylight / controller / cluster / access / commands / TransactionDataModification.java
1 /*
2  * Copyright (c) 2016 Cisco Systems, Inc. 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.controller.cluster.access.commands;
9
10 import static java.util.Objects.requireNonNull;
11
12 import com.google.common.annotations.Beta;
13 import java.io.IOException;
14 import org.opendaylight.controller.cluster.datastore.node.utils.stream.NormalizedNodeDataOutput;
15 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
16 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
17
18 /**
19  * A {@link TransactionModification} which has a data component.
20  *
21  * @author Robert Varga
22  */
23 @Beta
24 public abstract class TransactionDataModification extends TransactionModification {
25     private final NormalizedNode<?, ?> data;
26
27     TransactionDataModification(final YangInstanceIdentifier path, final NormalizedNode<?, ?> data) {
28         super(path);
29         this.data = requireNonNull(data);
30     }
31
32     public final NormalizedNode<?, ?> getData() {
33         return data;
34     }
35
36     @Override
37     final void writeTo(final NormalizedNodeDataOutput out) throws IOException {
38         super.writeTo(out);
39         out.writeNormalizedNode(data);
40     }
41 }