8d68ce7d23062f1f96f611c52cc1d5eed38507d9
[yangtools.git] / yang / yang-data-api / src / main / java / org / opendaylight / yangtools / yang / data / api / schema / tree / DefaultDataTreeCandidate.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.yangtools.yang.data.api.schema.tree;
9
10 import com.google.common.base.MoreObjects;
11 import com.google.common.base.Preconditions;
12 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
13
14 /**
15  * Default utility implementation of the {@link DataTreeCandidate} contract.
16  */
17 final class DefaultDataTreeCandidate implements DataTreeCandidate {
18     private final YangInstanceIdentifier rootPath;
19     private final DataTreeCandidateNode rootNode;
20
21     DefaultDataTreeCandidate(final YangInstanceIdentifier rootPath, final DataTreeCandidateNode rootNode) {
22         this.rootPath = Preconditions.checkNotNull(rootPath);
23         this.rootNode = Preconditions.checkNotNull(rootNode);
24     }
25
26     @Override
27     public DataTreeCandidateNode getRootNode() {
28         return rootNode;
29     }
30
31     @Override
32     public YangInstanceIdentifier getRootPath() {
33         return rootPath;
34     }
35
36     @Override
37     public String toString() {
38         return MoreObjects.toStringHelper(this).add("rootPath", getRootPath()).add("rootNode", getRootNode()).toString();
39     }
40 }