085a8457d1503af6b6f92f34eb6d645bb61afc67
[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 com.google.common.base.Optional;
11 import java.util.Collection;
12 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
13 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
14 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidateNode;
15 import org.opendaylight.yangtools.yang.data.api.schema.tree.ModificationType;
16
17 /**
18  * A deserialized {@link DataTreeCandidateNode} which represents a deletion.
19  */
20 abstract class DeletedDataTreeCandidateNode extends AbstractDataTreeCandidateNode {
21     private DeletedDataTreeCandidateNode() {
22         super(ModificationType.DELETE);
23     }
24
25     static DataTreeCandidateNode create() {
26         return new DeletedDataTreeCandidateNode() {
27             @Override
28             public PathArgument getIdentifier() {
29                 throw new UnsupportedOperationException("Root node does not have an identifier");
30             }
31         };
32     }
33
34     static DataTreeCandidateNode create(final PathArgument identifier) {
35         return new DeletedDataTreeCandidateNode() {
36             @Override
37             public PathArgument getIdentifier() {
38                 return identifier;
39             }
40         };
41     }
42
43     @Override
44     public final Optional<NormalizedNode<?, ?>> getDataAfter() {
45         return Optional.absent();
46     }
47
48     @Override
49     public final Collection<DataTreeCandidateNode> getChildNodes() {
50         // We would require the before-image to reconstruct the list of nodes which
51         // were deleted.
52         throw new UnsupportedOperationException("Children not available after serialization");
53     }
54 }

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.