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.yangtools.yang.binding.Notification;
13 import org.opendaylight.yangtools.yang.binding.util.BindingReflections;
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.
20 * This implementation performs serialization of data, only if receiver
21 * of notification actually accessed data from notification.
24 public final class LazySerializedDOMNotification implements DOMNotification {
26 private final BindingNormalizedNodeSerializer codec;
27 private final Notification data;
28 private final SchemaPath type;
30 private ContainerNode domBody;
32 private LazySerializedDOMNotification(final BindingNormalizedNodeSerializer codec, final Notification data, final SchemaPath type) {
39 static DOMNotification create(final BindingNormalizedNodeSerializer codec, final Notification data) {
40 final SchemaPath type = SchemaPath.create(true, BindingReflections.findQName(data.getImplementedInterface()));
41 return new LazySerializedDOMNotification(codec, data, type);
45 public SchemaPath getType() {
50 public ContainerNode getBody() {
51 if (domBody == null) {
52 domBody = codec.toNormalizedNodeNotification(data);
57 public Notification getBindingData() {