summaryrefslogtreecommitdiffstats
path: root/infra/data-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/honeycomb/params/xml/ns/yang/data/impl/rev160411/InMemoryDataTreeModule.java
blob: 99e5b396cc0eba03c365b4fe879db8b14c9e9e3d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
package org.opendaylight.yang.gen.v1.urn.honeycomb.params.xml.ns.yang.data.impl.rev160411;

import org.opendaylight.yang.gen.v1.urn.honeycomb.params.xml.ns.yang.data.api.rev160411.DatatreeType;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.opendaylight.yangtools.yang.data.api.schema.tree.*;
import org.opendaylight.yangtools.yang.data.impl.schema.tree.InMemoryDataTreeFactory;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class InMemoryDataTreeModule extends org.opendaylight.yang.gen.v1.urn.honeycomb.params.xml.ns.yang.data.impl.rev160411.AbstractInMemoryDataTreeModule {

    private static final Logger LOG = LoggerFactory.getLogger(InMemoryDataTreeModule.class);

    public InMemoryDataTreeModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
        super(identifier, dependencyResolver);
    }

    public InMemoryDataTreeModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver, org.opendaylight.yang.gen.v1.urn.honeycomb.params.xml.ns.yang.data.impl.rev160411.InMemoryDataTreeModule oldModule, java.lang.AutoCloseable oldInstance) {
        super(identifier, dependencyResolver, oldModule, oldInstance);
    }

    @Override
    public void customValidation() {
        // add custom validation form module attributes here.
    }

    @Override
    public java.lang.AutoCloseable createInstance() {
        LOG.debug("InMemoryConfigDataTreeModule.createInstance()");
        return new CloseableConfigDataTree(getSchemaServiceDependency().getGlobalContext(), getType());
    }

    private static class CloseableConfigDataTree implements AutoCloseable, DataTree {
        private final DataTree dataTree;

        CloseableConfigDataTree(final SchemaContext schemaContext, final DatatreeType type) {
            this.dataTree = InMemoryDataTreeFactory.getInstance().create(
                type == DatatreeType.Config ? TreeType.CONFIGURATION : TreeType.OPERATIONAL
            );
            dataTree.setSchemaContext(schemaContext);
        }

        @Override
        public void close() throws Exception {
            // NOP
        }

        @Override
        public DataTreeSnapshot takeSnapshot() {
            return dataTree.takeSnapshot();
        }

        @Override
        public void setSchemaContext(final SchemaContext newSchemaContext) {
            dataTree.setSchemaContext(newSchemaContext);
        }

        @Override
        public void commit(final DataTreeCandidate candidate) {
            dataTree.commit(candidate);
        }

        @Override
        public YangInstanceIdentifier getRootPath() {
            return dataTree.getRootPath();
        }

        @Override
        public void validate(final DataTreeModification modification) throws DataValidationFailedException {
            dataTree.validate(modification);
        }

        @Override
        public DataTreeCandidate prepare(final DataTreeModification modification) {
            return dataTree.prepare(modification);
        }
    }
}