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 com.google.common.base.Optional;
11 import com.google.common.base.Preconditions;
12 import javax.annotation.Nonnull;
13 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
14 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
17 * A {@link DataTreeModification} implementation which delegates all calls to
18 * another instance, making sure no method is being invoked from multiple threads
21 public final class SynchronizedDataTreeModification implements DataTreeModification {
22 private final DataTreeModification delegate;
24 private SynchronizedDataTreeModification(final DataTreeModification delegate) {
25 this.delegate = Preconditions.checkNotNull(delegate);
28 public static DataTreeModification create(final DataTreeModification delegate) {
29 return new SynchronizedDataTreeModification(delegate);
33 public synchronized Optional<NormalizedNode<?, ?>> readNode(final YangInstanceIdentifier path) {
34 return delegate.readNode(path);
38 public synchronized DataTreeModification newModification() {
39 return delegate.newModification();
43 public synchronized void delete(final YangInstanceIdentifier path) {
44 delegate.delete(path);
48 public synchronized void merge(final YangInstanceIdentifier path, final NormalizedNode<?, ?> data) {
49 delegate.merge(path, data);
53 public synchronized void write(final YangInstanceIdentifier path, final NormalizedNode<?, ?> data) {
54 delegate.write(path, data);
58 public synchronized void ready() {
63 public synchronized void applyToCursor(@Nonnull final DataTreeModificationCursor cursor) {
64 delegate.applyToCursor(cursor);