import java.io.IOException;
import org.opendaylight.mdsal.binding.javav2.spec.base.TreeNode;
-/*
+/**
* A serializer which writes TreeNode to supplied stream event writer.
*/
@Beta
public interface TreeNodeSerializer {
/**
- * Writes stream events representing object to supplied stream
+ * Writes stream events representing object to supplied stream.
*
* @param obj
* Source of stream events
--- /dev/null
+/*
+ * Copyright (c) 2017 Pantheon Technologies s.r.o. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.mdsal.binding.javav2.spec.runtime;
+
+import java.io.IOException;
+import org.opendaylight.mdsal.binding.javav2.spec.base.TreeNode;
+
+/**
+ * Contract for implementations of {@link TreeNodeSerializer}.
+ * The contract is kept between implementation of {@link TreeNodeSerializerRegistry},
+ * which maintains the lookup context required for recursive serialization.
+ */
+public interface TreeNodeSerializerImplementation {
+
+ /**
+ * Writes stream events for supplied data object to provided stream.
+ *
+ * DataObjectSerializerRegistry may be used to lookup serializers
+ * for other generated classes in order to support writing
+ * their events.
+ */
+ void serialize(TreeNodeSerializerRegistry reg, TreeNode obj, BindingStreamEventWriter stream) throws IOException;
+}
--- /dev/null
+/*
+ * Copyright (c) 2017 Pantheon Technologies s.r.o. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.mdsal.binding.javav2.spec.runtime;
+
+import org.opendaylight.mdsal.binding.javav2.spec.base.TreeNode;
+
+/**
+ * Contract for registry of {@link TreeNodeSerializer}.
+ * The contract is kept between implementation of {@link TreeNodeSerializerImplementation},
+ * Registry provides lookup for serializers to support recursive
+ * serialization of nested {@link TreeNode}s.
+ */
+public interface TreeNodeSerializerRegistry {
+
+ /**
+ * Returns implementation of requested serializer.
+ * @param binding input binding class
+ * @return returns serializer, based on input binding class
+ */
+ TreeNodeSerializer getSerializer(Class<? extends TreeNode> binding);
+}