BUG-509: cleanup datastore interafaces
[controller.git] / opendaylight / md-sal / sal-dom-broker / src / main / java / org / opendaylight / controller / md / sal / dom / store / impl / tree / DataPreconditionFailedException.java
1 /*
2  * Copyright (c) 2014 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.controller.md.sal.dom.store.impl.tree;
9
10 import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier;
11
12 import com.google.common.base.Preconditions;
13
14 /**
15  * Exception thrown when a proposed change fails validation before being
16  * applied into the datastore. This can have multiple reasons, for example
17  * the datastore has been concurrently modified such that a conflicting
18  * node is present, or the modification is structurally incorrect.
19  */
20 public class DataPreconditionFailedException extends Exception {
21     private static final long serialVersionUID = 1L;
22     private final InstanceIdentifier path;
23
24     /**
25      * Create a new instance.
26      *
27      * @param path Object path which caused this exception
28      * @param message Specific message describing the failure
29      */
30     public DataPreconditionFailedException(final InstanceIdentifier path, final String message) {
31         this(path, message, null);
32     }
33     /**
34      * Create a new instance, initializing
35      *
36      * @param path Object path which caused this exception
37      * @param message Specific message describing the failure
38      * @param cause Exception which triggered this failure, may be null
39      */
40     public DataPreconditionFailedException(final InstanceIdentifier path, final String message, final Throwable cause) {
41         super(message, cause);
42         this.path = Preconditions.checkNotNull(path);
43     }
44
45     /**
46      * Returns the offending object path.
47      *
48      * @return Path of the offending object
49      */
50     public InstanceIdentifier getPath() {
51         return path;
52     }
53 }