Cleaned up Java Binding code from YANG Tools
[mdsal.git] / binding / mdsal-binding-dom-codec / src / main / java / org / opendaylight / yangtools / binding / data / codec / gen / impl / DataObjectSerializerPrototype.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.yangtools.binding.data.codec.gen.impl;
9
10 import org.opendaylight.yangtools.yang.binding.BindingStreamEventWriter;
11 import org.opendaylight.yangtools.yang.binding.DataObject;
12 import org.opendaylight.yangtools.yang.binding.DataObjectSerializerImplementation;
13 import org.opendaylight.yangtools.yang.binding.DataObjectSerializerRegistry;
14
15 /**
16  * Prototype of a DataObjectSerializerImplementation. This is a template class, which the
17  * {@link AbstractStreamWriterGenerator} uses to instantiate {@link DataObjectSerializerImplementation}
18  * on a per-type basis. During that time, the {@link #serialize(DataObjectSerializerRegistry, DataObject, BindingStreamEventWriter)}
19  * method will be replaced by the real implementation.
20  */
21 final class DataObjectSerializerPrototype implements DataObjectSerializerImplementation {
22     private static final DataObjectSerializerPrototype INSTANCE = new DataObjectSerializerPrototype();
23
24     private DataObjectSerializerPrototype() {
25         // Intentionally hidden, subclasses can replace it
26     }
27
28     /**
29      * Return the shared serializer instance.
30      *
31      * @return Global singleton instance.
32      */
33     public static DataObjectSerializerPrototype getInstance() {
34         return INSTANCE;
35     }
36
37     @Override
38     public void serialize(final DataObjectSerializerRegistry reg, final DataObject obj, final BindingStreamEventWriter stream) {
39         throw new UnsupportedOperationException("Prototype body, this code should never be invoked.");
40     }
41 }