*/
package org.opendaylight.yangtools.yang.data.impl.schema.tree;
-import com.google.common.base.Preconditions;
+import static java.util.Objects.requireNonNull;
+
+import com.google.common.base.MoreObjects;
+import org.eclipse.jdt.annotation.NonNull;
+import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNodes;
import org.opendaylight.yangtools.yang.data.api.schema.tree.spi.TreeNode;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
final class DataTreeState {
private final LatestOperationHolder holder;
private final SchemaContext schemaContext;
- private final TreeNode root;
+ private final @NonNull TreeNode root;
private DataTreeState(final TreeNode root) {
- this.root = Preconditions.checkNotNull(root);
+ this.root = requireNonNull(root);
holder = new LatestOperationHolder();
schemaContext = null;
}
private DataTreeState(final TreeNode root, final LatestOperationHolder holder, final SchemaContext schemaContext) {
// It should be impossible to instantiate a new root without a SchemaContext
- this.schemaContext = Preconditions.checkNotNull(schemaContext);
- this.holder = Preconditions.checkNotNull(holder);
- this.root = Preconditions.checkNotNull(root);
+ this.schemaContext = requireNonNull(schemaContext);
+ this.holder = requireNonNull(holder);
+ this.root = requireNonNull(root);
}
static DataTreeState createInitial(final TreeNode root) {
return new DataTreeState(root);
}
- TreeNode getRoot() {
+ @NonNull TreeNode getRoot() {
return root;
}
return new InMemoryDataTreeSnapshot(schemaContext, root, holder.newSnapshot());
}
- DataTreeState withSchemaContext(final SchemaContext newSchemaContext, final SchemaAwareApplyOperation operation) {
+ DataTreeState withSchemaContext(final SchemaContext newSchemaContext, final ModificationApplyOperation operation) {
holder.setCurrent(operation);
return new DataTreeState(root, holder, newSchemaContext);
}
DataTreeState withRoot(final TreeNode newRoot) {
return new DataTreeState(newRoot, holder, schemaContext);
}
+
+ @Override
+ public String toString() {
+ final TreeNode r = root;
+ return MoreObjects.toStringHelper(this).add("data", NormalizedNodes.toStringTree(r.getData())).toString();
+ }
}
\ No newline at end of file