Fix checkstyle in mdsal-binding-dom-codec
[mdsal.git] / binding / mdsal-binding-dom-codec / src / main / java / org / opendaylight / mdsal / binding / dom / codec / gen / impl / AugmentableDataNodeContainerEmitterSource.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 package org.opendaylight.mdsal.binding.dom.codec.gen.impl;
9
10 import org.opendaylight.mdsal.binding.model.api.GeneratedType;
11 import org.opendaylight.yangtools.yang.binding.DataObjectSerializerImplementation;
12 import org.opendaylight.yangtools.yang.model.api.DataNodeContainer;
13
14 abstract class AugmentableDataNodeContainerEmitterSource extends DataNodeContainerSerializerSource {
15     private static final String AUGMENTABLE_SERIALIZER = "AUGMENTABLE_SERIALIZER";
16
17     AugmentableDataNodeContainerEmitterSource(final AbstractStreamWriterGenerator generator, final GeneratedType type,
18             final DataNodeContainer node) {
19         super(generator, type, node);
20         /*
21          * Eventhough intuition says the serializer could reference the generator directly, that is not true in OSGi
22          * environment -- so we need to resolve the reference first and inject it as a static constant.
23          */
24         staticConstant(AUGMENTABLE_SERIALIZER, DataObjectSerializerImplementation.class,
25             StreamWriterGenerator.AUGMENTABLE);
26     }
27
28     @Override
29     protected void emitAfterBody(final StringBuilder sb) {
30         sb.append(statement(invoke(AUGMENTABLE_SERIALIZER, "serialize", REGISTRY, INPUT, STREAM)));
31     }
32 }