Replace Guava constructs with their Java 8 equivalents.
Change-Id: Idfba9bbba34620fa9d40d611f76632b28dbf55eb
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
*/
package org.opendaylight.netconf.ssh;
-import com.google.common.base.Preconditions;
+import static java.util.Objects.requireNonNull;
+
import io.netty.bootstrap.Bootstrap;
import io.netty.channel.Channel;
import io.netty.channel.ChannelFuture;
} else {
LOG.warn("Unable to establish internal connection to netconf server for client: {}",
getClientAddress());
- Preconditions.checkNotNull(callback, "Exit callback must be set");
- callback.onExit(1, "Unable to establish internal connection to netconf server for client: "
- + getClientAddress());
+ requireNonNull(callback, "Exit callback must be set").onExit(1,
+ "Unable to establish internal connection to netconf server for client: " + getClientAddress());
}
});
}
* 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.netconf.ssh;
-import com.google.common.base.Preconditions;
+import static com.google.common.base.Preconditions.checkArgument;
+import static java.util.Objects.requireNonNull;
+
import io.netty.channel.local.LocalAddress;
import java.net.InetSocketAddress;
import java.util.Optional;
SshProxyServerConfiguration(final InetSocketAddress bindingAddress, final LocalAddress localAddress,
final AuthProvider authenticator, final PublickeyAuthenticator publickeyAuthenticator,
final KeyPairProvider keyPairProvider, final int idleTimeout) {
- this.bindingAddress = Preconditions.checkNotNull(bindingAddress);
- this.localAddress = Preconditions.checkNotNull(localAddress);
- this.authenticator = Preconditions.checkNotNull(authenticator);
- this.keyPairProvider = Preconditions.checkNotNull(keyPairProvider);
+ this.bindingAddress = requireNonNull(bindingAddress);
+ this.localAddress = requireNonNull(localAddress);
+ this.authenticator = requireNonNull(authenticator);
+ this.keyPairProvider = requireNonNull(keyPairProvider);
// Idle timeout cannot be disabled in the sshd by using =< 0 value
- Preconditions.checkArgument(idleTimeout > 0, "Idle timeout has to be > 0");
+ checkArgument(idleTimeout > 0, "Idle timeout has to be > 0");
this.idleTimeout = idleTimeout;
this.publickeyAuthenticator = Optional.ofNullable(publickeyAuthenticator);
}
*/
package org.opendaylight.netconf.messagebus.eventsources.netconf;
-import com.google.common.base.Preconditions;
+import static java.util.Objects.requireNonNull;
+
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
final DOMNotificationListener domNotificationListener) {
super(NotificationSourceType.ConnectionStatusChange, sourceName,
EVENT_SOURCE_STATUS_PATH.getLastComponent().getNamespace().toString());
- this.domNotificationListener = Preconditions.checkNotNull(domNotificationListener);
+ this.domNotificationListener = requireNonNull(domNotificationListener);
LOG.info("Connection notification source has been initialized.");
setActive(true);
setReplaySupported(false);
package org.opendaylight.netconf.messagebus.eventsources.netconf;
import static com.google.common.util.concurrent.Futures.immediateFuture;
+import static java.util.Objects.requireNonNull;
-import com.google.common.base.Preconditions;
import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.Maps;
import com.google.common.collect.Multimap;
final NetconfEventSourceMount mount,
final DOMNotificationPublishService publishService) {
this.mount = mount;
- this.urnPrefixToStreamMap = Preconditions.checkNotNull(streamMap);
- this.domPublish = Preconditions.checkNotNull(publishService);
+ this.urnPrefixToStreamMap = requireNonNull(streamMap);
+ this.domPublish = requireNonNull(publishService);
this.initializeNotificationTopicRegistrationList();
LOG.info("NetconfEventSource [{}] created.", mount.getNodeId());
private synchronized ListenableFuture<RpcResult<JoinTopicOutput>> registerTopic(
final TopicId topicId,
final List<SchemaPath> notificationsToSubscribe) {
- Preconditions.checkNotNull(notificationsToSubscribe);
+ requireNonNull(notificationsToSubscribe);
LOG.debug("Join topic {} - register", topicId);
JoinTopicStatus joinTopicStatus = JoinTopicStatus.Down;
*/
package org.opendaylight.netconf.messagebus.eventsources.netconf;
-import com.google.common.base.Preconditions;
+import static com.google.common.base.Verify.verifyNotNull;
+import static java.util.Objects.requireNonNull;
+
import java.util.Collection;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
final DOMNotificationPublishService domPublish,
final DOMMountPointService domMount,
final EventSourceRegistry eventSourceRegistry) {
- Preconditions.checkNotNull(dataBroker);
- Preconditions.checkNotNull(domPublish);
- Preconditions.checkNotNull(domMount);
- Preconditions.checkNotNull(eventSourceRegistry);
- this.dataBroker = dataBroker;
- this.domMounts = domMount;
- this.publishService = domPublish;
- this.eventSourceRegistry = eventSourceRegistry;
+ this.dataBroker = requireNonNull(dataBroker);
+ this.domMounts = requireNonNull(domMount);
+ this.publishService = requireNonNull(domPublish);
+ this.eventSourceRegistry = requireNonNull(eventSourceRegistry);
}
/**
* Invoked by blueprint.
*/
public void initialize() {
- Preconditions.checkNotNull(dataBroker);
- listenerRegistration = dataBroker.registerDataTreeChangeListener(DataTreeIdentifier.create(
+ listenerRegistration = verifyNotNull(dataBroker).registerDataTreeChangeListener(DataTreeIdentifier.create(
LogicalDatastoreType.OPERATIONAL, NETCONF_DEVICE_PATH), this);
LOG.info("NetconfEventSourceManager initialized.");
}
}
private void nodeCreated(final InstanceIdentifier<?> key, final Node node) {
- Preconditions.checkNotNull(key);
if (!validateNode(node)) {
- LOG.warn("NodeCreated event : Node [{}] is null or not valid.", key.toString());
+ LOG.warn("NodeCreated event : Node [{}] is null or not valid.", key);
return;
}
- LOG.info("Netconf event source [{}] is creating...", key.toString());
- NetconfEventSourceRegistration nesr = NetconfEventSourceRegistration.create(key, node, this);
+ LOG.info("Netconf event source [{}] is creating...", key);
+ NetconfEventSourceRegistration nesr = NetconfEventSourceRegistration.create(requireNonNull(key), node, this);
if (nesr != null) {
NetconfEventSourceRegistration nesrOld = registrationMap.put(key, nesr);
if (nesrOld != null) {
}
private void nodeRemoved(final InstanceIdentifier<?> key) {
- Preconditions.checkNotNull(key);
- LOG.info("Netconf event source [{}] is removing...", key.toString());
- NetconfEventSourceRegistration nesr = registrationMap.remove(key);
+ LOG.info("Netconf event source [{}] is removing...", key);
+ NetconfEventSourceRegistration nesr = registrationMap.remove(requireNonNull(key));
if (nesr != null) {
nesr.close();
}
*/
package org.opendaylight.netconf.messagebus.eventsources.netconf;
-import com.google.common.base.Preconditions;
+import static com.google.common.base.Preconditions.checkState;
+import static java.util.Objects.requireNonNull;
+
import java.util.List;
import java.util.Optional;
import org.opendaylight.controller.messagebus.spi.EventSourceRegistration;
public static NetconfEventSourceRegistration create(final InstanceIdentifier<?> instanceIdent, final Node node,
final NetconfEventSourceManager netconfEventSourceManager) {
- Preconditions.checkNotNull(instanceIdent);
- Preconditions.checkNotNull(node);
- Preconditions.checkNotNull(netconfEventSourceManager);
+ requireNonNull(instanceIdent);
+ requireNonNull(node);
+ requireNonNull(netconfEventSourceManager);
if (!isEventSource(node)) {
return null;
}
}
private void changeStatus(final ConnectionStatus newStatus) {
- Preconditions.checkNotNull(newStatus);
- Preconditions.checkState(this.currentNetconfConnStatus != null);
+ requireNonNull(newStatus);
+ checkState(this.currentNetconfConnStatus != null);
if (!checkConnectionStatusType(newStatus)) {
throw new IllegalStateException("Unknown new Netconf Connection Status");
}
* 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.yanglib.impl;
-import com.google.common.base.Preconditions;
+import static java.util.Objects.requireNonNull;
+
import com.google.common.io.ByteStreams;
import com.google.common.util.concurrent.ListenableFuture;
import java.io.IOException;
private final SchemaRepository schemaRepository;
public YangLibServiceImpl(final SchemaRepository schemaRepository) {
- this.schemaRepository = schemaRepository;
+ this.schemaRepository = requireNonNull(schemaRepository);
}
@Override
public String getSchema(final String name, final String revision) {
- Preconditions.checkNotNull(schemaRepository, "Schema repository is not initialized");
LOG.debug("Attempting load for schema source {}:{}", name, revision);
final SourceIdentifier sourceId = RevisionSourceIdentifier.create(name,
revision.isEmpty() ? null : Revision.of(revision));
* 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.restconf.common.patch;
-import com.google.common.base.Preconditions;
+import static java.util.Objects.requireNonNull;
+
import java.util.List;
import org.opendaylight.restconf.common.context.InstanceIdentifierContext;
import org.opendaylight.yangtools.yang.model.api.SchemaNode;
public class PatchContext {
-
private final InstanceIdentifierContext<? extends SchemaNode> context;
private final List<PatchEntity> data;
private final String patchId;
public PatchContext(final InstanceIdentifierContext<? extends SchemaNode> context,
final List<PatchEntity> data, final String patchId) {
- this.context = Preconditions.checkNotNull(context);
- this.data = Preconditions.checkNotNull(data);
- this.patchId = Preconditions.checkNotNull(patchId);
+ this.context = requireNonNull(context);
+ this.data = requireNonNull(data);
+ this.patchId = requireNonNull(patchId);
}
public InstanceIdentifierContext<? extends SchemaNode> getInstanceIdentifierContext() {
*/
package org.opendaylight.netconf.sal.restconf.impl;
-import com.google.common.base.Preconditions;
+import static java.util.Objects.requireNonNull;
+
import com.google.common.collect.ForwardingObject;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
private final Module delegate;
FakeImportedModule(final Module delegate) {
- this.delegate = Preconditions.checkNotNull(delegate);
+ this.delegate = requireNonNull(delegate);
}
@Override
*/
package org.opendaylight.netconf.sal.streams.listeners;
+import static java.util.Objects.requireNonNull;
+
import com.google.common.annotations.VisibleForTesting;
-import com.google.common.base.Preconditions;
import java.io.StringReader;
import java.time.Instant;
import java.util.Optional;
@SuppressWarnings("checkstyle:hiddenField")
public void setQueryParams(final Instant start, final Optional<Instant> stop, final Optional<String> filter,
final boolean leafNodesOnly) {
- this.start = Preconditions.checkNotNull(start);
+ this.start = requireNonNull(start);
this.stop = stop.orElse(null);
this.filter = filter.orElse(null);
this.leafNodesOnly = leafNodesOnly;
*/
package org.opendaylight.netconf.sal.streams.listeners;
+import static com.google.common.base.Preconditions.checkArgument;
+import static java.util.Objects.requireNonNull;
+
import com.google.common.annotations.VisibleForTesting;
-import com.google.common.base.Preconditions;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import java.io.IOException;
NotificationListenerAdapter(final SchemaPath path, final String streamName, final String outputType,
final ControllerContext controllerContext) {
register(this);
- this.outputType = Preconditions.checkNotNull(outputType);
- this.path = Preconditions.checkNotNull(path);
- Preconditions.checkArgument(streamName != null && !streamName.isEmpty());
+ this.outputType = requireNonNull(outputType);
+ this.path = requireNonNull(path);
+ checkArgument(streamName != null && !streamName.isEmpty());
this.streamName = streamName;
this.controllerContext = controllerContext;
}