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.mdsal.binding.dom.adapter;
10 import com.google.common.cache.CacheBuilder;
11 import com.google.common.cache.CacheLoader;
12 import com.google.common.cache.LoadingCache;
13 import org.opendaylight.mdsal.binding.dom.codec.api.BindingNormalizedNodeSerializer;
14 import org.opendaylight.mdsal.binding.spec.reflect.BindingReflections;
15 import org.opendaylight.yangtools.yang.binding.Notification;
16 import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
17 import org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier.Absolute;
20 * {@link AbstractLazySerializedEvent} specialized to RFC6020 global notifications.
22 final class LazySerializedNotification extends AbstractLazySerializedEvent<Notification<?>> {
23 private static final LoadingCache<Class<?>, Absolute> PATHS = CacheBuilder.newBuilder().weakKeys()
24 .build(new CacheLoader<>() {
26 public Absolute load(final Class<?> key) {
27 // FIXME: do not use reflection here, look the QName up from BindingRuntimeType
28 return Absolute.of(BindingReflections.findQName(key)).intern();
32 LazySerializedNotification(final BindingNormalizedNodeSerializer codec, final Notification<?> data) {
33 super(codec, data, PATHS.getUnchecked(data.implementedInterface()));
37 ContainerNode loadBody(final BindingNormalizedNodeSerializer codec) {
38 return codec.toNormalizedNodeNotification(getBindingData());