2 * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
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
8 package org.opendaylight.mdsal.binding.dom.codec.impl;
10 import static java.util.Objects.requireNonNull;
12 import java.io.IOException;
13 import org.eclipse.jdt.annotation.NonNull;
14 import org.opendaylight.mdsal.binding.dom.codec.api.BindingStreamEventWriter;
15 import org.opendaylight.yangtools.yang.binding.DataObject;
18 * A serializer which writes DataObject to supplied stream event writer.
20 final class DataObjectSerializer {
21 private final @NonNull DataObjectSerializerRegistry registry;
22 private final @NonNull DataObjectStreamer<?> delegate;
24 DataObjectSerializer(final DataObjectSerializerRegistry registry, final DataObjectStreamer<?> delegate) {
25 this.registry = requireNonNull(registry);
26 this.delegate = requireNonNull(delegate);
30 * Writes stream events representing object to supplied stream.
32 * @param obj Source of stream events
33 * @param stream Stream to which events should be written.
35 void serialize(final DataObject obj, final BindingStreamEventWriter stream) throws IOException {
36 delegate.serialize(registry, obj, stream);