X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-binding-broker%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fmd%2Fsal%2Fbinding%2Fimpl%2FContextReferenceExtractor.java;h=214ae3e6d8eb800db870f51626b4e00013f375ae;hb=2a6aa1775604906755883f810ee9ea6d5f286135;hp=4653ca399eeab995bd5890cb1a4dd7a41c9075d0;hpb=c2fbe8c5fa6d00473aa49b50b557ead738dc6a44;p=controller.git diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/ContextReferenceExtractor.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/ContextReferenceExtractor.java index 4653ca399e..214ae3e6d8 100644 --- a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/ContextReferenceExtractor.java +++ b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/md/sal/binding/impl/ContextReferenceExtractor.java @@ -1,27 +1,27 @@ /* * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved. * - * This program and the accompanying materials are made available under the terms of the Eclipse - * Public License v1.0 which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html */ package org.opendaylight.controller.md.sal.binding.impl; import com.google.common.cache.CacheBuilder; import com.google.common.cache.CacheLoader; import com.google.common.cache.LoadingCache; +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import java.lang.reflect.Method; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; +import org.eclipse.jdt.annotation.NonNull; +import org.eclipse.jdt.annotation.Nullable; import org.opendaylight.yangtools.yang.binding.DataObject; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.opendaylight.yangtools.yang.binding.annotations.RoutingContext; import org.slf4j.Logger; import org.slf4j.LoggerFactory; - +@Deprecated(forRemoval = true) abstract class ContextReferenceExtractor { - private static final Logger LOG = LoggerFactory.getLogger(ContextReferenceExtractor.class); private static final ContextReferenceExtractor NULL_EXTRACTOR = new ContextReferenceExtractor() { @@ -31,12 +31,11 @@ abstract class ContextReferenceExtractor { } }; - private static final LoadingCache, ContextReferenceExtractor> EXTRACTORS = CacheBuilder.newBuilder() .weakKeys().build(new CacheLoader, ContextReferenceExtractor>() { @Override - public ContextReferenceExtractor load(final Class key) throws Exception { + public ContextReferenceExtractor load(final Class key) { return create(key); } }); @@ -52,15 +51,16 @@ abstract class ContextReferenceExtractor { * Extract context-reference (Instance Identifier) from * Binding DataObject. * - * @param obj DataObject from which context reference - * should be extracted. + * @param obj DataObject from which context reference should be extracted. * - * @return Instance Identifier representing context reference - * or null, if data object does not contain context reference. + * @return Instance Identifier representing context reference or null, if data object does not contain + * context reference. */ abstract @Nullable InstanceIdentifier extract(DataObject obj); - private static @Nonnull ContextReferenceExtractor create(final Class key) { + @SuppressFBWarnings(value = "UPM_UNCALLED_PRIVATE_METHOD", + justification = "https://github.com/spotbugs/spotbugs/issues/811") + private static @NonNull ContextReferenceExtractor create(final Class key) { final Method contextGetter = getContextGetter(key); if (contextGetter == null) { return NULL_EXTRACTOR; @@ -70,14 +70,15 @@ abstract class ContextReferenceExtractor { if (InstanceIdentifier.class.isAssignableFrom(returnType)) { return DirectGetterRouteContextExtractor.create(contextGetter); } - final Method getValueMethod = findGetValueMethod(returnType,InstanceIdentifier.class); + final Method getValueMethod = findGetValueMethod(returnType, InstanceIdentifier.class); if (getValueMethod != null) { return GetValueRouteContextExtractor.create(contextGetter, getValueMethod); } else { - LOG.warn("Class {} can not be used to determine context, falling back to NULL_EXTRACTOR.",returnType); + LOG.warn("Class {} can not be used to determine context, falling back to NULL_EXTRACTOR.", returnType); } } catch (final IllegalAccessException e) { - LOG.warn("Class {} does not conform to Binding Specification v1. Falling back to NULL_EXTRACTOR", e); + LOG.warn("Class {} does not conform to Binding Specification v1. Falling back to NULL_EXTRACTOR", + returnType, e); } return NULL_EXTRACTOR; } @@ -85,7 +86,7 @@ abstract class ContextReferenceExtractor { private static @Nullable Method findGetValueMethod(final Class type, final Class returnType) { try { final Method method = type.getMethod(GET_VALUE_NAME); - if(returnType.equals(method.getReturnType())) { + if (returnType.equals(method.getReturnType())) { return method; } } catch (final NoSuchMethodException e) { @@ -102,7 +103,4 @@ abstract class ContextReferenceExtractor { } return null; } - - - }