HONEYCOMB-431: add validation support to Writers
[honeycomb.git] / infra / translate-api / src / main / java / io / fd / honeycomb / translate / write / Writer.java
index 18573e5..f3265a3 100644 (file)
@@ -32,6 +32,20 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 @Beta
 public interface Writer<D extends DataObject> extends SubtreeManager<D> {
 
+    /**
+     * Validates data modification.
+     *
+     * @param id Identifier of data being validated
+     * @param dataBefore Old data
+     * @param dataAfter New, updated data
+     * @param ctx Write context enabling writer to get information about candidate data as well as current data
+     */
+    default void validate(@Nonnull final InstanceIdentifier<? extends DataObject> id,
+                          @Nullable final DataObject dataBefore,
+                          @Nullable final DataObject dataAfter,
+                          @Nonnull final WriteContext ctx) throws DataValidationFailedException {
+    }
+
     /**
      * Process modifications and translate them as create/update/delete operations to lower level
      *