return "Invalid IP:" + deviceIp + " or Port:" + devicePort + "Please enter a valid entry to proceed.";
}
- final boolean isTcpOnly = (connectionType.equals("true")) ? true : false;
- final boolean isSchemaless = (schemaless.equals("true")) ? true : false;
+ final boolean isTcpOnly = connectionType.equals("true");
+ final boolean isSchemaless = schemaless.equals("true");
final Credentials credentials = new LoginPasswordBuilder().setPassword(password).setUsername(username).build();
final NetconfNode netconfNode = new NetconfNodeBuilder()
: updated.get(NetconfConsoleConstants.NETCONF_IP);
final String devicePort = Strings.isNullOrEmpty(updated.get(NetconfConsoleConstants.NETCONF_PORT))
? netconfNode.getPort().getValue().toString() : updated.get(NetconfConsoleConstants.NETCONF_PORT);
- final Boolean tcpOnly = (updated.get(NetconfConsoleConstants.TCP_ONLY).equals("true")) ? true : false;
+ final Boolean tcpOnly = updated.get(NetconfConsoleConstants.TCP_ONLY).equals("true");
final Boolean isSchemaless =
- (updated.get(NetconfConsoleConstants.SCHEMALESS).equals("true")) ? true : false;
+ updated.get(NetconfConsoleConstants.SCHEMALESS).equals("true");
final String newUsername = Strings.isNullOrEmpty(updated.get(NetconfConsoleConstants.USERNAME))
? updated.get(NetconfConsoleConstants.USERNAME) : username;
final String newPassword = Strings.isNullOrEmpty(updated.get(NetconfConsoleConstants.PASSWORD))
* @return :<code>true</code> if not empty, else, <code>false</code>
*/
private static boolean isNetconfNodesPresent(final Topology topology) {
- if (topology == null || topology.getNode() == null || topology.getNode().isEmpty()) {
- return false;
- }
- return true;
+ return topology != null && topology.getNode() != null && !topology.getNode().isEmpty();
}
/**
import com.google.common.base.MoreObjects;
import com.google.common.base.Optional;
import com.google.common.base.Preconditions;
+import java.util.Objects;
public final class HandlingPriority implements Comparable<HandlingPriority> {
HandlingPriority that = (HandlingPriority) obj;
- if (priority != null ? !priority.equals(that.priority) : that.priority != null) {
- return false;
- }
-
- return true;
+ return Objects.equals(priority, that.priority);
}
@Override
// Do not fail negotiation if promise is done or canceled
// It would result in setting result of the promise second time and that throws exception
- if (isPromiseFinished() == false) {
+ if (!isPromiseFinished()) {
LOG.warn("Netconf session was not established after {}", connectionTimeoutMillis);
changeState(State.FAILED);
final NetconfMessage message = getNetconfMessage(additionalHeader, doc);
if (message instanceof NetconfHelloMessage) {
- Preconditions.checkState(helloReceived == false,
+ Preconditions.checkState(!helloReceived,
"Multiple hello messages received, unexpected hello: %s", message);
out.add(message);
helloReceived = true;
createFidelityElement(doc, fidelityElements, exiOptions.getPreservePIs(), PIS_KEY);
createFidelityElement(doc, fidelityElements, exiOptions.getPreserveNS(), PREFIXES_KEY);
- if (fidelityElements.isEmpty() == false) {
+ if (!fidelityElements.isEmpty()) {
final Element fidelityElement = doc.createElementNS(
XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_EXI_1_0, FIDELITY_KEY);
for (final Element element : fidelityElements) {
session.close(false).addListener(new SshFutureListener<CloseFuture>() {
@Override
public void operationComplete(final CloseFuture future) {
- if (future.isClosed() == false) {
+ if (!future.isClosed()) {
session.close(true);
}
session = null;
promise.setFailure(new IllegalStateException("Channel closed"));
} else {
final ByteBuf byteBufMsg = (ByteBuf) msg;
- if (pending.isEmpty() == false) {
+ if (!pending.isEmpty()) {
queueRequest(ctx, byteBufMsg, promise);
return;
}
} catch (final WritePendingException e) {
- if (wasPending == false) {
+ if (!wasPending) {
queueRequest(ctx, byteBufMsg, promise);
}
}
// Replay not supported
final Optional<XmlElement> startTime =
operationElement.getOnlyChildElementWithSameNamespaceOptionally("startTime");
- Preconditions.checkArgument(startTime.isPresent() == false, "StartTime element not yet supported");
+ Preconditions.checkArgument(!startTime.isPresent(), "StartTime element not yet supported");
// Stop time not supported
final Optional<XmlElement> stopTime =
operationElement.getOnlyChildElementWithSameNamespaceOptionally("stopTime");
- Preconditions.checkArgument(stopTime.isPresent() == false, "StopTime element not yet supported");
+ Preconditions.checkArgument(!stopTime.isPresent(), "StopTime element not yet supported");
final StreamNameType streamNameType = parseStreamIfPresent(operationElement);
Preconditions.checkNotNull(netconfSession);
// Premature streams are allowed (meaning listener can register even if no provider is available yet)
- if (notifications.isStreamAvailable(streamNameType) == false) {
+ if (!notifications.isStreamAvailable(streamNameType)) {
LOG.warn("Registering premature stream {}. No publisher available yet for session {}", streamNameType,
getNetconfSessionIdForReporting());
}
throws DocumentedException {
final Document partialResponse = subsequentOperation.execute(requestMessage);
final Streams availableStreams = notificationRegistry.getNotificationPublishers();
- if (availableStreams.getStream().isEmpty() == false) {
+ if (!availableStreams.getStream().isEmpty()) {
serializeStreamsSubtree(partialResponse, availableStreams);
}
return partialResponse;
@Override
public void operationComplete(final ChannelFuture future) throws Exception {
- if (future.isSuccess() == false) {
+ if (!future.isSuccess()) {
LOG.warn("Unable to release internal connection to netconf server on channel: {}",
clientChannel);
}
MatchingResult matches = matches(src, filter);
if (matches != MatchingResult.NO_MATCH && matches != MatchingResult.CONTENT_MISMATCH) {
// copy srcChild to dst
- boolean filterHasChildren = filter.getChildElements().isEmpty() == false;
+ boolean filterHasChildren = !filter.getChildElements().isEmpty();
// copy to depth if this is leaf of filter tree
- Element copied = (Element) document.importNode(src.getDomElement(), filterHasChildren == false);
- boolean shouldAppend = filterHasChildren == false;
+ Element copied = (Element) document.importNode(src.getDomElement(), !filterHasChildren);
+ boolean shouldAppend = !filterHasChildren;
if (filterHasChildren) { // this implies TAG_MATCH
// do the same recursively
int numberOfTextMatchingChildren = 0;
if (result == null) {
for (Attr attr : filter.getAttributes().values()) {
// ignore namespace declarations
- if (XmlUtil.XMLNS_URI.equals(attr.getNamespaceURI()) == false) {
+ if (!XmlUtil.XMLNS_URI.equals(attr.getNamespaceURI())) {
// find attr with matching localName(), namespaceURI(), == value() in src
String found = src.getAttribute(attr.getLocalName(), attr.getNamespaceURI());
if (attr.getValue().equals(found) && result != MatchingResult.NO_MATCH) {
*/
static NetconfStateSchemas create(final DOMRpcService deviceRpc,
final NetconfSessionPreferences remoteSessionCapabilities, final RemoteDeviceId id) {
- if (remoteSessionCapabilities.isMonitoringSupported() == false) {
+ if (!remoteSessionCapabilities.isMonitoringSupported()) {
// TODO - need to search for get-schema support, not just ietf-netconf-monitoring support
// issue might be a deviation to ietf-netconf-monitoring where get-schema is unsupported...
LOG.warn("{}: Netconf monitoring not supported on device, cannot detect provided schemas", id);
return EMPTY;
}
- if (schemasNodeResult.getErrors().isEmpty() == false) {
+ if (!schemasNodeResult.getErrors().isEmpty()) {
LOG.warn("{}: Unable to detect available schemas, get to {} failed, {}",
id, STATE_SCHEMAS_IDENTIFIER, schemasNodeResult.getErrors());
return EMPTY;
}
final Optional<DataContainerChild<?, ?>> dataNode =
((DataContainerNode<?>) result).getChild(toId(NETCONF_DATA_QNAME));
- if (dataNode.isPresent() == false) {
+ if (!dataNode.isPresent()) {
return Optional.absent();
}
final Optional<DataContainerChild<? extends YangInstanceIdentifier.PathArgument, ?>> nStateNode =
((DataContainerNode<?>) dataNode.get()).getChild(toId(NetconfState.QNAME));
- if (nStateNode.isPresent() == false) {
+ if (!nStateNode.isPresent()) {
return Optional.absent();
}
final String formatAsString = getSingleChildNodeValue(schemaNode, childNode).get();
- if (formatAsString.equals(Yang.QNAME.toString()) == false) {
+ if (!formatAsString.equals(Yang.QNAME.toString())) {
LOG.debug("{}: Ignoring schema due to unsupported format: {}", id, formatAsString);
return Optional.absent();
}
childNode = NetconfMessageTransformUtil.IETF_NETCONF_MONITORING_SCHEMA_LOCATION;
final Set<String> locationsAsString = getAllChildNodeValues(schemaNode, childNode);
- if (locationsAsString.contains(Schema.Location.Enumeration.NETCONF.toString()) == false) {
+ if (!locationsAsString.contains(Schema.Location.Enumeration.NETCONF.toString())) {
LOG.debug("{}: Ignoring schema due to unsupported location: {}", id, locationsAsString);
return Optional.absent();
}
final RemoteYangSchema that = (RemoteYangSchema) obj;
- if (!qname.equals(that.qname)) {
- return false;
- }
-
- return true;
+ return qname.equals(that.qname);
}
@Override
}
private void queueNotification(final NetconfMessage notification) {
- Preconditions.checkState(passNotifications == false);
+ Preconditions.checkState(!passNotifications);
LOG.debug("{}: Caching notification {}, remote schema not yet fully built", id, notification);
if (LOG.isTraceEnabled()) {
@Override
public synchronized boolean cancel(final boolean mayInterruptIfRunning) {
- return uncancellable ? false : super.cancel(mayInterruptIfRunning);
+ return !uncancellable && super.cancel(mayInterruptIfRunning);
}
@Override
final String inputMsgId = input.getDocument().getDocumentElement().getAttribute(MESSAGE_ID_ATTR);
final String outputMsgId = output.getDocument().getDocumentElement().getAttribute(MESSAGE_ID_ATTR);
- if (inputMsgId.equals(outputMsgId) == false) {
+ if (!inputMsgId.equals(outputMsgId)) {
final Map<String, String> errorInfo = ImmutableMap.<String, String>builder()
.put("actual-message-id", outputMsgId)
.put("expected-message-id", inputMsgId)
private static final String MESSAGE_ID_BLUEPRINT = "%s-%s";
public String getNewMessageId(final String prefix) {
- Preconditions.checkArgument(Strings.isNullOrEmpty(prefix) == false, "Null or empty prefix");
+ Preconditions.checkArgument(!Strings.isNullOrEmpty(prefix), "Null or empty prefix");
return String.format(MESSAGE_ID_BLUEPRINT, prefix, getNewMessageId());
}
if (!name.equals(that.name)) {
return false;
}
- if (!bindingPath.equals(that.bindingPath)) {
- return false;
- }
-
- return true;
+ return bindingPath.equals(that.bindingPath);
}
@Override
final String commandName = consoleIO.read();
final Optional<Command> commandOpt = commandRegistry.getCommand(commandName);
- if (commandOpt.isPresent() == false) {
+ if (!commandOpt.isPresent()) {
continue;
}
final NetconfClientConfigurationBuilder configBuilder) {
this.connect(name, address, configBuilder);
synchronized (handler) {
- while (handler.isUp() == false) {
+ while (!handler.isUp()) {
try {
// TODO implement Timeout for unsuccessful connection
handler.wait();
public synchronized Optional<Command> getCommand(final String nameWithModule) {
final QName commandQName = mergeCommandIds().get(nameWithModule);
final Map<QName, Command> qNameCommandMap = mergeCommands();
- if (commandQName == null || qNameCommandMap.containsKey(commandQName) == false) {
+ if (commandQName == null || !qNameCommandMap.containsKey(commandQName)) {
return Optional.absent();
}
}
public Map<DataSchemaNode, List<NormalizedNode<?, ?>>> unwrap(final OutputDefinition outputDefinition) {
- Preconditions.checkArgument(outputDefinition.isEmpty() == false);
+ Preconditions.checkArgument(!outputDefinition.isEmpty());
final Map<QName, DataSchemaNode> mappedSchemaNodes = mapOutput(outputDefinition);
final Map<DataSchemaNode, List<NormalizedNode<?, ?>>> mappedNodesToSchema = Maps.newHashMap();
}
private boolean isReadingWanted(final DataSchemaNode node) {
- if (readConfigNode && !node.isConfiguration()) {
- return false;
- }
- return true;
+ return !readConfigNode || node.isConfiguration();
}
// TODO javadoc
private Optional<DataSchemaNode> getCurrentNode(DataSchemaNode parent, final String buffer) {
for (final String part : buffer.split(SEPARATOR)) {
- if (IOUtil.isQName(part) == false) {
+ if (!IOUtil.isQName(part)) {
return Optional.of(parent);
}
public List<File> generate(final boolean useSsh, final int batchSize,
final int generateConfigsTimeout, final String address,
final int devicesPerPort) {
- if (configDir.exists() == false) {
+ if (!configDir.exists()) {
Preconditions.checkState(configDir.mkdirs(), "Unable to create directory " + configDir);
}
Preconditions.checkArgument(timeout > 0, "Timeout =< 0");
Preconditions.checkArgument(editContent.exists(), "Edit content file missing");
- Preconditions.checkArgument(editContent.isDirectory() == false, "Edit content file is a dir");
+ Preconditions.checkArgument(!editContent.isDirectory(), "Edit content file is a dir");
Preconditions.checkArgument(editContent.canRead(), "Edit content file is unreadable");
Preconditions.checkArgument(destination.startsWith("/"), "Destination should start with a '/'");
}
Preconditions.checkArgument(editContent.exists(), "Edit content file missing");
- Preconditions.checkArgument(editContent.isDirectory() == false, "Edit content file is a dir");
+ Preconditions.checkArgument(!editContent.isDirectory(), "Edit content file is a dir");
Preconditions.checkArgument(editContent.canRead(), "Edit content file is unreadable");
Preconditions.checkArgument(threadAmount > 0, "Parameter thread-amount must be greater than 0");
Preconditions.checkArgument(msgTimeout >= 0, "Parameter msg-timeout must be greater than 0");
}
public boolean isLeafList() {
- return name == null ? true : false;
+ return name == null;
}
}
return false;
}
- if (!java.util.Objects.equals(put, that.put)) {
- return false;
- }
-
- return true;
+ return java.util.Objects.equals(put, that.put);
}
}
return false;
}
- if (!java.util.Objects.equals(failedResponses, that.failedResponses)) {
- return false;
- }
-
- return true;
+ return java.util.Objects.equals(failedResponses, that.failedResponses);
}
}
return false;
}
- if (!java.util.Objects.equals(failedResponses, that.failedResponses)) {
- return false;
- }
-
- return true;
+ return java.util.Objects.equals(failedResponses, that.failedResponses);
}
}
return false;
}
final Operational that = (Operational) obj;
- if (!java.util.Objects.equals(get, that.get)) {
- return false;
- }
-
- return true;
+ return java.util.Objects.equals(get, that.get);
}
}
return false;
}
- if (!java.util.Objects.equals(failedResponses, that.failedResponses)) {
- return false;
- }
-
- return true;
+ return java.util.Objects.equals(failedResponses, that.failedResponses);
}
}
return false;
}
- if (!java.util.Objects.equals(failedResponses, that.failedResponses)) {
- return false;
- }
-
- return true;
+ return java.util.Objects.equals(failedResponses, that.failedResponses);
}
}
return false;
}
- if (!java.util.Objects.equals(failedResponses, that.failedResponses)) {
- return false;
- }
-
- return true;
+ return java.util.Objects.equals(failedResponses, that.failedResponses);
}
}
* @return True if exist, false otherwise.
*/
public boolean isListening() {
- return this.registration == null ? false : true;
+ return this.registration != null;
}
/**
private static boolean isEqualNamespaceAndRevision(final QName parentQName, final QName nodeQName) {
if (parentQName == null) {
- if (nodeQName == null) {
- return true;
- }
- return false;
+ return nodeQName == null;
}
return parentQName.getNamespace().equals(nodeQName.getNamespace())
&& parentQName.getRevision().equals(nodeQName.getRevision());