X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=binding%2Fmdsal-binding-dom-codec%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fmdsal%2Fbinding%2Fdom%2Fcodec%2Fimpl%2FSchemaRootCodecContext.java;h=bfa286ac54267f1aea8728fc8883c6a4c1636043;hb=61fdc5953d6041f6be61663b941d926b1fbd3221;hp=be48e153fd1820893683c14fca66ded6817fe4c0;hpb=7f1cd0306b107bf71ee931af676e82d8d2366352;p=mdsal.git diff --git a/binding/mdsal-binding-dom-codec/src/main/java/org/opendaylight/mdsal/binding/dom/codec/impl/SchemaRootCodecContext.java b/binding/mdsal-binding-dom-codec/src/main/java/org/opendaylight/mdsal/binding/dom/codec/impl/SchemaRootCodecContext.java index be48e153fd..bfa286ac54 100644 --- a/binding/mdsal-binding-dom-codec/src/main/java/org/opendaylight/mdsal/binding/dom/codec/impl/SchemaRootCodecContext.java +++ b/binding/mdsal-binding-dom-codec/src/main/java/org/opendaylight/mdsal/binding/dom/codec/impl/SchemaRootCodecContext.java @@ -61,13 +61,6 @@ final class SchemaRootCodecContext extends DataContainerCo CacheBuilder.newBuilder().build(new CacheLoader<>() { @Override public DataContainerCodecContext load(final Class key) { - if (Notification.class.isAssignableFrom(key)) { - checkArgument(key.isInterface(), "Supplied class must be interface."); - final QName qname = BindingReflections.findQName(key); - final NotificationDefinition schema = getSchema().findNotification(qname).orElseThrow( - () -> new IllegalArgumentException("Supplied " + key + " is not valid notification")); - return new NotificationCodecContext<>(key, schema, factory()); - } return createDataTreeChildContext(key); } }); @@ -88,6 +81,18 @@ final class SchemaRootCodecContext extends DataContainerCo } }); + private final LoadingCache, NotificationCodecContext> notificationsByClass = CacheBuilder.newBuilder() + .build(new CacheLoader, NotificationCodecContext>() { + @Override + public NotificationCodecContext load(final Class key) { + checkArgument(key.isInterface(), "Supplied class must be interface."); + final QName qname = BindingReflections.findQName(key); + final NotificationDefinition schema = getSchema().findNotification(qname).orElseThrow( + () -> new IllegalArgumentException("Supplied " + key + " is not valid notification")); + return new NotificationCodecContext<>(key, schema, factory()); + } + }); + private final LoadingCache, ContainerNodeCodecContext> rpcDataByClass = CacheBuilder.newBuilder() .build(new CacheLoader, ContainerNodeCodecContext>() { @Override @@ -205,7 +210,7 @@ final class SchemaRootCodecContext extends DataContainerCo } NotificationCodecContext getNotification(final Class> notification) { - return (NotificationCodecContext) streamChild((Class)notification); + return getOrRethrow(notificationsByClass, notification); } NotificationCodecContext getNotification(final Absolute notification) {