2 * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
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
8 package org.opendaylight.yangtools.yang.data.api.schema.tree;
10 import static java.util.Objects.requireNonNull;
12 import java.util.Optional;
13 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
14 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
15 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
18 * A {@link DataTreeModification} implementation which delegates all calls to
19 * another instance, making sure no method is being invoked from multiple threads
22 public final class SynchronizedDataTreeModification implements DataTreeModification {
23 private final DataTreeModification delegate;
25 private SynchronizedDataTreeModification(final DataTreeModification delegate) {
26 this.delegate = requireNonNull(delegate);
29 public static DataTreeModification create(final DataTreeModification delegate) {
30 return new SynchronizedDataTreeModification(delegate);
34 public synchronized Optional<NormalizedNode<?, ?>> readNode(final YangInstanceIdentifier path) {
35 return delegate.readNode(path);
39 public synchronized DataTreeModification newModification() {
40 return delegate.newModification();
44 public synchronized void delete(final YangInstanceIdentifier path) {
45 delegate.delete(path);
49 public synchronized void merge(final YangInstanceIdentifier path, final NormalizedNode<?, ?> data) {
50 delegate.merge(path, data);
54 public synchronized void write(final YangInstanceIdentifier path, final NormalizedNode<?, ?> data) {
55 delegate.write(path, data);
59 public synchronized void ready() {
64 public synchronized void applyToCursor(final DataTreeModificationCursor cursor) {
65 delegate.applyToCursor(cursor);
69 public synchronized SchemaContext getSchemaContext() {
70 return delegate.getSchemaContext();