Bump upstreams
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / main / java / org / opendaylight / controller / cluster / datastore / persisted / DeletedDataTreeCandidateNode.java
1 /*
2  * Copyright (c) 2015 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.cluster.datastore.persisted;
9
10 import java.util.Collection;
11 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
12 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
13 import org.opendaylight.yangtools.yang.data.tree.api.DataTreeCandidateNode;
14 import org.opendaylight.yangtools.yang.data.tree.api.ModificationType;
15
16 /**
17  * A deserialized {@link DataTreeCandidateNode} which represents a deletion.
18  */
19 abstract class DeletedDataTreeCandidateNode extends AbstractDataTreeCandidateNode {
20     private DeletedDataTreeCandidateNode() {
21         super(ModificationType.DELETE);
22     }
23
24     static DataTreeCandidateNode create() {
25         return new DeletedDataTreeCandidateNode() {
26             @Override
27             public PathArgument name() {
28                 throw new UnsupportedOperationException("Root node does not have an identifier");
29             }
30         };
31     }
32
33     static DataTreeCandidateNode create(final PathArgument identifier) {
34         return new DeletedDataTreeCandidateNode() {
35             @Override
36             public PathArgument name() {
37                 return identifier;
38             }
39         };
40     }
41
42     @Override
43     public final NormalizedNode dataAfter() {
44         return null;
45     }
46
47     @Override
48     public final Collection<DataTreeCandidateNode> childNodes() {
49         // We would require the before-image to reconstruct the list of nodes which were deleted.
50         throw new UnsupportedOperationException("Children not available after serialization");
51     }
52 }