2 * Copyright (c) 2015 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.controller.md.sal.binding.impl;
10 import org.opendaylight.controller.md.sal.dom.api.DOMNotification;
11 import org.opendaylight.mdsal.binding.dom.codec.api.BindingNormalizedNodeSerializer;
12 import org.opendaylight.mdsal.binding.spec.reflect.BindingReflections;
13 import org.opendaylight.yangtools.yang.binding.Notification;
14 import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
15 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
18 * Lazy serialized implementation of DOM Notification.
21 * This implementation performs serialization of data, only if receiver
22 * of notification actually accessed data from notification.
26 public final class LazySerializedDOMNotification implements DOMNotification {
28 private final BindingNormalizedNodeSerializer codec;
29 private final Notification data;
30 private final SchemaPath type;
32 private ContainerNode domBody;
34 private LazySerializedDOMNotification(final BindingNormalizedNodeSerializer codec, final Notification data,
35 final SchemaPath type) {
41 static DOMNotification create(final BindingNormalizedNodeSerializer codec, final Notification data) {
42 final SchemaPath type = SchemaPath.create(true, BindingReflections.findQName(data.implementedInterface()));
43 return new LazySerializedDOMNotification(codec, data, type);
47 public SchemaPath getType() {
52 public ContainerNode getBody() {
53 if (domBody == null) {
54 domBody = codec.toNormalizedNodeNotification(data);
59 public Notification getBindingData() {