*/
package org.opendaylight.netconf.sal.connect.netconf.sal;
-import com.google.common.base.Preconditions;
+import static com.google.common.base.Preconditions.checkNotNull;
+import static com.google.common.base.Preconditions.checkState;
+import static java.util.Objects.requireNonNull;
+
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import org.opendaylight.mdsal.binding.api.DataBroker;
import org.opendaylight.mdsal.binding.api.Transaction;
import org.opendaylight.mdsal.binding.api.TransactionChain;
import org.slf4j.LoggerFactory;
public class NetconfDeviceSalProvider implements AutoCloseable {
-
private static final Logger LOG = LoggerFactory.getLogger(NetconfDeviceSalProvider.class);
private final RemoteDeviceId id;
mountInstance = new MountInstance(mountService, id);
this.dataBroker = dataBroker;
if (dataBroker != null) {
- txChain = Preconditions.checkNotNull(dataBroker).createTransactionChain(transactionChainListener);
+ txChain = requireNonNull(dataBroker).createTransactionChain(transactionChainListener);
topologyDatastoreAdapter = new NetconfDeviceTopologyAdapter(id, txChain);
}
}
public MountInstance getMountInstance() {
- Preconditions.checkState(mountInstance != null,
- "%s: Mount instance was not initialized by sal. Cannot get mount instance", id);
+ checkState(mountInstance != null, "%s: Mount instance was not initialized by sal. Cannot get mount instance",
+ id);
return mountInstance;
}
public NetconfDeviceTopologyAdapter getTopologyDatastoreAdapter() {
- Preconditions.checkState(topologyDatastoreAdapter != null,
- "%s: Sal provider %s was not initialized by sal. Cannot get topology datastore adapter", id);
- return topologyDatastoreAdapter;
+ final NetconfDeviceTopologyAdapter local = topologyDatastoreAdapter;
+ checkState(local != null,
+ "%s: Sal provider %s was not initialized by sal. Cannot get topology datastore adapter", id, this);
+ return local;
}
+ @SuppressFBWarnings(value = "UPM_UNCALLED_PRIVATE_METHOD",
+ justification = "https://github.com/spotbugs/spotbugs/issues/811")
private void resetTransactionChainForAdapaters() {
- txChain = Preconditions.checkNotNull(dataBroker).createTransactionChain(transactionChainListener);
-
+ txChain = requireNonNull(dataBroker).createTransactionChain(transactionChainListener);
topologyDatastoreAdapter.setTxChain(txChain);
-
LOG.trace("{}: Resetting TransactionChain {}", id, txChain);
-
}
@Override
private ObjectRegistration<DOMMountPoint> topologyRegistration;
MountInstance(final DOMMountPointService mountService, final RemoteDeviceId id) {
- this.mountService = Preconditions.checkNotNull(mountService);
- this.id = Preconditions.checkNotNull(id);
+ this.mountService = requireNonNull(mountService);
+ this.id = requireNonNull(id);
}
public void onTopologyDeviceConnected(final SchemaContext initialCtx,
public synchronized void onTopologyDeviceConnected(final SchemaContext initialCtx,
final DOMDataBroker broker, final DOMRpcService rpc,
final NetconfDeviceNotificationService newNotificationService, final DOMActionService deviceAction) {
- Preconditions.checkNotNull(mountService, "Closed");
- Preconditions.checkState(topologyRegistration == null, "Already initialized");
+ requireNonNull(mountService, "Closed");
+ checkState(topologyRegistration == null, "Already initialized");
final DOMMountPointService.DOMMountPointBuilder mountBuilder =
mountService.createMountPoint(id.getTopologyPath());
}
public synchronized void publish(final DOMNotification domNotification) {
- Preconditions.checkNotNull(notificationService, "Device not set up yet, cannot handle notification {}",
- domNotification);
- notificationService.publishNotification(domNotification);
+ checkNotNull(notificationService, "Device not set up yet, cannot handle notification %s", domNotification)
+ .publishNotification(domNotification);
}
}