*/
package org.opendaylight.netconf.mdsal.connector;
-import com.google.common.base.Optional;
-import com.google.common.base.Preconditions;
+import static com.google.common.base.Preconditions.checkState;
+
import com.google.common.util.concurrent.FluentFuture;
import java.util.ArrayList;
import java.util.List;
+import java.util.Optional;
import java.util.concurrent.ExecutionException;
import org.opendaylight.mdsal.common.api.CommitInfo;
import org.opendaylight.mdsal.dom.api.DOMDataBroker;
}
public synchronized Optional<DOMDataTreeReadWriteTransaction> getCandidateTransaction() {
- if (candidateTransaction == null) {
- return Optional.absent();
- }
-
- return Optional.of(candidateTransaction);
+ return Optional.ofNullable(candidateTransaction);
}
public synchronized DOMDataTreeReadWriteTransaction getOrCreateTransaction() {
public synchronized void abortRunningTransaction(final DOMDataTreeReadWriteTransaction tx) {
LOG.debug("Aborting current running Transaction");
- Preconditions.checkState(runningTransaction != null,
- NO_TRANSACTION_FOUND_FOR_SESSION + netconfSessionIdForReporting);
+ checkState(runningTransaction != null, NO_TRANSACTION_FOUND_FOR_SESSION + netconfSessionIdForReporting);
tx.cancel();
allOpenReadWriteTransactions.remove(tx);
}
* 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.api.capability;
-import com.google.common.base.Optional;
import java.util.Collection;
import java.util.Collections;
+import java.util.Optional;
/**
* Capability representing a basic, one-line, string based capability.
*/
public class BasicCapability implements Capability {
-
private final String capability;
public BasicCapability(final String capability) {
@Override
public Optional<String> getModuleNamespace() {
- return Optional.absent();
+ return Optional.empty();
}
@Override
public Optional<String> getModuleName() {
- return Optional.absent();
+ return Optional.empty();
}
@Override
public Optional<String> getRevision() {
- return Optional.absent();
+ return Optional.empty();
}
@Override
public Optional<String> getCapabilitySchema() {
- return Optional.absent();
+ return Optional.empty();
}
@Override
* 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.api.capability;
-import com.google.common.base.Optional;
import java.util.Collection;
+import java.util.Optional;
/**
* Contains capability URI announced by server hello message and optionally its
* 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.api.capability;
-import com.google.common.base.Optional;
+import java.util.Optional;
import org.opendaylight.yangtools.yang.common.Revision;
import org.opendaylight.yangtools.yang.model.api.Module;
@Override
public Optional<String> getRevision() {
- return Optional.fromNullable(revision);
+ return Optional.ofNullable(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.netconf.client;
-import com.google.common.base.Optional;
-import com.google.common.base.Preconditions;
+import static com.google.common.base.Preconditions.checkState;
+
import com.google.common.collect.Sets;
import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.util.HashedWheelTimer;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.UnknownHostException;
+import java.util.Optional;
import java.util.Set;
import java.util.concurrent.CancellationException;
import java.util.concurrent.ExecutionException;
private final NetconfClientSessionListener sessionListener;
private final long sessionId;
- public TestingNetconfClient(String clientLabel,
- NetconfClientDispatcher netconfClientDispatcher,
+ public TestingNetconfClient(final String clientLabel,
+ final NetconfClientDispatcher netconfClientDispatcher,
final NetconfClientConfiguration config) throws InterruptedException {
this.label = clientLabel;
sessionListener = config.getSessionListener();
this.sessionId = clientSession.getSessionId();
}
- private static NetconfClientSession get(Future<NetconfClientSession> clientFuture) throws InterruptedException {
+ private static NetconfClientSession get(final Future<NetconfClientSession> clientFuture)
+ throws InterruptedException {
try {
return clientFuture.get();
} catch (CancellationException e) {
}
}
- public Future<NetconfMessage> sendRequest(NetconfMessage message) {
+ public Future<NetconfMessage> sendRequest(final NetconfMessage message) {
return ((SimpleNetconfClientSessionListener) sessionListener).sendRequest(message);
}
- public NetconfMessage sendMessage(NetconfMessage message, int attemptMsDelay) throws ExecutionException,
+ public NetconfMessage sendMessage(final NetconfMessage message, final int attemptMsDelay) throws ExecutionException,
InterruptedException, TimeoutException {
return sendRequest(message).get(attemptMsDelay, TimeUnit.MILLISECONDS);
}
- public NetconfMessage sendMessage(NetconfMessage message) throws ExecutionException,
+ public NetconfMessage sendMessage(final NetconfMessage message) throws ExecutionException,
InterruptedException, TimeoutException {
return sendMessage(message, DEFAULT_CONNECT_TIMEOUT);
}
}
public Set<String> getCapabilities() {
- Preconditions.checkState(clientSession != null, "Client was not initialized successfully");
+ checkState(clientSession != null, "Client was not initialized successfully");
return Sets.newHashSet(clientSession.getServerCapabilities());
}
- public static void main(String[] args) throws Exception {
+ public static void main(final String[] args) throws Exception {
HashedWheelTimer hashedWheelTimer = new HashedWheelTimer();
NioEventLoopGroup nettyGroup = new NioEventLoopGroup();
NetconfClientDispatcherImpl netconfClientDispatcher = new NetconfClientDispatcherImpl(nettyGroup, nettyGroup,
System.console().writer().println(client.getCapabilities());
}
- private static NetconfClientConfiguration getClientConfig(String host, int port, boolean ssh, Optional<? extends
- AuthenticationHandler> maybeAuthHandler) throws UnknownHostException {
+ private static NetconfClientConfiguration getClientConfig(final String host, final int port, final boolean ssh,
+ final Optional<? extends AuthenticationHandler> maybeAuthHandler) throws UnknownHostException {
InetSocketAddress netconfAddress = new InetSocketAddress(InetAddress.getByName(host), port);
final NetconfClientConfigurationBuilder b = NetconfClientConfigurationBuilder.create();
b.withAddress(netconfAddress);
* 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.mapping.api;
+import static com.google.common.base.Preconditions.checkArgument;
+import static com.google.common.base.Preconditions.checkState;
+
import com.google.common.base.MoreObjects;
-import com.google.common.base.Optional;
-import com.google.common.base.Preconditions;
import java.util.Objects;
+import java.util.Optional;
public final class HandlingPriority implements Comparable<HandlingPriority> {
private Integer priority;
- public static HandlingPriority getHandlingPriority(int priority) {
+ public static HandlingPriority getHandlingPriority(final int priority) {
return new HandlingPriority(priority);
}
- private HandlingPriority(int priority) {
+ private HandlingPriority(final int priority) {
this.priority = priority;
}
* @return priority number or Optional.absent otherwise
*/
public Optional<Integer> getPriority() {
- return Optional.fromNullable(priority);
+ return Optional.ofNullable(priority);
}
- public HandlingPriority increasePriority(int priorityIncrease) {
- Preconditions.checkState(priority != null, "Unable to increase priority for %s", this);
- Preconditions.checkArgument(priorityIncrease > 0, "Negative increase");
- Preconditions.checkArgument(Long.valueOf(priority) + priorityIncrease < Integer.MAX_VALUE,
+ public HandlingPriority increasePriority(final int priorityIncrease) {
+ checkState(priority != null, "Unable to increase priority for %s", this);
+ checkArgument(priorityIncrease > 0, "Negative increase");
+ checkArgument(Long.valueOf(priority) + priorityIncrease < Integer.MAX_VALUE,
"Resulting priority cannot be higher than %s", Integer.MAX_VALUE);
return getHandlingPriority(priority + priorityIncrease);
}
@Override
@SuppressWarnings("checkstyle:parameterName")
- public int compareTo(HandlingPriority o) {
+ public int compareTo(final HandlingPriority o) {
if (this == o) {
return 0;
}
}
@Override
- public boolean equals(Object obj) {
+ public boolean equals(final Object obj) {
if (this == obj) {
return true;
}
import static com.google.common.base.Preconditions.checkState;
import static java.util.Objects.requireNonNull;
-import com.google.common.base.Optional;
import io.netty.channel.Channel;
import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelHandler;
import io.netty.util.TimerTask;
import io.netty.util.concurrent.GenericFutureListener;
import io.netty.util.concurrent.Promise;
+import java.util.Optional;
import java.util.concurrent.TimeUnit;
import org.opendaylight.netconf.api.NetconfDocumentedException;
import org.opendaylight.netconf.api.NetconfMessage;
}
private static Optional<SslHandler> getSslHandler(final Channel channel) {
- final SslHandler sslHandler = channel.pipeline().get(SslHandler.class);
- return sslHandler == null ? Optional.absent() : Optional.of(sslHandler);
+ return Optional.ofNullable(channel.pipeline().get(SslHandler.class));
}
public P getSessionPreferences() {
package org.opendaylight.netconf.nettyutil.handler;
import com.google.common.annotations.VisibleForTesting;
-import com.google.common.base.Optional;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.ByteBufOutputStream;
import io.netty.channel.ChannelHandlerContext;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.nio.charset.StandardCharsets;
+import java.util.Optional;
import javax.xml.transform.TransformerException;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
+import org.eclipse.jdt.annotation.Nullable;
import org.opendaylight.netconf.api.NetconfMessage;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class NetconfMessageToXMLEncoder extends MessageToByteEncoder<NetconfMessage> {
private static final Logger LOG = LoggerFactory.getLogger(NetconfMessageToXMLEncoder.class);
- private final Optional<String> clientId;
+ private final @Nullable String clientId;
public NetconfMessageToXMLEncoder() {
- this(Optional.absent());
+ this(Optional.empty());
}
public NetconfMessageToXMLEncoder(final Optional<String> clientId) {
- this.clientId = clientId;
+ this.clientId = clientId.orElse(null);
}
@Override
throws IOException, TransformerException {
LOG.trace("Sent to encode : {}", msg);
- if (clientId.isPresent()) {
- Comment comment = msg.getDocument().createComment("clientId:" + clientId.get());
+ if (clientId != null) {
+ Comment comment = msg.getDocument().createComment("clientId:" + clientId);
msg.getDocument().appendChild(comment);
}
*/
package org.opendaylight.netconf.sal.connect.netconf.listener;
-import com.google.common.base.Optional;
import com.google.common.base.Strings;
import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.SettableFuture;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
+import java.util.Optional;
import java.util.Queue;
import java.util.concurrent.Semaphore;
import java.util.concurrent.atomic.AtomicIntegerFieldUpdater;
final RemoteDeviceId id,
final RemoteDevice<NetconfSessionPreferences, NetconfMessage, NetconfDeviceCommunicator> remoteDevice,
final int rpcMessageLimit) {
- this(id, remoteDevice, Optional.absent(), rpcMessageLimit);
+ this(id, remoteDevice, Optional.empty(), rpcMessageLimit);
}
private NetconfDeviceCommunicator(
.setIdentifier(capability.getModuleName().get())
.setNamespace(new Uri(capability.getModuleNamespace().get()))
.setFormat(Yang.class)
- .setVersion(capability.getRevision().or(""))
+ .setVersion(capability.getRevision().orElse(""))
.setLocation(Collections.singletonList(new Location(Enumeration.NETCONF)))
.withKey(new SchemaKey(Yang.class, capability.getModuleName().get(),
- capability.getRevision().or("")))
+ capability.getRevision().orElse("")))
.build();
private final Capabilities capabilities;
* 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.test.tool;
-import com.google.common.base.Optional;
+import java.util.Optional;
import org.opendaylight.netconf.api.capability.BasicCapability;
import org.opendaylight.netconf.api.capability.YangModuleCapability;
*/
@Override
public Optional<String> getCapabilitySchema() {
- return Optional.absent();
+ return Optional.empty();
}
}
package org.opendaylight.netconf.test.tool;
import com.google.common.base.MoreObjects.ToStringHelper;
-import com.google.common.base.Optional;
import com.google.common.collect.Collections2;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import java.net.UnknownHostException;
import java.nio.channels.AsynchronousChannelGroup;
import java.util.List;
+import java.util.Optional;
import java.util.Set;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
} else if (configuration.isXmlConfigurationProvided()) {
LOG.info("using SimulatedOperationProvider.");
operationProvider = new SimulatedOperationProvider(idProvider, transformedCapabilities,
- Optional.fromNullable(configuration.getNotificationFile()),
- Optional.fromNullable(configuration.getInitialConfigXMLFile()));
+ Optional.ofNullable(configuration.getNotificationFile()),
+ Optional.ofNullable(configuration.getInitialConfigXMLFile()));
} else {
LOG.info("using OperationsProvider.");
operationProvider = new OperationsProvider(idProvider, transformedCapabilities,
* 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.test.tool;
-import com.google.common.base.Optional;
import com.google.common.collect.Sets;
import java.io.File;
import java.util.Collections;
+import java.util.Optional;
import java.util.Set;
import org.opendaylight.netconf.api.capability.Capability;
import org.opendaylight.netconf.api.monitoring.CapabilityListener;
* 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.test.tool.operations;
-import com.google.common.base.Optional;
import com.google.common.collect.Sets;
+import java.util.Optional;
import java.util.Set;
import org.opendaylight.netconf.api.capability.Capability;
import org.opendaylight.netconf.impl.SessionIdProvider;
final SimulatedGet sGet = new SimulatedGet(String.valueOf(currentSessionId), storage);
final SimulatedEditConfig sEditConfig = new SimulatedEditConfig(String.valueOf(currentSessionId), storage);
final SimulatedGetConfig sGetConfig = new SimulatedGetConfig(
- String.valueOf(currentSessionId), storage, Optional.absent());
+ String.valueOf(currentSessionId), storage, Optional.empty());
final SimulatedCommit sCommit = new SimulatedCommit(String.valueOf(currentSessionId));
final SimulatedLock sLock = new SimulatedLock(String.valueOf(currentSessionId));
final SimulatedUnLock sUnlock = new SimulatedUnLock(String.valueOf(currentSessionId));
final SimulatedCreateSubscription sCreateSubs = new SimulatedCreateSubscription(
- String.valueOf(currentSessionId), Optional.absent());
+ String.valueOf(currentSessionId), Optional.empty());
final SimulatedDiscardChanges sDiscardChanges = new SimulatedDiscardChanges(
String.valueOf(currentSessionId));
return Sets.newHashSet(
*/
package org.opendaylight.netconf.test.tool.rpc;
-import com.google.common.base.Optional;
import com.google.common.base.Preconditions;
import com.google.common.collect.Maps;
import java.io.File;
import java.util.Date;
import java.util.List;
import java.util.Map;
+import java.util.Optional;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
notifs = Optional.of(loadNotifications(notificationsFile.get()));
scheduledExecutorService = Executors.newScheduledThreadPool(1);
} else {
- notifs = Optional.absent();
+ notifs = Optional.empty();
}
if (notifs.isPresent()) {
*/
package org.opendaylight.netconf.test.tool.rpc;
-import com.google.common.base.Optional;
import java.io.File;
import java.io.IOException;
import java.util.List;
+import java.util.Optional;
import org.opendaylight.netconf.api.xml.XmlElement;
import org.opendaylight.netconf.api.xml.XmlNetconfConstants;
import org.opendaylight.netconf.api.xml.XmlUtil;
public class SimulatedGetConfig extends AbstractLastNetconfOperation {
private final DataList storage;
- private static final Logger LOG = LoggerFactory
- .getLogger(SimulatedGetConfig.class);
+ private static final Logger LOG = LoggerFactory.getLogger(SimulatedGetConfig.class);
public SimulatedGetConfig(final String netconfSessionIdForReporting, final DataList storage,
final Optional<File> initialConfigXMLFile) {