Rename mdsal-netconf-connector to netconf-server-mdsal
[netconf.git] / plugins / netconf-server-mdsal / src / main / java / org / opendaylight / netconf / mdsal / connector / ops / DataTreeChange.java
1 /*
2  * Copyright (c) 2015 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.netconf.mdsal.connector.ops;
9
10 import static java.util.Objects.requireNonNull;
11
12 import com.google.common.base.MoreObjects;
13 import com.google.common.collect.ImmutableList;
14 import com.google.common.collect.ImmutableList.Builder;
15 import java.util.Deque;
16 import org.opendaylight.netconf.api.EffectiveOperation;
17 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
18 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
19 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
20
21 public final class DataTreeChange {
22     private final NormalizedNode changeRoot;
23     private final YangInstanceIdentifier path;
24     private final EffectiveOperation action;
25
26     DataTreeChange(final NormalizedNode changeRoot, final EffectiveOperation action, final Deque<PathArgument> path) {
27         this.changeRoot = requireNonNull(changeRoot);
28         this.action = requireNonNull(action);
29
30         final Builder<PathArgument> builder = ImmutableList.builderWithExpectedSize(path.size());
31         path.descendingIterator().forEachRemaining(builder::add);
32         this.path = YangInstanceIdentifier.create(builder.build());
33     }
34
35     public NormalizedNode getChangeRoot() {
36         return changeRoot;
37     }
38
39     public EffectiveOperation getAction() {
40         return action;
41     }
42
43     public YangInstanceIdentifier getPath() {
44         return path;
45     }
46
47     @Override
48     public String toString() {
49         return MoreObjects.toStringHelper(this).add("action", action).add("path", path).add("root", changeRoot)
50                 .toString();
51     }
52 }