72520c0aeca0b0c5c5f3f1972767f07b8863384e
[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 com.google.common.annotations.Beta;
11 import com.google.common.base.Preconditions;
12 import java.io.IOException;
13 import org.opendaylight.controller.cluster.datastore.node.utils.stream.NormalizedNodeDataOutput;
14 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
15 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
16
17 /**
18  * A {@link TransactionModification} which has a data component.
19  *
20  * @author Robert Varga
21  */
22 @Beta
23 public abstract class TransactionDataModification extends TransactionModification {
24     private final NormalizedNode<?, ?> data;
25
26     TransactionDataModification(final YangInstanceIdentifier path, final NormalizedNode<?, ?> data) {
27         super(path);
28         this.data = Preconditions.checkNotNull(data);
29     }
30
31     public final NormalizedNode<?, ?> getData() {
32         return data;
33     }
34
35     @Override
36     final void writeTo(final NormalizedNodeDataOutput out) throws IOException {
37         super.writeTo(out);
38         out.writeNormalizedNode(data);
39     }
40 }