*/
package org.opendaylight.netconf.callhome.protocol;
-import com.google.common.base.Preconditions;
+import static com.google.common.base.Preconditions.checkArgument;
+import static java.util.Objects.requireNonNull;
+
import com.google.common.collect.ImmutableSet;
import java.security.KeyPair;
import java.util.Collection;
private final Set<KeyPair> clientKeys = new HashSet<>();
Builder(final String nodeId, final String username) {
- this.nodeId = Preconditions.checkNotNull(nodeId);
- this.username = Preconditions.checkNotNull(username);
+ this.nodeId = requireNonNull(nodeId);
+ this.username = requireNonNull(username);
}
/**
ServerAllowed(final String nodeId, final String username, final Collection<String> passwords,
final Collection<KeyPair> clientKeyPairs) {
- this.username = Preconditions.checkNotNull(username);
+ this.username = requireNonNull(username);
this.passwords = ImmutableSet.copyOf(passwords);
this.clientKeyPair = ImmutableSet.copyOf(clientKeyPairs);
- this.nodeId = Preconditions.checkNotNull(nodeId);
+ this.nodeId = requireNonNull(nodeId);
}
@Override
@Override
protected void applyTo(final ClientSession session) {
- Preconditions.checkArgument(session instanceof ClientSessionImpl);
+ checkArgument(session instanceof ClientSessionImpl);
session.setUsername(username);
// First try authentication using server host keys, else try password.
* 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.callhome.protocol;
-import com.google.common.base.Preconditions;
+import static java.util.Objects.requireNonNull;
+
import io.netty.buffer.ByteBuf;
import io.netty.channel.AbstractServerChannel;
import io.netty.channel.ChannelConfig;
MinaSshNettyChannel(final CallHomeSessionContext context, final ClientSession session,
final ClientChannel sshChannel) {
- this.context = Preconditions.checkNotNull(context);
- this.session = Preconditions.checkNotNull(session);
- this.sshChannel = Preconditions.checkNotNull(sshChannel);
+ this.context = requireNonNull(context);
+ this.session = requireNonNull(session);
+ this.sshChannel = requireNonNull(sshChannel);
this.sshReadHandler = new AsyncSshHandlerReader(
new ConnectionClosedDuringRead(), new FireReadMessage(), "netconf", sshChannel.getAsyncOut());
this.sshWriteAsyncHandler = new AsyncSshHandlerWriter(sshChannel.getAsyncIn());
* 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.callhome.mount;
-import com.google.common.base.Preconditions;
+import static java.util.Objects.requireNonNull;
+
import io.netty.util.concurrent.Promise;
import java.net.InetSocketAddress;
import java.security.PublicKey;
CallHomeMountSessionContext(String nodeId, CallHomeProtocolSessionContext protocol,
CallHomeChannelActivator activator, CloseCallback callback) {
- this.nodeId = new NodeId(Preconditions.checkNotNull(nodeId, "nodeId"));
+ this.nodeId = new NodeId(requireNonNull(nodeId, "nodeId"));
this.key = ContextKey.from(protocol.getRemoteAddress());
- this.protocol = Preconditions.checkNotNull(protocol, "protocol");
- this.activator = Preconditions.checkNotNull(activator, "activator");
- this.onClose = Preconditions.checkNotNull(callback, "callback");
+ this.protocol = requireNonNull(protocol, "protocol");
+ this.activator = requireNonNull(activator, "activator");
+ this.onClose = requireNonNull(callback, "callback");
}
NodeId getId() {
* 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.callhome.mount;
-import com.google.common.base.Objects;
-import com.google.common.base.Preconditions;
+import static com.google.common.base.Preconditions.checkArgument;
+import static java.util.Objects.requireNonNull;
+
import java.net.Inet4Address;
import java.net.Inet6Address;
import java.net.InetAddress;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.NetconfNode;
class ContextKey {
-
private final IpAddress address;
private final PortNumber port;
- ContextKey(IpAddress address, PortNumber port) {
- this.address = Preconditions.checkNotNull(address);
- this.port = Preconditions.checkNotNull(port);
+ ContextKey(final IpAddress address, final PortNumber port) {
+ this.address = requireNonNull(address);
+ this.port = requireNonNull(port);
}
@Override
}
@Override
- public boolean equals(Object obj) {
+ public boolean equals(final Object obj) {
if (this == obj) {
return true;
}
return false;
}
ContextKey other = (ContextKey) obj;
- return Objects.equal(address, other.address) && Objects.equal(port, other.port);
+ return address.equals(other.address) && port.equals(other.port);
}
IpAddress getIpAddress() {
return port;
}
- public static ContextKey from(NetconfNode node) {
+ public static ContextKey from(final NetconfNode node) {
return new ContextKey(node.getHost().getIpAddress(), node.getPort());
}
- public static ContextKey from(SocketAddress remoteAddress) {
- Preconditions.checkArgument(remoteAddress instanceof InetSocketAddress);
+ public static ContextKey from(final SocketAddress remoteAddress) {
+ checkArgument(remoteAddress instanceof InetSocketAddress);
InetSocketAddress inetSocketAddr = (InetSocketAddress) remoteAddress;
InetAddress ipAddress = inetSocketAddr.getAddress();
if (ipAddress instanceof Inet4Address) {
yangIp = new IpAddress(IetfInetUtil.INSTANCE.ipv4AddressFor(ipAddress));
} else {
- Preconditions.checkArgument(ipAddress instanceof Inet6Address);
+ checkArgument(ipAddress instanceof Inet6Address);
yangIp = new IpAddress(IetfInetUtil.INSTANCE.ipv6AddressFor(ipAddress));
}
return new ContextKey(yangIp, new PortNumber(inetSocketAddr.getPort()));
* 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.topology.singleton.api;
import org.opendaylight.netconf.sal.connect.api.RemoteDeviceHandler;
import org.opendaylight.netconf.sal.connect.netconf.listener.NetconfSessionPreferences;
/**
- * Provides API for connection odl (master) with device.
+ * Provides API for connection ODL (master) with device.
*/
+// FIXME: way more documentation is needed here
public interface RemoteDeviceConnector {
/**
* Create device communicator and open device connection.
+ *
+ * @param deviceHandler Device handler
+ * @throws NullPointerException if {@code deviceHandler} is null
*/
+ // FIXME: this should return a resource corresponding to the device connection
void startRemoteDeviceConnection(RemoteDeviceHandler<NetconfSessionPreferences> deviceHandler);
/**
* Stop device communicator.
*/
+ // FIXME: see above, this should live in the returned resource
void stopRemoteDeviceConnection();
}
*/
package org.opendaylight.netconf.topology.singleton.impl;
+import static java.util.Objects.requireNonNull;
+
import akka.actor.ActorRef;
import akka.actor.ActorSystem;
import akka.cluster.Cluster;
import akka.dispatch.OnComplete;
import akka.pattern.Patterns;
import akka.util.Timeout;
-import com.google.common.base.Preconditions;
import java.util.List;
import java.util.stream.Collectors;
import org.opendaylight.mdsal.binding.api.DataBroker;
}
private void registerMasterMountPoint() {
- Preconditions.checkNotNull(id);
- Preconditions.checkNotNull(currentSchemaContext,
- "Device has no remote schema context yet. Probably not fully connected.");
- Preconditions.checkNotNull(netconfSessionPreferences,
- "Device has no capabilities yet. Probably not fully connected.");
+ requireNonNull(id);
+ requireNonNull(currentSchemaContext, "Device has no remote schema context yet. Probably not fully connected.");
+ requireNonNull(netconfSessionPreferences, "Device has no capabilities yet. Probably not fully connected.");
final NetconfDeviceNotificationService notificationService = new NetconfDeviceNotificationService();
deviceDataBroker = newDeviceDataBroker();
}
}
}
-}
\ No newline at end of file
+}
private final String privateKeyPath;
private final String privateKeyPassphrase;
private final AAAEncryptionService encryptionService;
- private NetconfConnectorDTO deviceCommunicatorDTO;
private final NetconfKeystoreAdapter keystoreAdapter;
private final DeviceActionFactory deviceActionFactory;
+ // FIXME: this seems to be a builder-like transition between {start,stop}RemoteDeviceConnection. More documentation
+ // is needed, as to what the lifecycle is here.
+ private NetconfConnectorDTO deviceCommunicatorDTO;
+
public RemoteDeviceConnectorImpl(final NetconfTopologySetup netconfTopologyDeviceSetup,
final RemoteDeviceId remoteDeviceId, final DeviceActionFactory deviceActionFactory) {
this.netconfTopologyDeviceSetup = requireNonNull(netconfTopologyDeviceSetup);
final boolean reconnectOnChangedSchema = node.isReconnectOnChangedSchema() == null
? NetconfTopologyUtils.DEFAULT_RECONNECT_ON_CHANGED_SCHEMA : node.isReconnectOnChangedSchema();
- RemoteDeviceHandler<NetconfSessionPreferences> salFacade = deviceHandler;
+ RemoteDeviceHandler<NetconfSessionPreferences> salFacade = requireNonNull(deviceHandler);
if (keepaliveDelay > 0) {
LOG.info("{}: Adding keepalive facade.", remoteDeviceId);
salFacade = new KeepaliveSalFacade(remoteDeviceId, salFacade,
final NetconfDevice.SchemaResourcesDTO schemaResourcesDTO = netconfTopologyDeviceSetup.getSchemaResourcesDTO();
// pre register yang library sources as fallback schemas to schema registry
+ // FIXME: this list not used anywhere. Should it be retained or discarded? (why?)
+ // it would seem those registrations should be bound to NetconfConnectorDTO
final List<SchemaSourceRegistration<YangTextSchemaSource>> registeredYangLibSources = Lists.newArrayList();
if (node.getYangLibrary() != null) {
final String yangLibURL = node.getYangLibrary().getYangLibraryUrl().getValue();
import com.google.common.base.Function;
import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.Collections2;
-import com.google.common.collect.Lists;
-import com.google.common.collect.Sets;
+import java.util.ArrayList;
import java.util.Collections;
+import java.util.HashSet;
import java.util.Optional;
import java.util.Set;
import org.opendaylight.netconf.api.capability.Capability;
public DummyMonitoringService(final Set<Capability> capabilities) {
this.capabilities = new CapabilitiesBuilder().setCapability(
- Lists.newArrayList(Collections2.transform(capabilities, CAPABILITY_URI_FUNCTION))).build();
+ new ArrayList<>(Collections2.transform(capabilities, CAPABILITY_URI_FUNCTION))).build();
- Set<Capability> moduleCapabilities = Sets.newHashSet();
+ Set<Capability> moduleCapabilities = new HashSet<>();
this.capabilityMultiMap = ArrayListMultimap.create();
for (Capability cap : capabilities) {
if (cap.getModuleName().isPresent()) {
}
this.schemas = new SchemasBuilder().setSchema(
- Lists.newArrayList(Collections2.transform(moduleCapabilities, CAPABILITY_SCHEMA_FUNCTION))).build();
+ new ArrayList<>(Collections2.transform(moduleCapabilities, CAPABILITY_SCHEMA_FUNCTION))).build();
}
@Override
import com.google.common.collect.ClassToInstanceMap;
import com.google.common.collect.ImmutableClassToInstanceMap;
-import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import com.google.common.util.concurrent.MoreExecutors;
import java.util.Collections;
import java.util.EnumMap;
+import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ExecutionException;
LeafSetEntryNode locationLeafSetEntryNode = Builders.leafSetEntryBuilder().withNodeIdentifier(
new NodeWithValue<>(location, "NETCONF")).withValue("NETCONF").build();
- Map<QName, Object> keyValues = Maps.newHashMap();
+ Map<QName, Object> keyValues = new HashMap<>();
for (final Schema schema : monitor.getSchemas().getSchema()) {
keyValues.put(identifier, schema.getIdentifier());
keyValues.put(version, schema.getVersion());
* 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.MoreObjects.ToStringHelper;
import com.google.common.collect.Collections2;
-import com.google.common.collect.Lists;
-import com.google.common.collect.Sets;
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ThreadFactoryBuilder;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.net.InetSocketAddress;
import java.net.UnknownHostException;
import java.nio.channels.AsynchronousChannelGroup;
+import java.util.ArrayList;
+import java.util.HashSet;
import java.util.List;
import java.util.Optional;
import java.util.Set;
private final NioEventLoopGroup nettyThreadgroup;
private final HashedWheelTimer hashedWheelTimer;
- private final List<Channel> devicesChannels = Lists.newArrayList();
- private final List<SshProxyServer> sshWrappers = Lists.newArrayList();
+ private final List<Channel> devicesChannels = new ArrayList<>();
+ private final List<SshProxyServer> sshWrappers = new ArrayList<>();
private final ScheduledExecutorService minaTimerExecutor;
private final ExecutorService nioExecutor;
private final Configuration configuration;
private NetconfServerDispatcherImpl createDispatcher(final Set<Capability> capabilities,
final SchemaSourceProvider<YangTextSchemaSource> sourceProvider) {
- final Set<Capability> transformedCapabilities = Sets.newHashSet(Collections2.transform(capabilities, input -> {
+ final Set<Capability> transformedCapabilities = new HashSet<>(Collections2.transform(capabilities, input -> {
if (sendFakeSchema) {
sendFakeSchema = false;
return new FakeCapability((YangModuleCapability) input);
int currentPort = configuration.getStartingPort();
- final List<Integer> openDevices = Lists.newArrayList();
+ final List<Integer> openDevices = new ArrayList<>();
// Generate key to temp folder
final KeyPairProvider keyPairProvider = new VirtualKeyPairProvider();
}
private Set<Capability> parseSchemasToModuleCapabilities(final SharedSchemaRepository consumer) {
- final Set<SourceIdentifier> loadedSources = Sets.newHashSet();
+ final Set<SourceIdentifier> loadedSources = new HashSet<>();
consumer.registerSchemaSourceListener(TextToASTTransformer.create(consumer, consumer));
consumer.registerSchemaSourceListener(new SchemaSourceListener() {
@Override
throw new RuntimeException("Cannot parse schema context", e);
}
- final Set<Capability> capabilities = Sets.newHashSet();
+ final Set<Capability> capabilities = new HashSet<>();
for (final Module module : schemaContext.getModules()) {
for (final Module subModule : module.getSubmodules()) {
* 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.client.stress;
-import com.google.common.collect.Lists;
+import java.util.ArrayList;
import java.util.List;
import org.opendaylight.netconf.api.NetconfMessage;
import org.opendaylight.netconf.sal.connect.netconf.listener.NetconfDeviceCommunicator;
}
private static List<Integer> countEditBatchSizes(final Parameters params, final int amount) {
- final List<Integer> editBatches = Lists.newArrayList();
+ final List<Integer> editBatches = new ArrayList<>();
if (params.editBatchSize != amount) {
final int fullBatches = amount / params.editBatchSize;
for (int i = 0; i < fullBatches; i++) {
* 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.client.stress;
import com.google.common.base.Preconditions;
-import com.google.common.collect.Lists;
import com.google.common.util.concurrent.ListenableFuture;
+import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
@Override
public void invoke() {
final AtomicInteger responseCounter = new AtomicInteger(0);
- final List<ListenableFuture<RpcResult<NetconfMessage>>> futures = Lists.newArrayList();
+ final List<ListenableFuture<RpcResult<NetconfMessage>>> futures = new ArrayList<>();
int batchI = 0;
for (final Integer editBatch : getEditBatches()) {
*/
package org.opendaylight.restconf.common.errors;
-import com.google.common.base.Preconditions;
+import static java.util.Objects.requireNonNull;
+
import com.google.common.collect.ImmutableList;
import java.util.ArrayList;
import java.util.Collection;
* the HTTP status.
*/
public RestconfDocumentedException(final Status status) {
- Preconditions.checkNotNull(status, "Status can't be null");
errors = ImmutableList.of();
- this.status = status;
+ this.status = requireNonNull(status, "Status can't be null");
}
public RestconfDocumentedException(final Throwable cause, final RestconfError error) {
super(cause, error.getErrorTag().getStatusCode());
- Preconditions.checkNotNull(error, "RestconfError can't be null");
errors = ImmutableList.of(error);
status = null;
}
* 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.errors;
-import com.google.common.base.Preconditions;
+import static java.util.Objects.requireNonNull;
+
import java.io.Serializable;
import java.util.Locale;
import org.opendaylight.yangtools.yang.common.RpcError;
*/
public RestconfError(final ErrorType errorType, final ErrorTag errorTag, final String errorMessage,
final String errorAppTag, final String errorInfo, final YangInstanceIdentifier errorPath) {
- Preconditions.checkNotNull(errorType, "Error type is required for RestConfError");
- Preconditions.checkNotNull(errorTag, "Error tag is required for RestConfError");
- this.errorType = errorType;
- this.errorTag = errorTag;
+ this.errorType = requireNonNull(errorType, "Error type is required for RestConfError");
+ this.errorTag = requireNonNull(errorTag, "Error tag is required for RestConfError");
this.errorMessage = errorMessage;
this.errorAppTag = errorAppTag;
this.errorInfo = errorInfo;
* 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 org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
*/
public PatchEntity(final String editId, final PatchEditOperation operation, final YangInstanceIdentifier targetNode,
final NormalizedNode<?, ?> node) {
- this.editId = Preconditions.checkNotNull(editId);
- this.operation = Preconditions.checkNotNull(operation);
- this.targetNode = Preconditions.checkNotNull(targetNode);
- this.node = Preconditions.checkNotNull(node);
+ this.editId = requireNonNull(editId);
+ this.operation = requireNonNull(operation);
+ this.targetNode = requireNonNull(targetNode);
+ this.node = requireNonNull(node);
}
/**
*/
public PatchEntity(final String editId, final PatchEditOperation operation,
final YangInstanceIdentifier targetNode) {
- this.editId = Preconditions.checkNotNull(editId);
- this.operation = Preconditions.checkNotNull(operation);
- this.targetNode = Preconditions.checkNotNull(targetNode);
+ this.editId = requireNonNull(editId);
+ this.operation = requireNonNull(operation);
+ this.targetNode = requireNonNull(targetNode);
this.node = null;
}
*/
package org.opendaylight.restconf.common.util;
-import com.google.common.base.Preconditions;
+import static java.util.Objects.requireNonNull;
+
import java.io.IOException;
import java.io.InputStream;
import java.io.PushbackInputStream;
*
*/
public static Optional<InputStream> isInputStreamEmpty(final InputStream entityStream) throws IOException {
- Preconditions.checkNotNull(entityStream);
- final PushbackInputStream pushbackInputStream = new PushbackInputStream(entityStream);
+ final PushbackInputStream pushbackInputStream = new PushbackInputStream(requireNonNull(entityStream));
int firstByte = pushbackInputStream.read();
if (firstByte == -1) {
*/
package org.opendaylight.restconf.nb.rfc8040.codecs;
-import com.google.common.base.Preconditions;
+import static java.util.Objects.requireNonNull;
+
import com.google.common.collect.Iterables;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.net.URI;
}
}
+ @SuppressFBWarnings(value = "UPM_UNCALLED_PRIVATE_METHOD",
+ justification = "https://github.com/spotbugs/spotbugs/issues/811")
private static Module getModuleByNamespace(final String namespace, final DOMMountPoint mountPoint,
final SchemaContext schemaContext) {
final URI validNamespace = resolveValidNamespace(namespace, mountPoint, schemaContext);
return null;
}
+ @SuppressFBWarnings(value = "UPM_UNCALLED_PRIVATE_METHOD",
+ justification = "https://github.com/spotbugs/spotbugs/issues/811")
private static DataSchemaNode findInstanceDataChildByNameAndNamespace(final DataNodeContainer container,
final String name, final URI namespace) {
- Preconditions.checkNotNull(namespace);
+ requireNonNull(namespace);
final Iterable<DataSchemaNode> result = Iterables.filter(findInstanceDataChildrenByName(container, name),
node -> namespace.equals(node.getQName().getNamespace()));
private static List<DataSchemaNode> findInstanceDataChildrenByName(final DataNodeContainer container,
final String name) {
- Preconditions.checkNotNull(container);
- Preconditions.checkNotNull(name);
-
final List<DataSchemaNode> instantiatedDataNodeContainers = new ArrayList<>();
- collectInstanceDataNodeContainers(instantiatedDataNodeContainers, container, name);
+ collectInstanceDataNodeContainers(instantiatedDataNodeContainers, requireNonNull(container),
+ requireNonNull(name));
return instantiatedDataNodeContainers;
}
*/
package org.opendaylight.restconf.nb.rfc8040.handlers;
-import com.google.common.base.Preconditions;
+import static java.util.Objects.requireNonNull;
+
import com.google.common.base.Throwables;
import java.util.Collection;
import java.util.concurrent.ExecutionException;
@Override
@SuppressWarnings("checkstyle:hiddenField")
public void onGlobalContextUpdated(final SchemaContext context) {
- Preconditions.checkNotNull(context);
- schemaContext = context;
+ schemaContext = requireNonNull(context);
final Module ietfYangLibraryModule =
context.findModule(IetfYangLibrary.MODULE_QNAME).orElse(null);
*/
package org.opendaylight.restconf.nb.rfc8040.jersey.providers;
+import static java.util.Objects.requireNonNull;
import static org.opendaylight.yangtools.yang.data.api.schema.stream.NormalizedNodeStreamWriter.UNKNOWN_SIZE;
import com.google.common.annotations.Beta;
-import com.google.common.base.Preconditions;
import com.google.common.collect.Iterables;
import java.io.IOException;
import java.util.Collection;
private ParameterAwareNormalizedNodeWriter(final NormalizedNodeStreamWriter writer, final Integer maxDepth,
final List<Set<QName>> fields) {
- this.writer = Preconditions.checkNotNull(writer);
+ this.writer = requireNonNull(writer);
this.maxDepth = maxDepth;
this.fields = fields;
}
*/
package org.opendaylight.restconf.nb.rfc8040.rests.utils;
-import com.google.common.collect.Maps;
import com.google.common.util.concurrent.FluentFuture;
+import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
private static void isEqualUriAndPayloadKeyValues(final Map<QName, Object> uriKeyValues, final MapEntryNode payload,
final List<QName> keyDefinitions) {
- final Map<QName, Object> mutableCopyUriKeyValues = Maps.newHashMap(uriKeyValues);
+ final Map<QName, Object> mutableCopyUriKeyValues = new HashMap<>(uriKeyValues);
for (final QName keyDefinition : keyDefinitions) {
final Object uriKeyValue = RestconfDocumentedException.throwIfNull(
mutableCopyUriKeyValues.remove(keyDefinition), ErrorType.PROTOCOL, ErrorTag.DATA_MISSING,
*/
package org.opendaylight.restconf.nb.rfc8040.services.simple.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.restconf.nb.rfc8040.services.simple.impl;
-import com.google.common.base.Preconditions;
+import static java.util.Objects.requireNonNull;
+
import java.util.Optional;
import org.opendaylight.yangtools.concepts.SemVer;
import org.opendaylight.yangtools.yang.common.Revision;
private final Module module;
FakeModuleImport(final Module module) {
- this.module = Preconditions.checkNotNull(module);
+ this.module = requireNonNull(module);
}
@Override
*/
package org.opendaylight.restconf.nb.rfc8040.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 javax.xml.XMLConstants;
@SuppressWarnings("checkstyle:hiddenField")
public void setQueryParams(final Instant start, final Instant stop, final String filter,
final boolean leafNodesOnly) {
- this.start = Preconditions.checkNotNull(start);
+ this.start = requireNonNull(start);
this.stop = stop;
this.filter = filter;
this.leafNodesOnly = leafNodesOnly;
*/
package org.opendaylight.restconf.nb.rfc8040.streams.listeners;
+import static com.google.common.base.Preconditions.checkArgument;
+import static com.google.common.base.Preconditions.checkState;
+import static java.util.Objects.requireNonNull;
+
import com.google.common.base.MoreObjects;
-import com.google.common.base.Preconditions;
import java.io.IOException;
import java.time.Instant;
import java.util.Collection;
final NotificationOutputType outputType) {
setLocalNameOfPath(path.getLastPathArgument().getNodeType().getLocalName());
- this.outputType = Preconditions.checkNotNull(outputType);
- this.path = Preconditions.checkNotNull(path);
- Preconditions.checkArgument(streamName != null && !streamName.isEmpty());
- this.streamName = streamName;
+ this.outputType = requireNonNull(outputType);
+ this.path = requireNonNull(path);
+ this.streamName = requireNonNull(streamName);
+ checkArgument(!streamName.isEmpty());
}
@Override
.append(normalizedNode.getIdentifier()).build();
final Optional<DataSchemaContextNode<?>> childrenSchemaNode = dataSchemaContextTree.findChild(yiid);
- Preconditions.checkState(childrenSchemaNode.isPresent());
+ checkState(childrenSchemaNode.isPresent());
boolean isNodeMixin = childrenSchemaNode.get().isMixin();
boolean isSkippedNonLeaf = getLeafNodesOnly() && !(normalizedNode instanceof LeafNode);
if (!isNodeMixin && !isSkippedNonLeaf) {
try {
SchemaPath nodePath;
final Optional<DataSchemaContextNode<?>> childrenSchemaNode = dataSchemaContextTree.findChild(eventPath);
- Preconditions.checkState(childrenSchemaNode.isPresent());
+ checkState(childrenSchemaNode.isPresent());
if (normalized instanceof MapEntryNode || normalized instanceof UnkeyedListEntryNode) {
nodePath = childrenSchemaNode.get().getDataSchemaNode().getPath();
} else {
*/
package org.opendaylight.restconf.nb.rfc8040.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.MoreObjects;
-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) {
setLocalNameOfPath(path.getLastComponent().getLocalName());
- this.outputType = Preconditions.checkNotNull(outputType);
- this.path = Preconditions.checkNotNull(path);
- Preconditions.checkArgument(streamName != null && !streamName.isEmpty());
- this.streamName = streamName;
+ this.outputType = requireNonNull(outputType);
+ this.path = requireNonNull(path);
+ this.streamName = requireNonNull(streamName);
+ checkArgument(!streamName.isEmpty());
}
/**
*/
package org.opendaylight.restconf.nb.rfc8040;
+import static com.google.common.base.Preconditions.checkArgument;
+import static java.util.Objects.requireNonNull;
import static org.junit.Assert.assertNotNull;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
-import com.google.common.base.Preconditions;
import java.io.BufferedReader;
import java.io.ByteArrayOutputStream;
import java.io.File;
}
public static String getDocumentInPrintableForm(final Document doc) {
- Preconditions.checkNotNull(doc);
try {
final ByteArrayOutputStream out = new ByteArrayOutputStream();
final TransformerFactory tf = TransformerFactory.newInstance();
transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "4");
- transformer.transform(new DOMSource(doc), new StreamResult(new OutputStreamWriter(out,
+ transformer.transform(new DOMSource(requireNonNull(doc)), new StreamResult(new OutputStreamWriter(out,
StandardCharsets.UTF_8)));
final byte[] charData = out.toByteArray();
return new String(charData, StandardCharsets.UTF_8);
public static NodeIdentifierWithPredicates getNodeIdentifierPredicate(final String localName,
final String namespace, final String revision, final String... keysAndValues) throws ParseException {
- Preconditions.checkArgument(keysAndValues.length % 2 == 0,
- "number of keys argument have to be divisible by 2 (map)");
+ checkArgument(keysAndValues.length % 2 == 0, "number of keys argument have to be divisible by 2 (map)");
final Map<QName, Object> predicate = new HashMap<>();
int index = 0;
*/
package org.opendaylight.restconf.nb.rfc8040.streams.listeners;
+import static java.util.Objects.requireNonNull;
import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
-import com.google.common.base.Preconditions;
import com.google.common.collect.Lists;
import java.net.URI;
import java.util.ArrayList;
private String prepareJson(final DOMNotification notificationData, final SchemaPath schemaPathNotifi) {
final NotificationListenerAdapter notifiAdapter = ListenersBroker.getInstance().registerNotificationListener(
schemaPathNotifi, "stream-name", NotificationOutputType.JSON);
- final String result = notifiAdapter.prepareJson(schmeaCtx, notificationData);
- return Preconditions.checkNotNull(result);
+ return requireNonNull(notifiAdapter.prepareJson(schmeaCtx, notificationData));
}
}