19267b1bd68afe90f719ff70a888b437dd78971f
[hc2vpp.git] /
1 package org.opendaylight.yang.gen.v1.urn.honeycomb.params.xml.ns.yang.data.impl.rev160411;
2
3 import io.fd.honeycomb.v3po.data.DataTreeSnapshot;
4 import io.fd.honeycomb.v3po.data.ModifiableDataTree;
5 import io.fd.honeycomb.v3po.data.impl.ConfigDataTree;
6 import io.fd.honeycomb.v3po.translate.TranslationException;
7 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTree;
8 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeModification;
9 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataValidationFailedException;
10 import org.opendaylight.yangtools.yang.data.api.schema.tree.TreeType;
11 import org.opendaylight.yangtools.yang.data.impl.schema.tree.InMemoryDataTreeFactory;
12 import org.slf4j.Logger;
13 import org.slf4j.LoggerFactory;
14
15 public class ConfigDataTreeModule extends
16         org.opendaylight.yang.gen.v1.urn.honeycomb.params.xml.ns.yang.data.impl.rev160411.AbstractConfigDataTreeModule {
17
18     private static final Logger LOG = LoggerFactory.getLogger(ConfigDataTreeModule.class);
19
20     public ConfigDataTreeModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier,
21                                 org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
22         super(identifier, dependencyResolver);
23     }
24
25     public ConfigDataTreeModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier,
26                                 org.opendaylight.controller.config.api.DependencyResolver dependencyResolver,
27                                 org.opendaylight.yang.gen.v1.urn.honeycomb.params.xml.ns.yang.data.impl.rev160411.ConfigDataTreeModule oldModule,
28                                 java.lang.AutoCloseable oldInstance) {
29         super(identifier, dependencyResolver, oldModule, oldInstance);
30     }
31
32     @Override
33     public void customValidation() {
34         // add custom validation form module attributes here.
35     }
36
37     @Override
38     public java.lang.AutoCloseable createInstance() {
39         LOG.info("ConfigDataTreeModule.createInstance()");
40         final DataTree dataTree = InMemoryDataTreeFactory.getInstance().create(TreeType.CONFIGURATION);
41         dataTree.setSchemaContext(getSchemaServiceDependency().getGlobalContext());
42         return new CloseableConfigDataTree(
43                 new ConfigDataTree(getSerializerDependency(), dataTree, getWriterRegistryDependency()));
44     }
45
46     private static final class CloseableConfigDataTree implements ModifiableDataTree, AutoCloseable {
47
48         private final ConfigDataTree delegate;
49
50         CloseableConfigDataTree(final ConfigDataTree delegate) {
51             this.delegate = delegate;
52         }
53
54         @Override
55         public void close() throws Exception {
56             LOG.info("CloseableConfigDataTree.close()");
57             // NOP
58         }
59
60         @Override
61         public void modify(final DataTreeModification modification)
62                 throws DataValidationFailedException, TranslationException {
63             LOG.trace("CloseableConfigDataTree.modify modification={}", modification);
64             delegate.modify(modification);
65         }
66
67         @Override
68         public void initialize(final DataTreeModification modification) throws DataValidationFailedException {
69             LOG.trace("CloseableConfigDataTree.initialize modification={}", modification);
70             delegate.initialize(modification);
71         }
72
73         @Override
74         public DataTreeSnapshot takeSnapshot() {
75             LOG.trace("CloseableConfigDataTree.takeSnapshot");
76             return delegate.takeSnapshot();
77         }
78     }
79 }