From 9a167254cc619fe205233ca47ba590608048b2b5 Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Wed, 11 Nov 2020 19:53:20 +0100 Subject: [PATCH] Cleanup SchemaRootCodecContext formatting Java 11 gives us <> on anonymous subclasses, hence we can clean up quite a bit here. Change-Id: I8c768a07535a6dde7c08d361b98349eb97d62774 Signed-off-by: Robert Varga --- .../codec/impl/SchemaRootCodecContext.java | 91 ++++++++++--------- 1 file changed, 46 insertions(+), 45 deletions(-) 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 e25ac36dad..d9f7e0995c 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 @@ -54,7 +54,8 @@ import org.opendaylight.yangtools.yang.model.util.SchemaNodeUtils; final class SchemaRootCodecContext extends DataContainerCodecContext { - private final LoadingCache, DataContainerCodecContext> childrenByClass = CacheBuilder.newBuilder() + private final LoadingCache, DataContainerCodecContext> childrenByClass = + CacheBuilder.newBuilder() .build(new CacheLoader, DataContainerCodecContext>() { @Override public DataContainerCodecContext load(final Class key) { @@ -62,13 +63,13 @@ final class SchemaRootCodecContext extends DataContainerCo } }); - private final LoadingCache>, ActionCodecContext> actionsByClass = CacheBuilder - .newBuilder().build(new CacheLoader>, ActionCodecContext>() { - @Override - public ActionCodecContext load(final Class> key) { - return createActionContext(key); - } - }); + private final LoadingCache>, ActionCodecContext> actionsByClass = + CacheBuilder.newBuilder().build(new CacheLoader<>() { + @Override + public ActionCodecContext load(final Class> key) { + return createActionContext(key); + } + }); private final LoadingCache, ContainerNodeCodecContext> rpcDataByClass = CacheBuilder.newBuilder().build( new CacheLoader, ContainerNodeCodecContext>() { @@ -87,55 +88,55 @@ final class SchemaRootCodecContext extends DataContainerCo }); private final LoadingCache, ChoiceNodeCodecContext> choicesByClass = - CacheBuilder.newBuilder().build(new CacheLoader, ChoiceNodeCodecContext>() { - @Override - public ChoiceNodeCodecContext load(final Class key) { - return createChoiceDataContext(key); - } - }); + CacheBuilder.newBuilder().build(new CacheLoader<>() { + @Override + public ChoiceNodeCodecContext load(final Class key) { + return createChoiceDataContext(key); + } + }); - private final LoadingCache> childrenByQName = CacheBuilder.newBuilder().build( - new CacheLoader>() { - @Override - public DataContainerCodecContext load(final QName qname) { - final DataSchemaNode childSchema = getSchema().getDataChildByName(qname); - childNonNull(childSchema, qname,"Argument %s is not valid child of %s", qname,getSchema()); - if (childSchema instanceof DataNodeContainer || childSchema instanceof ChoiceSchemaNode) { - @SuppressWarnings("unchecked") - final Class childCls = (Class) - factory().getRuntimeContext().getClassForSchema(childSchema); - return streamChild(childCls); - } - - throw new UnsupportedOperationException("Unsupported child type " + childSchema.getClass()); + private final LoadingCache> childrenByQName = + CacheBuilder.newBuilder().build(new CacheLoader<>() { + @Override + public DataContainerCodecContext load(final QName qname) { + final DataSchemaNode childSchema = getSchema().getDataChildByName(qname); + childNonNull(childSchema, qname, "Argument %s is not valid child of %s", qname, getSchema()); + if (childSchema instanceof DataNodeContainer || childSchema instanceof ChoiceSchemaNode) { + @SuppressWarnings("unchecked") + final Class childCls = (Class) + factory().getRuntimeContext().getClassForSchema(childSchema); + return streamChild(childCls); } - }); - private final LoadingCache> rpcDataByPath = CacheBuilder.newBuilder().build( - new CacheLoader>() { + throw new UnsupportedOperationException("Unsupported child type " + childSchema.getClass()); + } + }); + + private final LoadingCache> rpcDataByPath = + CacheBuilder.newBuilder().build(new CacheLoader<>() { @Override public RpcInputCodec load(final Absolute key) { final ContainerLike schema = SchemaContextUtil.getRpcDataSchema(getSchema(), key.asSchemaPath()); @SuppressWarnings("unchecked") final Class cls = (Class) - factory().getRuntimeContext().getClassForSchema(schema); + factory().getRuntimeContext().getClassForSchema(schema); return getRpc(cls); } }); - private final LoadingCache> notificationsByPath = CacheBuilder.newBuilder() - .build(new CacheLoader>() { - @Override - public NotificationCodecContext load(final Absolute key) { - final NotificationDefinition schema = SchemaContextUtil.getNotificationSchema(getSchema(), - // FIXME: do not convert here! - key.asSchemaPath()); - @SuppressWarnings("unchecked") - final Class clz = (Class) - factory().getRuntimeContext().getClassForSchema(schema); - return getNotification(clz); - } - }); + private final LoadingCache> notificationsByPath = + CacheBuilder.newBuilder().build(new CacheLoader<>() { + @Override + public NotificationCodecContext load(final Absolute key) { + final NotificationDefinition schema = SchemaContextUtil.getNotificationSchema(getSchema(), + // FIXME: do not convert here! + key.asSchemaPath()); + @SuppressWarnings("unchecked") + final Class clz = (Class) + factory().getRuntimeContext().getClassForSchema(schema); + return getNotification(clz); + } + }); private SchemaRootCodecContext(final DataContainerCodecPrototype dataPrototype) { super(dataPrototype); -- 2.36.6