2 * Copyright (c) 2018 ZTE, 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.javav2.dom.codec.impl;
10 import com.google.common.annotations.Beta;
11 import com.google.common.base.Preconditions;
12 import javax.xml.transform.dom.DOMSource;
13 import org.opendaylight.mdsal.binding.javav2.runtime.context.BindingRuntimeContext;
14 import org.opendaylight.yangtools.concepts.Codec;
15 import org.w3c.dom.Document;
18 * Codec for serialize/deserialize anyxml.
21 public final class AnyxmlCodec implements Codec<DOMSource, Document> {
23 private final BindingRuntimeContext context;
26 * Prepared binding runtime context for anyxml codec.
29 * - binding runtime context
31 public AnyxmlCodec(final BindingRuntimeContext context) {
32 this.context = Preconditions.checkNotNull(context);
36 public Document deserialize(final DOMSource input) {
37 Preconditions.checkArgument(input != null, "Input must not be null.");
38 return (Document) input.getNode();
42 public DOMSource serialize(final Document input) {
43 Preconditions.checkArgument(input != null, "Input must not be null.");
44 return new DOMSource(input);