Merge "Bug 1577: Gates access to Shard actor until its initialized"
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / main / java / org / opendaylight / controller / cluster / datastore / modification / DeleteModification.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
9 package org.opendaylight.controller.cluster.datastore.modification;
10
11 import org.opendaylight.controller.cluster.datastore.util.InstanceIdentifierUtils;
12 import org.opendaylight.controller.protobuff.messages.persistent.PersistentMessages;
13 import org.opendaylight.controller.sal.core.spi.data.DOMStoreWriteTransaction;
14 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
15
16 /**
17  * DeleteModification store all the parameters required to delete a path from the data tree
18  */
19 public class DeleteModification extends AbstractModification {
20     private static final long serialVersionUID = 1L;
21
22     public DeleteModification(YangInstanceIdentifier path) {
23         super(path);
24     }
25
26     @Override
27     public void apply(DOMStoreWriteTransaction transaction) {
28         transaction.delete(path);
29     }
30
31     @Override
32     public Object toSerializable() {
33         return PersistentMessages.Modification.newBuilder().setType(this.getClass().toString())
34                 .setPath(InstanceIdentifierUtils.toSerializable(this.path)).build();
35     }
36
37     public static DeleteModification fromSerializable(Object serializable) {
38         PersistentMessages.Modification o = (PersistentMessages.Modification) serializable;
39         return new DeleteModification(InstanceIdentifierUtils.fromSerializable(o.getPath()));
40     }
41 }