2 * Copyright (c) 2017 Pantheon Technologies s.r.o. 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.serialized;
10 import com.google.common.annotations.Beta;
11 import javax.annotation.Nonnull;
12 import org.opendaylight.mdsal.binding.javav2.dom.codec.api.serializer.BindingNormalizedNodeSerializer;
13 import org.opendaylight.mdsal.binding.javav2.runtime.reflection.BindingReflections;
14 import org.opendaylight.mdsal.binding.javav2.spec.base.Notification;
15 import org.opendaylight.mdsal.dom.api.DOMNotification;
16 import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
17 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
20 * Lazy serialized implementation of DOM Notification.
23 * This implementation performs serialization of data, only if receiver of notification actually accessed data
28 public final class LazySerializedDOMNotification implements DOMNotification {
30 private final BindingNormalizedNodeSerializer codec;
31 private final Notification<?> data;
32 private final SchemaPath type;
34 private ContainerNode domBody;
36 private LazySerializedDOMNotification(final BindingNormalizedNodeSerializer codec, final Notification<?> data,
37 final SchemaPath type) {
44 * Create serializer of Binding notification data to DOM notification with specific codec.
49 * - binding notification data
50 * @return DOM notification serializer
52 public static DOMNotification create(final BindingNormalizedNodeSerializer codec, final Notification<?> data) {
53 final SchemaPath type = SchemaPath.create(true, BindingReflections.findQName(data.getClass()));
54 return new LazySerializedDOMNotification(codec, data, type);
59 public SchemaPath getType() {
65 public ContainerNode getBody() {
66 if (domBody == null) {
67 domBody = codec.toNormalizedNodeNotification(data);
73 * Get binding notification data.
75 * @return binding notification data
77 public Notification<?> getBindingData() {