Bug 8153: enforce check-style rules for netconf 41/57041/3
authorIvan Hrasko <ivan.hrasko@pantheon.tech>
Mon, 15 May 2017 07:27:53 +0000 (09:27 +0200)
committerIvan Hrasko <ivan.hrasko@pantheon.tech>
Mon, 15 May 2017 08:47:30 +0000 (10:47 +0200)
- netconf-cli module

Change-Id: Ifb0be378ff9f3ddc697bb34d139c5fc76b824907
Signed-off-by: Ivan Hrasko <ivan.hrasko@pantheon.tech>
50 files changed:
netconf/tools/netconf-cli/pom.xml
netconf/tools/netconf-cli/src/main/java/org/opendaylight/netconf/cli/Cli.java
netconf/tools/netconf-cli/src/main/java/org/opendaylight/netconf/cli/CommandArgHandlerRegistry.java
netconf/tools/netconf-cli/src/main/java/org/opendaylight/netconf/cli/Main.java
netconf/tools/netconf-cli/src/main/java/org/opendaylight/netconf/cli/NetconfDeviceConnectionHandler.java
netconf/tools/netconf-cli/src/main/java/org/opendaylight/netconf/cli/NetconfDeviceConnectionManager.java
netconf/tools/netconf-cli/src/main/java/org/opendaylight/netconf/cli/SchemaContextRegistry.java
netconf/tools/netconf-cli/src/main/java/org/opendaylight/netconf/cli/commands/AbstractCommand.java
netconf/tools/netconf-cli/src/main/java/org/opendaylight/netconf/cli/commands/CommandConstants.java
netconf/tools/netconf-cli/src/main/java/org/opendaylight/netconf/cli/commands/CommandDispatcher.java
netconf/tools/netconf-cli/src/main/java/org/opendaylight/netconf/cli/commands/CommandInvocationException.java
netconf/tools/netconf-cli/src/main/java/org/opendaylight/netconf/cli/commands/input/Input.java
netconf/tools/netconf-cli/src/main/java/org/opendaylight/netconf/cli/commands/input/InputDefinition.java
netconf/tools/netconf-cli/src/main/java/org/opendaylight/netconf/cli/commands/local/Close.java
netconf/tools/netconf-cli/src/main/java/org/opendaylight/netconf/cli/commands/local/Connect.java
netconf/tools/netconf-cli/src/main/java/org/opendaylight/netconf/cli/commands/local/Disconnect.java
netconf/tools/netconf-cli/src/main/java/org/opendaylight/netconf/cli/commands/local/Help.java
netconf/tools/netconf-cli/src/main/java/org/opendaylight/netconf/cli/commands/output/Output.java
netconf/tools/netconf-cli/src/main/java/org/opendaylight/netconf/cli/commands/output/OutputDefinition.java
netconf/tools/netconf-cli/src/main/java/org/opendaylight/netconf/cli/commands/remote/RemoteCommand.java
netconf/tools/netconf-cli/src/main/java/org/opendaylight/netconf/cli/io/ConsoleIO.java
netconf/tools/netconf-cli/src/main/java/org/opendaylight/netconf/cli/io/ConsoleIOImpl.java
netconf/tools/netconf-cli/src/main/java/org/opendaylight/netconf/cli/io/IOUtil.java
netconf/tools/netconf-cli/src/main/java/org/opendaylight/netconf/cli/reader/GenericListEntryReader.java
netconf/tools/netconf-cli/src/main/java/org/opendaylight/netconf/cli/reader/Reader.java
netconf/tools/netconf-cli/src/main/java/org/opendaylight/netconf/cli/reader/ReadingException.java
netconf/tools/netconf-cli/src/main/java/org/opendaylight/netconf/cli/reader/custom/ConfigReader.java
netconf/tools/netconf-cli/src/main/java/org/opendaylight/netconf/cli/reader/custom/EditContentReader.java
netconf/tools/netconf-cli/src/main/java/org/opendaylight/netconf/cli/reader/custom/FilterReader.java
netconf/tools/netconf-cli/src/main/java/org/opendaylight/netconf/cli/reader/impl/AnyXmlReader.java
netconf/tools/netconf-cli/src/main/java/org/opendaylight/netconf/cli/reader/impl/BasicDataHolderReader.java
netconf/tools/netconf-cli/src/main/java/org/opendaylight/netconf/cli/reader/impl/ChoiceReader.java
netconf/tools/netconf-cli/src/main/java/org/opendaylight/netconf/cli/reader/impl/ContainerReader.java
netconf/tools/netconf-cli/src/main/java/org/opendaylight/netconf/cli/reader/impl/GenericReader.java
netconf/tools/netconf-cli/src/main/java/org/opendaylight/netconf/cli/reader/impl/LeafListEntryReader.java
netconf/tools/netconf-cli/src/main/java/org/opendaylight/netconf/cli/reader/impl/LeafReader.java
netconf/tools/netconf-cli/src/main/java/org/opendaylight/netconf/cli/reader/impl/ListEntryReader.java
netconf/tools/netconf-cli/src/main/java/org/opendaylight/netconf/cli/reader/impl/SeparatedNodes.java
netconf/tools/netconf-cli/src/main/java/org/opendaylight/netconf/cli/reader/impl/UnionTypeReader.java
netconf/tools/netconf-cli/src/main/java/org/opendaylight/netconf/cli/writer/WriteException.java
netconf/tools/netconf-cli/src/main/java/org/opendaylight/netconf/cli/writer/Writer.java
netconf/tools/netconf-cli/src/main/java/org/opendaylight/netconf/cli/writer/custom/DataWriter.java
netconf/tools/netconf-cli/src/main/java/org/opendaylight/netconf/cli/writer/impl/AbstractWriter.java
netconf/tools/netconf-cli/src/main/java/org/opendaylight/netconf/cli/writer/impl/AugmentationNodeCliSerializer.java
netconf/tools/netconf-cli/src/main/java/org/opendaylight/netconf/cli/writer/impl/CliOutputFromNormalizedNodeSerializerFactory.java
netconf/tools/netconf-cli/src/main/java/org/opendaylight/netconf/cli/writer/impl/LeafSetEntryNodeCliSerializer.java
netconf/tools/netconf-cli/src/main/java/org/opendaylight/netconf/cli/writer/impl/MapEntryNodeCliSerializer.java
netconf/tools/netconf-cli/src/main/java/org/opendaylight/netconf/cli/writer/impl/NormalizedNodeWriter.java
netconf/tools/netconf-cli/src/test/java/org/opendaylight/netconf/cli/ConsoleIOTestImpl.java
netconf/tools/netconf-cli/src/test/java/org/opendaylight/netconf/cli/ValueForMessage.java [moved from netconf/tools/netconf-cli/src/test/java/org/opendaylight/netconf/cli/ValueForMessages.java with 89% similarity]

index df25b24815463c18d204e557714cc6cbdb09c264..0a90e08eab3e7d964ad7133f8ba9c0d82845ed70 100644 (file)
           </execution>
         </executions>
       </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-checkstyle-plugin</artifactId>
+        <configuration>
+          <propertyExpansion>checkstyle.violationSeverity=error</propertyExpansion>
+        </configuration>
+      </plugin>
     </plugins>
   </build>
 </project>
index 9205b5df3d9e28c0181e62f9735a40ab275f0920..8df78fa542770ccb1d6d77ba401622fbc9ebf752 100644 (file)
@@ -37,7 +37,7 @@ import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode;
 
 /**
- * The top level cli state that dispatches command executions
+ * The top level cli state that dispatches command executions.
  */
 public class Cli implements Runnable {
     private final CommandDispatcher commandRegistry;
@@ -46,7 +46,8 @@ public class Cli implements Runnable {
     private final ConsoleIO consoleIO;
 
     public Cli(final ConsoleIO consoleIO, final CommandDispatcher commandRegistry,
-            final CommandArgHandlerRegistry argumentHandlerRegistry, final SchemaContextRegistry schemaContextRegistry) {
+           final CommandArgHandlerRegistry argumentHandlerRegistry,
+           final SchemaContextRegistry schemaContextRegistry) {
         this.consoleIO = consoleIO;
         this.commandRegistry = commandRegistry;
         this.argumentHandlerRegistry = argumentHandlerRegistry;
@@ -111,7 +112,8 @@ public class Cli implements Runnable {
 
                 // FIXME move custom writer to GenericWriter/Serializers ...
                 // this checks only first level
-                final Optional<Class<? extends Writer<DataSchemaNode>>> customReaderClassOpt = tryGetCustomHandler(schemaNode);
+                final Optional<Class<? extends Writer<DataSchemaNode>>> customReaderClassOpt = tryGetCustomHandler(
+                    schemaNode);
 
                 if (customReaderClassOpt.isPresent()) {
                     final Writer<DataSchemaNode> customReaderInstance = argumentHandlerRegistry
@@ -164,7 +166,7 @@ public class Cli implements Runnable {
                 try {
                     final Class<?> argumentClass = Class.forName(argumentHandlerClassName);
                     // TODO add check before cast
-                    return Optional.<Class<? extends T>> of((Class<? extends T>) argumentClass);
+                    return Optional.of((Class<? extends T>) argumentClass);
                 } catch (final ClassNotFoundException e) {
                     throw new IllegalArgumentException("Unknown custom reader class " + argumentHandlerClassName
                             + " for: " + dataSchemaNode.getQName());
@@ -184,7 +186,7 @@ public class Cli implements Runnable {
 
         private final Completer completer;
 
-        public RootConsoleContext(final CommandDispatcher commandRegistry) {
+        RootConsoleContext(final CommandDispatcher commandRegistry) {
             completer = new CommandCompleter(commandRegistry);
         }
 
@@ -202,7 +204,7 @@ public class Cli implements Runnable {
 
             private final CommandDispatcher commandRegistry;
 
-            public CommandCompleter(final CommandDispatcher commandRegistry) {
+            CommandCompleter(final CommandDispatcher commandRegistry) {
                 this.commandRegistry = commandRegistry;
             }
 
index 4f92b0514be9f4cafd1cf82b3b79dc28b8378174..3319b9fda4699355b93a11f8085721cb72b5c0c4 100644 (file)
@@ -79,9 +79,10 @@ public class CommandArgHandlerRegistry {
         return new GenericReader(consoleIO, this, schemaContext, readConfigNode);
     }
 
-    public synchronized Writer<DataSchemaNode> getCustomWriter(final Class<? extends Writer<DataSchemaNode>> writerType) {
-        return customWriters.get(writerType).provide(consoleIO, getRemoteSchema(writerType, schemaContextRegistry),
-                this);
+    public synchronized Writer<DataSchemaNode> getCustomWriter(
+            final Class<? extends Writer<DataSchemaNode>> writerType) {
+        return customWriters.get(writerType).provide(
+            consoleIO, getRemoteSchema(writerType, schemaContextRegistry), this);
     }
 
     public synchronized Writer<DataSchemaNode> getGenericWriter() {
@@ -89,9 +90,9 @@ public class CommandArgHandlerRegistry {
     }
 
     /**
-     * Reader providers, in order to construct readers lazily
+     * Reader providers, in order to construct readers lazily.
      */
-    private static interface ReaderProvider {
+    private interface ReaderProvider {
         Reader<? extends DataSchemaNode> provide(ConsoleIO consoleIO,
                 final CommandArgHandlerRegistry commandArgHandlerRegistry,
                 final SchemaContextRegistry schemaContextRegistry);
@@ -136,9 +137,9 @@ public class CommandArgHandlerRegistry {
     }
 
     /**
-     * Writer providers, in order to construct readers lazily
+     * Writer providers, in order to construct readers lazily.
      */
-    private static interface WriterProvider {
+    private interface WriterProvider {
         Writer<DataSchemaNode> provide(ConsoleIO consoleIO, SchemaContext schema,
                 final CommandArgHandlerRegistry commandArgHandlerRegistry);
     }
index 42518a293acb7987f8ed9ef8a872736ea90ae7a4..97b045abe7511dc98d9a02d4a4918c50418fd5b0 100644 (file)
@@ -30,10 +30,11 @@ import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 
 /**
  * Parse arguments, start remote device connection and start CLI after the
- * connection is fully up
+ * connection is fully up.
  */
 public class Main {
 
+    @SuppressWarnings("illegalCatch")
     public static void main(final String[] args) {
         final CliArgumentParser cliArgs = new CliArgumentParser();
         try {
@@ -63,19 +64,24 @@ public class Main {
         commandDispatcher.addLocalCommands(connectionManager, localSchema, cliArgs.getConnectionTimeoutMs());
 
         switch (cliArgs.connectionArgsPresent()) {
-        case TCP: {
-            // FIXME support pure TCP
-            handleRunningException(new UnsupportedOperationException("PURE TCP CONNECTIONS ARE NOT SUPPORTED YET, USE SSH INSTEAD BY PROVIDING USERNAME AND PASSWORD AS WELL"));
-            return;
-        }
-        case SSH: {
-            writeStatus(consoleIO, "Connecting to %s via SSH. Please wait.", cliArgs.getAddress());
-            connectionManager.connectBlocking(cliArgs.getAddress(), cliArgs.getServerAddress(), getClientSshConfig(cliArgs));
-            break;
-        }
-        case NONE: {/* Do not connect initially */
-            writeStatus(consoleIO, "No initial connection. To connect use the connect command");
-        }
+            case TCP:
+                // FIXME support pure TCP
+                handleRunningException(new UnsupportedOperationException(
+                    "PURE TCP CONNECTIONS ARE NOT SUPPORTED YET, "
+                        + "USE SSH INSTEAD BY PROVIDING USERNAME AND PASSWORD AS WELL"));
+                return;
+            case SSH:
+                writeStatus(consoleIO, "Connecting to %s via SSH. Please wait.", cliArgs.getAddress());
+                connectionManager.connectBlocking(cliArgs.getAddress(), cliArgs.getServerAddress(),
+                    getClientSshConfig(cliArgs));
+                break;
+            case NONE:
+                /* Do not connect initially */
+                writeStatus(consoleIO, "No initial connection. To connect use the connect command");
+                break;
+            default:
+                // NOOP
+                break;
         }
 
         try {
@@ -102,12 +108,13 @@ public class Main {
                 .withProtocol(NetconfClientConfiguration.NetconfClientProtocol.SSH);
     }
 
-    private static void handleStartupException(final IOException e) {
-        handleException(e, "Unable to initialize CLI");
+    private static void handleStartupException(final IOException exc) {
+        handleException(exc, "Unable to initialize CLI");
     }
 
-    private static void handleException(final Exception e, final String message) {
-        System.console().writer().println(String.format("Error %s cause %s", message, getStackTraceAsString(e.fillInStackTrace())));
+    private static void handleException(final Exception exc, final String message) {
+        System.console().writer().println(
+            String.format("Error %s cause %s", message, getStackTraceAsString(exc.fillInStackTrace())));
     }
 
     private static void writeStatus(final ConsoleIO io, final String blueprint, final Object... args) {
@@ -118,8 +125,8 @@ public class Main {
         }
     }
 
-    private static void handleRunningException(final Exception e) {
-        handleException(e, "Unexpected CLI runtime exception");
+    private static void handleRunningException(final Exception exc) {
+        handleException(exc, "Unexpected CLI runtime exception");
     }
 
     private static final class CliArgumentParser {
@@ -135,13 +142,14 @@ public class Main {
         private final ArgumentParser parser;
         private Namespace parsed;
 
+        @SuppressWarnings("checkstyle:lineLength")
         private CliArgumentParser() {
             parser = ArgumentParsers.newArgumentParser("Netconf cli").defaultHelp(true)
                     .description("Generic cli for netconf devices")
-                    .usage("Submit address + port for initial TCP connection (PURE TCP CONNECTIONS ARE NOT SUPPORTED YET)\n" +
-                            "Submit username + password in addition to address + port for initial SSH connection\n" +
-                            "If no arguments(or unexpected combination) is submitted, cli will be started without initial connection\n" +
-                            "To use with ODL controller, run with: java -jar netconf-cli-0.2.5-SNAPSHOT-executable.jar  --server localhost --port 1830 --username admin --password admin");
+                    .usage("Submit address + port for initial TCP connection (PURE TCP CONNECTIONS ARE NOT SUPPORTED YET)\n"
+                        + "Submit username + password in addition to address + port for initial SSH connection\n"
+                        + "If no arguments(or unexpected combination) is submitted, cli will be started without initial connection\n"
+                        + "To use with ODL controller, run with: java -jar netconf-cli-0.2.5-SNAPSHOT-executable.jar  --server localhost --port 1830 --username admin --password admin");
 
             final ArgumentGroup tcpGroup = parser.addArgumentGroup("TCP")
                     .description("Base arguments to initiate TCP connection right away");
@@ -151,8 +159,8 @@ public class Main {
             tcpGroup.addArgument("--" + CONNECT_TIMEOUT)
                     .type(Integer.class)
                     .setDefault(DEFAULT_CONNECTION_TIMEOUT_MS)
-                    .help("Timeout(in ms) for connection to succeed, if the connection is not fully established by the time is up, " +
-                            "connection attempt is considered a failure. This attribute is not working as expected yet");
+                    .help("Timeout(in ms) for connection to succeed, if the connection is not fully established by the time is up, "
+                        + "connection attempt is considered a failure. This attribute is not working as expected yet");
 
             final ArgumentGroup sshGroup = parser.addArgumentGroup("SSH")
                     .description("SSH credentials, if provided, initial connection will be attempted using SSH");
@@ -216,8 +224,8 @@ public class Main {
         }
 
         public InitialConnectionType connectionArgsPresent() {
-            if(getAddress() != null && getPort() != null) {
-                if(getUsername() != null && getPassword() != null) {
+            if (getAddress() != null && getPort() != null) {
+                if (getUsername() != null && getPassword() != null) {
                     return InitialConnectionType.SSH;
                 }
                 return InitialConnectionType.TCP;
index c98c3368e72e94dec5fd5b82189822a0d1af1884..26eeb1b3d529eea6decb43087219b1105439f00c 100644 (file)
@@ -67,6 +67,8 @@ public class NetconfDeviceConnectionHandler implements RemoteDeviceHandler<Netco
     }
 
     /**
+     * Check if device is up.
+     *
      * @return true if connection was fully established
      */
     public synchronized boolean isUp() {
@@ -87,9 +89,7 @@ public class NetconfDeviceConnectionHandler implements RemoteDeviceHandler<Netco
     }
 
     @Override
-    public void onNotification(DOMNotification domNotification) {
-
-    }
+    public void onNotification(DOMNotification domNotification) {}
 
     @Override
     public void close() {
index 6e95ccf3a4013392ae4ed39d5a6c3117a466c6ed..aeebcbf669c772205dbf05d9c6169d777d90c315 100644 (file)
@@ -35,7 +35,7 @@ import org.opendaylight.yangtools.yang.parser.repo.SharedSchemaRepository;
 import org.opendaylight.yangtools.yang.parser.util.TextToASTTransformer;
 
 /**
- * Manages connect/disconnect to 1 remote device
+ * Manages connect/disconnect to 1 remote device.
  */
 public class NetconfDeviceConnectionManager implements Closeable {
 
@@ -70,7 +70,8 @@ public class NetconfDeviceConnectionManager implements Closeable {
 
     // TODO we receive configBuilder in order to add SessionListener, Session
     // Listener should not be part of config
-    public synchronized void connect(final String name, final InetSocketAddress address, final NetconfClientConfigurationBuilder configBuilder) {
+    public synchronized void connect(final String name, final InetSocketAddress address,
+                                     final NetconfClientConfigurationBuilder configBuilder) {
         // TODO change IllegalState exceptions to custom ConnectionException
         Preconditions.checkState(listener == null, "Already connected");
 
@@ -80,11 +81,14 @@ public class NetconfDeviceConnectionManager implements Closeable {
                 console, name);
 
         final SharedSchemaRepository repository = new SharedSchemaRepository("repo");
-        final SchemaContextFactory schemaContextFactory = repository.createSchemaContextFactory(SchemaSourceFilter.ALWAYS_ACCEPT);
-        final FilesystemSchemaSourceCache<YangTextSchemaSource> cache = new FilesystemSchemaSourceCache<>(repository, YangTextSchemaSource.class, new File(CACHE));
+        final SchemaContextFactory schemaContextFactory = repository
+            .createSchemaContextFactory(SchemaSourceFilter.ALWAYS_ACCEPT);
+        final FilesystemSchemaSourceCache<YangTextSchemaSource> cache = new FilesystemSchemaSourceCache<>(
+            repository, YangTextSchemaSource.class, new File(CACHE));
         repository.registerSchemaSourceListener(cache);
         repository.registerSchemaSourceListener(TextToASTTransformer.create(repository, repository));
-        final SchemaResourcesDTO schemaResourcesDTO = new SchemaResourcesDTO(repository, repository, schemaContextFactory, new NetconfStateSchemasResolverImpl());
+        final SchemaResourcesDTO schemaResourcesDTO = new SchemaResourcesDTO(
+            repository, repository, schemaContextFactory, new NetconfStateSchemasResolverImpl());
 
         device = new NetconfDeviceBuilder()
                 .setReconnectOnSchemasChange(true)
@@ -100,9 +104,10 @@ public class NetconfDeviceConnectionManager implements Closeable {
     }
 
     /**
-     * Blocks thread until connection is fully established
+     * Blocks thread until connection is fully established.
      */
-    public synchronized Set<String> connectBlocking(final String name, final InetSocketAddress address, final NetconfClientConfigurationBuilder configBuilder) {
+    public synchronized Set<String> connectBlocking(final String name, final InetSocketAddress address,
+                                                    final NetconfClientConfigurationBuilder configBuilder) {
         this.connect(name, address, configBuilder);
         synchronized (handler) {
             while (handler.isUp() == false) {
index be2f8742bb82d02e9e7dbcc1e71665cfea31fedf..9312d8b75c8490894b7874e232dbe6acefda473e 100644 (file)
@@ -13,6 +13,7 @@ import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 /**
  * Contains the local schema context (containing local commands) and remote schema context (remote commands)
  *
+ * <p>
  * Remote commands are set only after the connection is fully established. So classes using the remote schema context
  */
 public class SchemaContextRegistry {
index f5e2b8da63abaa7e6d546938e879f159f45a823a..d5f8ede24f00b693cefd68de4ffa6112ec621af4 100644 (file)
@@ -19,14 +19,14 @@ import org.opendaylight.yangtools.yang.model.api.RpcDefinition;
 
 public abstract class AbstractCommand implements Command {
 
-    private final QName qName;
+    private final QName qualifiedName;
     private final InputDefinition args;
     private final OutputDefinition output;
     private final String description;
 
-    public AbstractCommand(final QName qName, final InputDefinition args, final OutputDefinition output,
+    public AbstractCommand(final QName qualifiedName, final InputDefinition args, final OutputDefinition output,
             final String description) {
-        this.qName = qName;
+        this.qualifiedName = qualifiedName;
         this.args = args;
         this.output = output;
         this.description = description;
@@ -37,6 +37,11 @@ public abstract class AbstractCommand implements Command {
         return output != null ? OutputDefinition.fromOutput(output) : OutputDefinition.empty();
     }
 
+    @Override
+    public OutputDefinition getOutputDefinition() {
+        return output;
+    }
+
     protected static InputDefinition getInputDefinition(final RpcDefinition rpcDefinition) {
         final ContainerSchemaNode input = rpcDefinition.getInput();
         return InputDefinition.fromInput(input);
@@ -47,14 +52,9 @@ public abstract class AbstractCommand implements Command {
         return args;
     }
 
-    @Override
-    public OutputDefinition getOutputDefinition() {
-        return output;
-    }
-
     @Override
     public QName getCommandId() {
-        return qName;
+        return qualifiedName;
     }
 
     @Override
@@ -68,7 +68,7 @@ public abstract class AbstractCommand implements Command {
 
             @Override
             public Optional<String> getPrompt() {
-                return Optional.of(qName.getLocalName());
+                return Optional.of(qualifiedName.getLocalName());
             }
         };
     }
index 987cb076ff5275802484e3f1fb4e2103c0824f3c..35d9ae88bc6e13c4883b941f029a748a93ffcfa9 100644 (file)
@@ -15,7 +15,8 @@ public class CommandConstants {
 
     // Local command ids are defined here, this links the implementation to the rpc definition in yang
     // Better way needs to be found to provide this link instead of hardcoded QNames (e.g. yang extension)
-    public static final QName HELP_QNAME = QName.create(URI.create("netconf:cli"), IOUtil.parseDate("2014-05-22"), "help");
+    public static final QName HELP_QNAME = QName.create(
+        URI.create("netconf:cli"), IOUtil.parseDate("2014-05-22"), "help");
     public static final QName CLOSE_QNAME = QName.create(HELP_QNAME, "close");
     public static final QName CONNECT_QNAME = QName.create(HELP_QNAME, "connect");
     public static final QName DISCONNECT_QNAME = QName.create(CONNECT_QNAME, "disconnect");
index 077a8a8b44ae6b947c65970887c166ab0049b5fb..da448515a5790d01b0ebf437ab3807df6b4d3221 100644 (file)
@@ -80,38 +80,42 @@ public class CommandDispatcher {
     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) == false) {
             return Optional.absent();
         }
 
         return Optional.of(qNameCommandMap.get(commandQName));
     }
 
-    public synchronized Optional<Command> getCommand(final QName qName) {
-        return Optional.fromNullable(mergeCommands().get(qName));
+    public synchronized Optional<Command> getCommand(final QName qualifiedName) {
+        return Optional.fromNullable(mergeCommands().get(qualifiedName));
     }
 
-    private static Optional<Command> getCommand(final Map<String, QName> commandNameMap, final Map<QName, Command> commands, final String nameWithModule) {
+    private static Optional<Command> getCommand(final Map<String, QName> commandNameMap,
+                                                final Map<QName, Command> commands, final String nameWithModule) {
         final QName qName = commandNameMap.get(nameWithModule);
-        if(qName == null)
+        if (qName == null) {
             return Optional.absent();
-
+        }
         final Command command = commands.get(qName);
-        if(command == null) {
+        if (command == null) {
             return Optional.absent();
         }
 
         return Optional.of(command);
     }
 
-    public static final Collection<String> BASE_NETCONF_SCHEMA_PATHS = Lists.newArrayList("/schema/remote/ietf-netconf.yang",
-            "/schema/common/netconf-cli-ext.yang", "/schema/common/ietf-inet-types.yang");
+    public static final Collection<String> BASE_NETCONF_SCHEMA_PATHS = Lists.newArrayList(
+        "/schema/remote/ietf-netconf.yang",
+        "/schema/common/netconf-cli-ext.yang",
+        "/schema/common/ietf-inet-types.yang");
 
     public synchronized void addRemoteCommands(final DOMRpcService rpcService, final SchemaContext remoteSchema) {
         this.addRemoteCommands(rpcService, remoteSchema, parseSchema(BASE_NETCONF_SCHEMA_PATHS));
     }
 
-    public synchronized void addRemoteCommands(final DOMRpcService rpcService, final SchemaContext remoteSchema, final SchemaContext baseNetconfSchema) {
+    public synchronized void addRemoteCommands(final DOMRpcService rpcService, final SchemaContext remoteSchema,
+                                               final SchemaContext baseNetconfSchema) {
         for (final SchemaContext context : Lists.newArrayList(remoteSchema, baseNetconfSchema)) {
             for (final Module module : context.getModules()) {
                 for (final RpcDefinition rpcDefinition : module.getRpcs()) {
@@ -128,10 +132,13 @@ public class CommandDispatcher {
         nameToQNameRemote.clear();
     }
 
-    public static final Collection<String> LOCAL_SCHEMA_PATHS = Lists.newArrayList("/schema/local/netconf-cli.yang", "/schema/common/netconf-cli-ext.yang",
-            "/schema/common/ietf-inet-types.yang");
+    public static final Collection<String> LOCAL_SCHEMA_PATHS = Lists.newArrayList(
+        "/schema/local/netconf-cli.yang",
+        "/schema/common/netconf-cli-ext.yang",
+        "/schema/common/ietf-inet-types.yang");
 
-    public synchronized void addLocalCommands(final NetconfDeviceConnectionManager connectionManager, final SchemaContext localSchema, final Integer connectionTimeout) {
+    public synchronized void addLocalCommands(final NetconfDeviceConnectionManager connectionManager,
+                                              final SchemaContext localSchema, final Integer connectionTimeout) {
         for (final Module module : localSchema.getModules()) {
             for (final RpcDefinition rpcDefinition : module.getRpcs()) {
 
@@ -149,7 +156,8 @@ public class CommandDispatcher {
                 } else if (rpcDefinition.getQName().equals(CommandConstants.DISCONNECT_QNAME)) {
                     localCommand = Disconnect.create(rpcDefinition, connectionManager);
                 } else {
-                    throw new IllegalStateException("No command implementation available for local command: " + rpcDefinition.getQName());
+                    throw new IllegalStateException(
+                        "No command implementation available for local command: " + rpcDefinition.getQName());
                 }
 
                 localCommands.put(localCommand.getCommandId(), localCommand);
@@ -179,7 +187,8 @@ public class CommandDispatcher {
                 new Function<String, InputStream>() {
                     @Override
                     public InputStream apply(final String input) {
-                        final InputStream resourceAsStream = NetconfDeviceConnectionHandler.class.getResourceAsStream(input);
+                        final InputStream resourceAsStream = NetconfDeviceConnectionHandler.class
+                            .getResourceAsStream(input);
                         Preconditions.checkNotNull(resourceAsStream, "File %s was null", input);
                         return resourceAsStream;
                     }
index 21bcaaf8f987ce921ed71e5e40cfaba52d7ba89b..908e85b6d6ba7f7f742f9e1c7fbd1efcca022984 100644 (file)
@@ -11,8 +11,8 @@ import org.opendaylight.yangtools.yang.common.QName;
 
 public class CommandInvocationException extends Exception {
 
-    public CommandInvocationException(final QName qName, final Throwable cause) {
-        this("Command " + qName + " invocation failed: " + cause.getMessage(), cause);
+    public CommandInvocationException(final QName qualifiedName, final Throwable cause) {
+        this("Command " + qualifiedName + " invocation failed: " + cause.getMessage(), cause);
     }
 
     protected CommandInvocationException(final String message, final Throwable cause) {
@@ -21,8 +21,8 @@ public class CommandInvocationException extends Exception {
 
     public static class CommandTimeoutException extends CommandInvocationException {
 
-        public CommandTimeoutException(final QName qName, final Throwable e) {
-            super("Command " + qName + " timed out: " + e.getMessage(), e);
+        public CommandTimeoutException(final QName qualifiedName, final Throwable throwable) {
+            super("Command " + qualifiedName + " timed out: " + throwable.getMessage(), throwable);
         }
     }
 }
index cc86d7b58cca5ce750d49ce7bbdb64e59a916404..b1404c7da3c644467b278ebf1d45c140891fc3b7 100644 (file)
@@ -21,7 +21,7 @@ import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
 import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableContainerNodeBuilder;
 
 /**
- * Input arguments for and rpc/command execution
+ * Input arguments for and rpc/command execution.
  */
 public class Input {
 
@@ -31,13 +31,14 @@ public class Input {
 
     public Input(final List<NormalizedNode<?, ?>> args) {
         // FIXME empty Input should be constructed from static factory method
-        if(args.isEmpty()) {
+        if (args.isEmpty()) {
             this.args = Collections.emptyList();
             return;
         }
 
         final NormalizedNode<?, ?> input = args.iterator().next();
-        Preconditions.checkArgument(input instanceof DataContainerChild<?, ?>, "Input container has to be of type Data Container Child.");
+        Preconditions.checkArgument(
+            input instanceof DataContainerChild<?, ?>, "Input container has to be of type Data Container Child.");
         this.args = new ArrayList<>((Collection<NormalizedNode<?, ?>>) input.getValue());
 
         for (final NormalizedNode<?, ?> arg : this.args) {
index 6fcffa3bd7c13df3a7f74dfadf617a346c028fe7..1e94a856aae2fb89c91682da9997d0508596cf29 100644 (file)
@@ -11,7 +11,7 @@ import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
 
 /**
  * The definition of input arguments represented by schema nodes parsed from
- * yang rpc definition
+ * yang rpc definition.
  */
 public class InputDefinition {
 
index 615a689b8d69118ac0fc8600aecda8186d32a2bf..d1417ba9c5e0c184ff9b569a3faea5d9461c9970 100644 (file)
@@ -18,12 +18,13 @@ import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.model.api.RpcDefinition;
 
 /**
- * Local command to shut down the cli
+ * Local command to shut down the cli.
  */
 public class Close extends AbstractCommand {
 
-    public Close(final QName qName, final InputDefinition args, final OutputDefinition output, final String description) {
-        super(qName, args, output, description);
+    public Close(final QName qualifiedName, final InputDefinition args, final OutputDefinition output,
+            final String description) {
+        super(qualifiedName, args, output, description);
     }
 
     @Override
index 10645abf1a4e632019033383f9797778a02db944..3bffa568a4af238be424f87a7ea76d5b164524d5 100644 (file)
@@ -41,16 +41,17 @@ import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableLe
 import org.opendaylight.yangtools.yang.model.api.RpcDefinition;
 
 /**
- * Local command to connect to a remote device
+ * Local command to connect to a remote device.
  */
 public class Connect extends AbstractCommand {
 
     private final NetconfDeviceConnectionManager connectManager;
     private final Integer connectionTimeout;
 
-    private Connect(final QName qName, final InputDefinition args, final OutputDefinition output,
-                    final NetconfDeviceConnectionManager connectManager, final String description, final Integer connectionTimeout) {
-        super(qName, args, output, description);
+    private Connect(final QName qualifiedName, final InputDefinition args, final OutputDefinition output,
+                    final NetconfDeviceConnectionManager connectManager, final String description,
+                    final Integer connectionTimeout) {
+        super(qualifiedName, args, output, description);
         this.connectManager = connectManager;
         this.connectionTimeout = connectionTimeout;
     }
@@ -61,7 +62,8 @@ public class Connect extends AbstractCommand {
         return invoke(config, getArgument(inputArgs, "address-name", String.class), inputArgs);
     }
 
-    private Output invoke(final NetconfClientConfigurationBuilder config, final String addressName, final Input inputArgs) {
+    private Output invoke(final NetconfClientConfigurationBuilder config,
+                          final String addressName, final Input inputArgs) {
         final Set<String> remoteCmds = connectManager.connectBlocking(addressName, getAdress(inputArgs), config);
 
         final ArrayList<DataContainerChild<?, ?>> output = Lists.newArrayList();
@@ -108,7 +110,8 @@ public class Connect extends AbstractCommand {
         final String address = getArgument(inputArgs, "address-name", String.class);
         final InetSocketAddress inetAddress;
         try {
-            inetAddress = new InetSocketAddress(InetAddress.getByName(address), getArgument(inputArgs, "address-port", Integer.class));
+            inetAddress = new InetSocketAddress(
+                InetAddress.getByName(address), getArgument(inputArgs, "address-port", Integer.class));
         } catch (final UnknownHostException e) {
             throw new IllegalArgumentException("Unable to use address: " + address, e);
         }
@@ -141,7 +144,8 @@ public class Connect extends AbstractCommand {
         return new NeverReconnectStrategy(GlobalEventExecutor.INSTANCE, 1000);
     }
 
-    public static Command create(final RpcDefinition rpcDefinition, final NetconfDeviceConnectionManager connectManager, final Integer connectionTimeout) {
+    public static Command create(final RpcDefinition rpcDefinition, final NetconfDeviceConnectionManager connectManager,
+                                 final Integer connectionTimeout) {
         return new Connect(rpcDefinition.getQName(), getInputDefinition(rpcDefinition),
                 getOutputDefinition(rpcDefinition), connectManager, rpcDefinition.getDescription(), connectionTimeout);
     }
index 495cb33b9f74f4663fb56908b4e2b20c79c092dc..15e8b3706d9362ec025f657ef3e74f7f37c25f6e 100644 (file)
@@ -21,16 +21,16 @@ import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableLe
 import org.opendaylight.yangtools.yang.model.api.RpcDefinition;
 
 /**
- * Local disconnect command
+ * Local disconnect command.
  */
 public class Disconnect extends AbstractCommand {
 
     private final NetconfDeviceConnectionManager connectionManager;
 
-    public Disconnect(final QName qName, final InputDefinition inputDefinition,
+    public Disconnect(final QName qualifiedName, final InputDefinition inputDefinition,
             final OutputDefinition outputDefinition, final NetconfDeviceConnectionManager connectionManager,
             final String description) {
-        super(qName, inputDefinition, outputDefinition, description);
+        super(qualifiedName, inputDefinition, outputDefinition, description);
         this.connectionManager = connectionManager;
     }
 
index 4b7e4aa1f9c9515346e9685191e5fd17aaaa0f0b..82751ec9b71aa53811132b916cc646c9f85c3b92 100644 (file)
@@ -37,8 +37,9 @@ public class Help extends AbstractCommand {
 
     private final CommandDispatcher commandDispatcher;
 
-    public Help(final QName qName, final InputDefinition argsDefinition, final OutputDefinition output, final String description, final CommandDispatcher commandDispatcher) {
-        super(qName, argsDefinition, output, description);
+    public Help(final QName qualifiedName, final InputDefinition argsDefinition, final OutputDefinition output,
+                final String description, final CommandDispatcher commandDispatcher) {
+        super(qualifiedName, argsDefinition, output, description);
         this.commandDispatcher = commandDispatcher;
     }
 
@@ -55,7 +56,7 @@ public class Help extends AbstractCommand {
                     ImmutableLeafNodeBuilder.create()
                             .withNodeIdentifier(new NodeIdentifier(QName.create(getCommandId(), "id")))
                             .withValue(id).build());
-            if(description.isPresent()) {
+            if (description.isPresent()) {
                 nameAndDescription.add(
                         ImmutableLeafNodeBuilder.create()
                                 .withNodeIdentifier(new NodeIdentifier(QName.create(getCommandId(), "description")))
@@ -75,6 +76,7 @@ public class Help extends AbstractCommand {
     }
 
     public static Command create(final RpcDefinition rpcDefinition, final CommandDispatcher commandDispatcher) {
-        return new Help(rpcDefinition.getQName(), getInputDefinition(rpcDefinition), getOutputDefinition(rpcDefinition), rpcDefinition.getDescription(), commandDispatcher);
+        return new Help(rpcDefinition.getQName(), getInputDefinition(rpcDefinition), getOutputDefinition(rpcDefinition),
+            rpcDefinition.getDescription(), commandDispatcher);
     }
 }
index f48fc7047270124db71493a43608c1f889dadad8..45a7b4ad2268eeb802f91376bfc132942552b6fa 100644 (file)
@@ -18,7 +18,7 @@ import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
 
 /**
- * Output values for and rpc/command execution
+ * Output values for and rpc/command execution.
  */
 public class Output {
 
@@ -39,8 +39,8 @@ public class Output {
         final Map<DataSchemaNode, List<NormalizedNode<?, ?>>> mappedNodesToSchema = Maps.newHashMap();
 
         final DataSchemaNode schemaNode = mappedSchemaNodes.get(output.getNodeType().withoutRevision());
-        final List<NormalizedNode<?, ?>> list = mappedNodesToSchema.get(schemaNode) == null ? Lists.<NormalizedNode<?, ?>>newArrayList()
-                : mappedNodesToSchema.get(schemaNode);
+        final List<NormalizedNode<?, ?>> list = mappedNodesToSchema.get(schemaNode) == null
+            ? Lists.newArrayList() : mappedNodesToSchema.get(schemaNode);
         list.add(output);
         mappedNodesToSchema.put(schemaNode, list);
 
index 18907b78b25566d1bc48b331dee89efb7b67c893..1964a5bc54a72acdc1ed860328aa4b757640dd71 100644 (file)
@@ -14,7 +14,7 @@ import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
 
 /**
- * The definition of output elements represented by schema nodes parsed from yang rpc definition
+ * The definition of output elements represented by schema nodes parsed from yang rpc definition.
  */
 public class OutputDefinition implements Iterable<DataSchemaNode> {
 
index ba9b033063e4ed130b0f8a772f77284512526b76..75e7f3855a6c007ae9a7b18a9b4b11a3d6f430ff 100644 (file)
@@ -28,7 +28,7 @@ import org.opendaylight.yangtools.yang.model.api.SchemaPath;
 
 /**
  * Generic remote command implementation that sends the rpc xml to the remote device and waits for response
- * Waiting is limited with TIMEOUT
+ * Waiting is limited with TIMEOUT.
  */
 public class RemoteCommand extends AbstractCommand {
 
@@ -37,15 +37,16 @@ public class RemoteCommand extends AbstractCommand {
     private static final TimeUnit DEFAULT_TIMEOUT_UNIT = TimeUnit.MILLISECONDS;
     private final DOMRpcService rpcService;
 
-    public RemoteCommand(final QName qName, final InputDefinition args, final OutputDefinition output, final String description, final DOMRpcService rpcService) {
-        super(qName, args, output, description);
+    public RemoteCommand(final QName qualifiedName, final InputDefinition args, final OutputDefinition output,
+                         final String description, final DOMRpcService rpcService) {
+        super(qualifiedName, args, output, description);
         this.rpcService = rpcService;
     }
 
     @Override
     public Output invoke(final Input inputArgs) throws CommandInvocationException {
-        final CheckedFuture<DOMRpcResult, DOMRpcException> invokeRpc =
-                rpcService.invokeRpc(SchemaPath.create(Collections.singletonList(getCommandId()), true), inputArgs.wrap(getCommandId()));
+        final CheckedFuture<DOMRpcResult, DOMRpcException> invokeRpc = rpcService.invokeRpc(
+            SchemaPath.create(Collections.singletonList(getCommandId()), true), inputArgs.wrap(getCommandId()));
 
         try {
             return new Output(invokeRpc.get(DEFAULT_TIMEOUT, DEFAULT_TIMEOUT_UNIT).getResult());
index ae33c3ac5bb1cd4e13d52c763b34f00370bd71cb..44ef661ddeb25e7b1339514b7a19d7534982531b 100644 (file)
@@ -10,7 +10,7 @@ package org.opendaylight.netconf.cli.io;
 import java.io.IOException;
 
 /**
- * Definition of IO interface
+ * Definition of IO interface.
  */
 public interface ConsoleIO {
 
index 22810cd8d45a6fb0ffa63613563bb5d5310fe816..b24a5091b2e7e65c3a460e8f018ec563a3f80fc2 100644 (file)
@@ -25,7 +25,7 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 /**
- * Jline based IO implementation
+ * Jline based IO implementation.
  */
 public class ConsoleIOImpl implements ConsoleIO {
 
@@ -122,7 +122,7 @@ public class ConsoleIOImpl implements ConsoleIO {
                 newPrompt.append(promptPart.get());
             }
         }
-        if (newPrompt.length() ==0) {
+        if (newPrompt.length() == 0) {
             newPrompt.append(PATH_SEPARATOR);
         }
 
@@ -140,7 +140,7 @@ public class ConsoleIOImpl implements ConsoleIO {
 
     private class QuestionMarkActionListener implements ActionListener {
         @Override
-        public void actionPerformed(final ActionEvent e) {
+        public void actionPerformed(final ActionEvent event) {
             ConsoleIOImpl.this.complete();
         }
     }
index 0387889681473f3c0f1f88cfdad373410f9a21a2..ad92c666a8cf7aecc2867b62459cd49344d3b9e5 100644 (file)
@@ -8,7 +8,6 @@
 package org.opendaylight.netconf.cli.io;
 
 import java.text.ParseException;
-import java.text.SimpleDateFormat;
 import java.util.Date;
 import java.util.Map;
 import java.util.regex.Matcher;
@@ -27,11 +26,10 @@ public class IOUtil {
     public static final String PROMPT_SUFIX = ">";
     public static final String PATH_SEPARATOR = "/";
 
-    private IOUtil() {
-    }
+    private IOUtil() {}
 
-    public static boolean isQName(final String qName) {
-        final Matcher matcher = patternNew.matcher(qName);
+    public static boolean isQName(final String qualifiedName) {
+        final Matcher matcher = PATTERN.matcher(qualifiedName);
         return matcher.matches();
     }
 
@@ -55,18 +53,18 @@ public class IOUtil {
         return "";
     }
 
-    public static String qNameToKeyString(final QName qName, final String moduleName) {
-        return String.format("%s(%s)", qName.getLocalName(), moduleName);
+    public static String qNameToKeyString(final QName qualifiedName, final String moduleName) {
+        return String.format("%s(%s)", qualifiedName.getLocalName(), moduleName);
     }
 
     // TODO test and check regex + review format of string for QName
-    final static Pattern patternNew = Pattern.compile("([^\\)]+)\\(([^\\)]+)\\)");
+    static final Pattern PATTERN = Pattern.compile("([^\\)]+)\\(([^\\)]+)\\)");
 
-    public static QName qNameFromKeyString(final String qName, final Map<String, QName> mappedModules)
+    public static QName qNameFromKeyString(final String qualifiedName, final Map<String, QName> mappedModules)
             throws ReadingException {
-        final Matcher matcher = patternNew.matcher(qName);
+        final Matcher matcher = PATTERN.matcher(qualifiedName);
         if (!matcher.matches()) {
-            final String message = String.format("QName in wrong format: %s should be: %s", qName, patternNew);
+            final String message = String.format("QName in wrong format: %s should be: %s", qualifiedName, PATTERN);
             throw new ReadingException(message);
         }
         final QName base = mappedModules.get(matcher.group(2));
index 83761fdba86694fee8274ec2e86b6e5fcb97d593..436247ac35bcc3164fed00491c52b73e1a439c26 100644 (file)
@@ -10,7 +10,7 @@ package org.opendaylight.netconf.cli.reader;
 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
 
 /**
- * marker interface to mark reader which can be used with GenericListReader
+ * Marker interface to mark reader which can be used with GenericListReader.
  */
 public interface GenericListEntryReader<T extends DataSchemaNode> extends Reader<T> {
 
index ecf28a6f189b28d3633edd63d8f224004d422e30..7c4601cd81d70751a93d89826effa763f56bcb93 100644 (file)
@@ -12,7 +12,7 @@ import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
 
 /**
- * Generic provider(reader) of input arguments for commands
+ * Generic provider(reader) of input arguments for commands.
  */
 public interface Reader<T extends DataSchemaNode> {
 
index 955d14f70098dc13e196185d029cc1e7e08c46ce..98a1fffac83f4485f7c9634d77dd0182012ecf47 100644 (file)
@@ -11,8 +11,8 @@ public class ReadingException extends Exception {
 
     private static final long serialVersionUID = -298382323286156591L;
 
-    public ReadingException(final String msg, final Exception e) {
-        super(msg, e);
+    public ReadingException(final String msg, final Exception ex) {
+        super(msg, ex);
     }
 
     public ReadingException(final String msg) {
index b05f56f27e24eb93a0694e3606c44ffacfa3af0a..995e232d8747cd4952cb77661e47018ac6680a8c 100644 (file)
@@ -73,7 +73,8 @@ public class ConfigReader extends AbstractReader<DataSchemaNode> {
     // FIXME refactor + unite common code with FilterReader
 
     @Override
-    protected List<NormalizedNode<?, ?>> readWithContext(final DataSchemaNode schemaNode) throws IOException, ReadingException {
+    protected List<NormalizedNode<?, ?>> readWithContext(final DataSchemaNode schemaNode)
+            throws IOException, ReadingException {
         console.writeLn("Config " + schemaNode.getQName().getLocalName());
         console.writeLn("Submit path of the data to edit. Use TAB for autocomplete");
 
@@ -93,11 +94,11 @@ public class ConfigReader extends AbstractReader<DataSchemaNode> {
 
         List<? extends NormalizedNode<?, ?>> previous = readInnerNode(rawValue);
 
-        for (final QName qName : Lists.reverse(filterPartsQNames).subList(1, filterPartsQNames.size())) {
+        for (final QName qualifiedName : Lists.reverse(filterPartsQNames).subList(1, filterPartsQNames.size())) {
             previous = Collections.<NormalizedNode<?, ?>>singletonList(
                     ImmutableContainerNodeBuilder.create()
-                            .withNodeIdentifier(new NodeIdentifier(qName))
-                            .withValue(previous == null ? Collections.<DataContainerChild<?, ?>>emptyList() : (Collection) previous).build()
+                            .withNodeIdentifier(new NodeIdentifier(qualifiedName))
+                            .withValue(previous == null ? Collections.emptyList() : (Collection) previous).build()
             );
         }
 
@@ -105,11 +106,12 @@ public class ConfigReader extends AbstractReader<DataSchemaNode> {
             return Collections.singletonList(null);
         }
 
-        final DataContainerNodeAttrBuilder<NodeIdentifier, ContainerNode> builder = ImmutableContainerNodeBuilder.create();
+        final DataContainerNodeAttrBuilder<NodeIdentifier, ContainerNode> builder = ImmutableContainerNodeBuilder
+            .create();
         builder.withNodeIdentifier(new NodeIdentifier(schemaNode.getQName()));
         builder.withValue((Collection<DataContainerChild<?, ?>>) previous);
 
-        return Collections.<NormalizedNode<?, ?>> singletonList(builder.build());
+        return Collections.singletonList(builder.build());
     }
 
     private List<NormalizedNode<?, ?>> readInnerNode(final String pathString) throws ReadingException {
@@ -127,14 +129,14 @@ public class ConfigReader extends AbstractReader<DataSchemaNode> {
 
         private final SchemaContext remoteSchemaContext;
 
-        public FilterConsoleContext(final DataSchemaNode schemaNode, final SchemaContext remoteSchemaContext) {
+        FilterConsoleContext(final DataSchemaNode schemaNode, final SchemaContext remoteSchemaContext) {
             super(schemaNode);
             this.remoteSchemaContext = remoteSchemaContext;
         }
 
         @Override
         protected List<Completer> getAdditionalCompleters() {
-            return Collections.<Completer> singletonList(new FilterCompleter(remoteSchemaContext));
+            return Collections.singletonList(new FilterCompleter(remoteSchemaContext));
         }
     }
 
@@ -142,7 +144,7 @@ public class ConfigReader extends AbstractReader<DataSchemaNode> {
 
         private final SchemaContext remoteSchemaContext;
 
-        public FilterCompleter(final SchemaContext remoteSchemaContext) {
+        FilterCompleter(final SchemaContext remoteSchemaContext) {
             this.remoteSchemaContext = remoteSchemaContext;
         }
 
index 92a33fb4e8181d4171c493cd4dd9b15c58c4b388..23de82824bab769c84ae751c3944cd536146aff4 100644 (file)
@@ -28,15 +28,19 @@ public class EditContentReader extends ChoiceReader {
 
     // FIXME this could be removed if feature/if-feature are supported
 
-    public EditContentReader(final ConsoleIO console, final CommandArgHandlerRegistry argumentHandlerRegistry, final SchemaContext schemaContext) {
+    public EditContentReader(final ConsoleIO console, final CommandArgHandlerRegistry argumentHandlerRegistry,
+                             final SchemaContext schemaContext) {
         super(console, argumentHandlerRegistry, schemaContext);
     }
 
     @Override
-    public List<NormalizedNode<?, ?>> readWithContext(final ChoiceSchemaNode choiceNode) throws IOException, ReadingException {
-        Preconditions.checkState(choiceNode.getQName().equals(EDIT_CONTENT_QNAME), "Unexpected choice %s, expected %s", choiceNode, EDIT_CONTENT_QNAME);
+    public List<NormalizedNode<?, ?>> readWithContext(final ChoiceSchemaNode choiceNode)
+            throws IOException, ReadingException {
+        Preconditions.checkState(choiceNode.getQName().equals(EDIT_CONTENT_QNAME),
+            "Unexpected choice %s, expected %s", choiceNode, EDIT_CONTENT_QNAME);
         final ChoiceCaseNode selectedCase = choiceNode.getCaseNodeByName(CONFIG_QNAME);
-        Preconditions.checkNotNull(selectedCase, "Unexpected choice %s, expected %s that contains %s", choiceNode, EDIT_CONTENT_QNAME, CONFIG_QNAME);
+        Preconditions.checkNotNull(selectedCase,
+            "Unexpected choice %s, expected %s that contains %s", choiceNode, EDIT_CONTENT_QNAME, CONFIG_QNAME);
         return readSelectedCase(selectedCase);
     }
 
index e75d217c1720b693283eb6b0d89370d63a8158f7..d63a5b26cfaada3a59bab479622314805d7355dd 100644 (file)
@@ -74,7 +74,8 @@ public class FilterReader extends AbstractReader<DataSchemaNode> {
     public static final String FILTER_TYPE_VALUE_DEFAULT = "subtree";
 
     @Override
-    protected List<NormalizedNode<?, ?>> readWithContext(final DataSchemaNode schemaNode) throws IOException, ReadingException {
+    protected List<NormalizedNode<?, ?>> readWithContext(final DataSchemaNode schemaNode)
+            throws IOException, ReadingException {
         boolean redSuccessfuly = false;
         DataContainerChild<?, ?> newNode = null;
         do {
@@ -98,10 +99,11 @@ public class FilterReader extends AbstractReader<DataSchemaNode> {
 
                 DataContainerChild<?, ?> previous = null;
 
-                for (final QName qName : Lists.reverse(filterPartsQNames)) {
-                    previous = ImmutableContainerNodeBuilder.create().withNodeIdentifier(new NodeIdentifier(qName))
-                            .withValue(previous == null ? Collections.<DataContainerChild<?, ?>>emptyList()
-                                    : Collections.<DataContainerChild<?, ?>>singletonList(previous)).build();
+                for (final QName qualifiedName : Lists.reverse(filterPartsQNames)) {
+                    previous = ImmutableContainerNodeBuilder.create()
+                        .withNodeIdentifier(new NodeIdentifier(qualifiedName))
+                            .withValue(previous == null ? Collections.emptyList()
+                                    : Collections.singletonList(previous)).build();
                 }
 
                 final Map<QName, String> attributes = Collections.singletonMap(FILTER_TYPE_QNAME,
@@ -115,7 +117,7 @@ public class FilterReader extends AbstractReader<DataSchemaNode> {
                 console.writeLn(message);
             }
         } while (!redSuccessfuly);
-        return Collections.<NormalizedNode<?, ?>> singletonList(newNode);
+        return Collections.singletonList(newNode);
     }
 
     @Override
@@ -127,14 +129,14 @@ public class FilterReader extends AbstractReader<DataSchemaNode> {
 
         private final SchemaContext remoteSchemaContext;
 
-        public FilterConsoleContext(final DataSchemaNode schemaNode, final SchemaContext remoteSchemaContext) {
+        FilterConsoleContext(final DataSchemaNode schemaNode, final SchemaContext remoteSchemaContext) {
             super(schemaNode);
             this.remoteSchemaContext = remoteSchemaContext;
         }
 
         @Override
         protected List<Completer> getAdditionalCompleters() {
-            return Collections.<Completer> singletonList(new FilterCompleter(remoteSchemaContext));
+            return Collections.singletonList(new FilterCompleter(remoteSchemaContext));
         }
 
     }
@@ -146,7 +148,7 @@ public class FilterReader extends AbstractReader<DataSchemaNode> {
         // TODO add skip to filter completer, better soulution would be to add
         // SKIP completer before context completer if possible
 
-        public FilterCompleter(final SchemaContext remoteSchemaContext) {
+        FilterCompleter(final SchemaContext remoteSchemaContext) {
             this.remoteSchemaContext = remoteSchemaContext;
         }
 
@@ -198,14 +200,14 @@ public class FilterReader extends AbstractReader<DataSchemaNode> {
                     return Optional.of(parent);
                 }
 
-                QName qName;
+                QName qualifiedName;
                 try {
-                    qName = IOUtil.qNameFromKeyString(part, mappedModules);
+                    qualifiedName = IOUtil.qNameFromKeyString(part, mappedModules);
                 } catch (final ReadingException e) {
                     return Optional.of(parent);
                 }
 
-                final DataSchemaNode dataChildByName = parent.getDataChildByName(qName);
+                final DataSchemaNode dataChildByName = parent.getDataChildByName(qualifiedName);
                 if (dataChildByName instanceof DataNodeContainer) {
                     parent = (DataNodeContainer) dataChildByName;
                 } else {
index 6112fc875b9987d11dce0968a9ba975789be30c1..cdc30830639381fb1865eac27873ae4c97ef2267 100644 (file)
@@ -44,7 +44,8 @@ public class AnyXmlReader extends AbstractReader<AnyXmlSchemaNode> {
     }
 
     @Override
-    protected List<NormalizedNode<?, ?>> readWithContext(final AnyXmlSchemaNode schemaNode) throws IOException, ReadingException {
+    protected List<NormalizedNode<?, ?>> readWithContext(final AnyXmlSchemaNode schemaNode)
+            throws IOException, ReadingException {
         console.writeLn(listType(schemaNode) + " " + schemaNode.getQName().getLocalName());
 
         final String rawValue = console.read();
@@ -58,7 +59,8 @@ public class AnyXmlReader extends AbstractReader<AnyXmlSchemaNode> {
                         .withNodeIdentifier(new NodeIdentifier(schemaNode.getQName()))
                         .withChild(value.get()).build();
             } else {
-                newNode = ImmutableLeafNodeBuilder.create().withNodeIdentifier(new NodeIdentifier(schemaNode.getQName())).withValue(rawValue).build();
+                newNode = ImmutableLeafNodeBuilder.create().withNodeIdentifier(
+                    new NodeIdentifier(schemaNode.getQName())).withValue(rawValue).build();
             }
         }
 
@@ -70,11 +72,11 @@ public class AnyXmlReader extends AbstractReader<AnyXmlSchemaNode> {
     private Optional<DataContainerChild<?, ?>> tryParse(final String rawValue, final AnyXmlSchemaNode schemaNode) {
         try {
             final Document dom = XmlUtil.readXmlToDocument(rawValue);
-            return Optional.<DataContainerChild<?, ?>> of(
-                    DomToNormalizedNodeParserFactory.
-                            getInstance(DomUtils.defaultValueCodecProvider(), getSchemaContext()).
-                            getAnyXmlNodeParser().
-                            parse(Collections.singletonList(dom.getDocumentElement()), schemaNode)
+            return Optional.of(
+                    DomToNormalizedNodeParserFactory
+                            .getInstance(DomUtils.defaultValueCodecProvider(), getSchemaContext())
+                            .getAnyXmlNodeParser()
+                            .parse(Collections.singletonList(dom.getDocumentElement()), schemaNode)
             );
         } catch (SAXException | IOException e) {
             // TODO log
index 65f694c0c90bc440ce45a8e1d6e4566b5b6c5193..e5447ce5a87af1b7e8d5b08dc6845ea3830d030b 100644 (file)
@@ -58,7 +58,8 @@ public abstract class BasicDataHolderReader<T extends DataSchemaNode> extends Ab
     @Override
     public List<NormalizedNode<?, ?>> readWithContext(final T schemaNode) throws IOException, ReadingException {
         TypeDefinition<?> type = getType(schemaNode);
-        console.formatLn("Submit %s %s(%s)", listType(schemaNode), schemaNode.getQName().getLocalName(), type.getQName().getLocalName());
+        console.formatLn("Submit %s %s(%s)", listType(schemaNode), schemaNode.getQName().getLocalName(),
+            type.getQName().getLocalName());
 
         while (baseTypeFor(type) instanceof UnionTypeDefinition) {
             final Optional<TypeDefinition<?>> optionalTypeDef = new UnionTypeReader(console).read(type);
@@ -142,8 +143,7 @@ public abstract class BasicDataHolderReader<T extends DataSchemaNode> extends Ab
         return currentCompleter;
     }
 
-    private static interface DataHolderCompleter extends Completer {
-
+    private interface DataHolderCompleter extends Completer {
         Object resolveValue(String rawValue) throws ReadingException;
     }
 
@@ -152,7 +152,7 @@ public abstract class BasicDataHolderReader<T extends DataSchemaNode> extends Ab
         private final Optional<TypeDefinitionAwareCodec<Object, ? extends TypeDefinition<?>>> codec;
         private final TypeDefinition<?> type;
 
-        public GeneralDataHolderCompleter(final TypeDefinition<?> type) {
+        GeneralDataHolderCompleter(final TypeDefinition<?> type) {
             this.type = type;
             codec = getCodecForType(type);
         }
@@ -164,18 +164,17 @@ public abstract class BasicDataHolderReader<T extends DataSchemaNode> extends Ab
         private static Optional<TypeDefinitionAwareCodec<Object, ? extends TypeDefinition<?>>> getCodecForType(
                 final TypeDefinition<?> type) {
             if (type != null) {
-                return Optional
-                        .<TypeDefinitionAwareCodec<Object, ? extends TypeDefinition<?>>> fromNullable(TypeDefinitionAwareCodec
-                                .from(type));
+                return Optional.fromNullable(TypeDefinitionAwareCodec.from(type));
             }
             return Optional.absent();
         }
 
+        @SuppressWarnings("illegalCatch")
         @Override
         public Object resolveValue(final String rawValue) throws ReadingException {
             try {
                 return codec.isPresent() ? codec.get().deserialize(rawValue) : rawValue;
-            } catch (final RuntimeException e) {
+            } catch (final Exception e) {
                 final String message = "It wasn't possible deserialize value " + rawValue + ".";
                 LOG.error(message, e);
                 throw new ReadingException(message, e);
@@ -190,7 +189,7 @@ public abstract class BasicDataHolderReader<T extends DataSchemaNode> extends Ab
 
     private static final class EnumDataHolderCompleter extends GeneralDataHolderCompleter {
 
-        public EnumDataHolderCompleter(final TypeDefinition<?> type) {
+        EnumDataHolderCompleter(final TypeDefinition<?> type) {
             super(type);
         }
 
@@ -210,7 +209,7 @@ public abstract class BasicDataHolderReader<T extends DataSchemaNode> extends Ab
 
         private final BiMap<String, QName> identityMap;
 
-        public IdentityRefDataHolderCompleter(final TypeDefinition<?> type, final SchemaContext schemaContext) {
+        IdentityRefDataHolderCompleter(final TypeDefinition<?> type, final SchemaContext schemaContext) {
             super(type);
             this.identityMap = getIdentityMap(schemaContext);
         }
index e44041c831d56940190e6a457e2afc0c4c9120e4..2fe85b354e751dc64427a46697d5daaaf1166f6d 100644 (file)
@@ -57,7 +57,8 @@ public class ChoiceReader extends AbstractReader<ChoiceSchemaNode> {
     }
 
     @Override
-    public List<NormalizedNode<?, ?>> readWithContext(final ChoiceSchemaNode choiceNode) throws IOException, ReadingException {
+    public List<NormalizedNode<?, ?>> readWithContext(final ChoiceSchemaNode choiceNode)
+            throws IOException, ReadingException {
         final Map<String, ChoiceCaseNode> availableCases = collectAllCases(choiceNode);
         console.formatLn("Select case for choice %s from: %s", choiceNode.getQName().getLocalName(),
                 formatSet(availableCases.keySet()));
@@ -87,7 +88,8 @@ public class ChoiceReader extends AbstractReader<ChoiceSchemaNode> {
         // leaf without question, since the case was selected
         if (containsOnlyOneEmptyLeaf(selectedCase)) {
             final NormalizedNode<?, ?> newNode = ImmutableLeafNodeBuilder.create()
-                    .withNodeIdentifier(new NodeIdentifier(selectedCase.getChildNodes().iterator().next().getQName())).build();
+                    .withNodeIdentifier(new NodeIdentifier(selectedCase.getChildNodes().iterator().next().getQName()))
+                    .build();
             return Collections.<NormalizedNode<?, ?>>singletonList(newNode);
         }
 
@@ -136,8 +138,8 @@ public class ChoiceReader extends AbstractReader<ChoiceSchemaNode> {
         return new BaseConsoleContext<ChoiceSchemaNode>(schemaNode) {
             @Override
             public List<Completer> getAdditionalCompleters() {
-                return Collections
-                        .<Completer> singletonList(new StringsCompleter(collectAllCases(schemaNode).keySet()));
+                return Collections.<Completer>singletonList(
+                    new StringsCompleter(collectAllCases(schemaNode).keySet()));
             }
         };
     }
index cf7a4002e71095ed1452e4dc91ada8713e9fcaec..2b6fd3b75d22a526d53976d8379afefdea7f5348 100644 (file)
@@ -49,7 +49,8 @@ public class ContainerReader extends AbstractReader<ContainerSchemaNode> {
     }
 
     @Override
-    public List<NormalizedNode<?, ?>> readWithContext(final ContainerSchemaNode containerNode) throws IOException, ReadingException {
+    public List<NormalizedNode<?, ?>> readWithContext(final ContainerSchemaNode containerNode)
+            throws IOException, ReadingException {
         console.formatLn("Submit child nodes for container: %s, %s", containerNode.getQName().getLocalName(),
                 Collections2.transform(containerNode.getChildNodes(), new Function<DataSchemaNode, String>() {
                     @Override
@@ -57,7 +58,8 @@ public class ContainerReader extends AbstractReader<ContainerSchemaNode> {
                         return input.getQName().getLocalName();
                     }
                 }));
-        final DataContainerNodeAttrBuilder<NodeIdentifier, ContainerNode> builder = ImmutableContainerNodeBuilder.create();
+        final DataContainerNodeAttrBuilder<NodeIdentifier, ContainerNode> builder = ImmutableContainerNodeBuilder
+            .create();
         builder.withNodeIdentifier(new NodeIdentifier(containerNode.getQName()));
 
         final ArrayList<NormalizedNode<?, ?>> nodesToAdd = new ArrayList<>();
@@ -77,7 +79,7 @@ public class ContainerReader extends AbstractReader<ContainerSchemaNode> {
             nodesToAdd.addAll(argumentHandlerRegistry.getGenericReader(getSchemaContext(),
                     getReadConfigNode()).read(childNode));
         }
-        return Collections.<NormalizedNode<?, ?>> singletonList(builder.withValue((ArrayList) nodesToAdd).build());
+        return Collections.singletonList(builder.withValue((ArrayList) nodesToAdd).build());
     }
 
     private List<DataSchemaNode> sortChildren(final Set<DataSchemaNode> unsortedNodes) {
index 32f9d7e170646858f7a3ec8555a8d5424cb4b23f..c0b60cf0d9cddcb4d7af665cc462d6f47e6e7adc 100644 (file)
@@ -49,7 +49,8 @@ public class GenericReader extends AbstractReader<DataSchemaNode> {
     }
 
     @Override
-    protected List<NormalizedNode<?, ?>> readWithContext(final DataSchemaNode schemaNode) throws IOException, ReadingException {
+    protected List<NormalizedNode<?, ?>> readWithContext(final DataSchemaNode schemaNode)
+            throws IOException, ReadingException {
         final Optional<Class<? extends Reader<DataSchemaNode>>> customReaderClassOpt = tryGetCustomHandler(schemaNode);
 
         if (customReaderClassOpt.isPresent()) {
@@ -65,7 +66,8 @@ public class GenericReader extends AbstractReader<DataSchemaNode> {
         // TODO reuse instances
     }
 
-    private List<NormalizedNode<?, ?>> readGeneric(final DataSchemaNode schemaNode) throws ReadingException, IOException {
+    private List<NormalizedNode<?, ?>> readGeneric(final DataSchemaNode schemaNode)
+            throws ReadingException, IOException {
         final List<NormalizedNode<?, ?>> newNodes = new ArrayList<>();
         boolean isRedCorrectly = false;
         do {
@@ -116,7 +118,7 @@ public class GenericReader extends AbstractReader<DataSchemaNode> {
                 try {
                     final Class<?> argumentClass = Class.forName(argumentHandlerClassName);
                     // TODO add check before cast
-                    return Optional.<Class<? extends T>> of((Class<? extends T>) argumentClass);
+                    return Optional.of((Class<? extends T>) argumentClass);
                 } catch (final ClassNotFoundException e) {
                     throw new IllegalArgumentException("Unknown custom reader class " + argumentHandlerClassName
                             + " for: " + dataSchemaNode.getQName());
index bccc84f1d18173715d9b06c3152edac937bcbf69..eea054f83f0677fafe28296bdf82b42aefd0c1c9 100644 (file)
@@ -23,11 +23,11 @@ import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
 class LeafListEntryReader extends BasicDataHolderReader<LeafListSchemaNode> implements
         GenericListEntryReader<LeafListSchemaNode> {
 
-    public LeafListEntryReader(final ConsoleIO console, final SchemaContext schemaContext) {
+    LeafListEntryReader(final ConsoleIO console, final SchemaContext schemaContext) {
         super(console, schemaContext);
     }
 
-    public LeafListEntryReader(final ConsoleIO console, final SchemaContext schemaContext, final boolean readConfigNode) {
+    LeafListEntryReader(final ConsoleIO console, final SchemaContext schemaContext, final boolean readConfigNode) {
         super(console, schemaContext, readConfigNode);
     }
 
@@ -47,7 +47,7 @@ class LeafListEntryReader extends BasicDataHolderReader<LeafListSchemaNode> impl
 
             @Override
             protected List<Completer> getAdditionalCompleters() {
-                return Lists.<Completer> newArrayList(getBaseCompleter(getDataSchemaNode()));
+                return Lists.newArrayList(getBaseCompleter(getDataSchemaNode()));
             }
         };
     }
index 706b16c152ff851171184b7f70bebbd218a0577c..87d9749a516d3e5309cf2a060309b6d8898ad937 100644 (file)
@@ -39,7 +39,7 @@ public class LeafReader extends BasicDataHolderReader<LeafSchemaNode> {
         return new BaseConsoleContext<LeafSchemaNode>(schemaNode) {
             @Override
             public List<Completer> getAdditionalCompleters() {
-                final List<Completer> completers = Lists.<Completer> newArrayList(getBaseCompleter(schemaNode));
+                final List<Completer> completers = Lists.newArrayList(getBaseCompleter(schemaNode));
                 final Optional<String> defaultValue = getDefaultValue(schemaNode);
                 if (defaultValue.isPresent()) {
                     completers.add(new StringsCompleter(defaultValue.get()));
index 7a8930429eb6fea2bd3d26db54af7aba8a563805..71170c14a24db310f333ba77e1b6e61a75ec63bc 100644 (file)
@@ -44,20 +44,21 @@ class ListEntryReader extends AbstractReader<ListSchemaNode> implements GenericL
 
     private final CommandArgHandlerRegistry argumentHandlerRegistry;
 
-    public ListEntryReader(final ConsoleIO console, final CommandArgHandlerRegistry argumentHandlerRegistry,
+    ListEntryReader(final ConsoleIO console, final CommandArgHandlerRegistry argumentHandlerRegistry,
             final SchemaContext schemaContext) {
         super(console, schemaContext);
         this.argumentHandlerRegistry = argumentHandlerRegistry;
     }
 
-    public ListEntryReader(final ConsoleIO console, final CommandArgHandlerRegistry argumentHandlerRegistry,
-            final SchemaContext schemaContext, final boolean readConfigNode) {
+    ListEntryReader(final ConsoleIO console, final CommandArgHandlerRegistry argumentHandlerRegistry,
+                    final SchemaContext schemaContext, final boolean readConfigNode) {
         super(console, schemaContext, readConfigNode);
         this.argumentHandlerRegistry = argumentHandlerRegistry;
     }
 
     @Override
-    public List<NormalizedNode<?, ?>> readWithContext(final ListSchemaNode listNode) throws IOException, ReadingException {
+    public List<NormalizedNode<?, ?>> readWithContext(final ListSchemaNode listNode)
+            throws IOException, ReadingException {
         console.formatLn("Submit child nodes for list entry: %s, %s", listNode.getQName().getLocalName(),
                 Collections2.transform(listNode.getChildNodes(), new Function<DataSchemaNode, String>() {
                     @Override
@@ -123,8 +124,8 @@ class ListEntryReader extends AbstractReader<ListSchemaNode> implements GenericL
         return newNodes;
     }
 
-    private List<NormalizedNode<?, ?>> readMandatoryNotKeys(final Set<DataSchemaNode> mandatoryNotKeys) throws ReadingException,
-            IOException {
+    private List<NormalizedNode<?, ?>> readMandatoryNotKeys(final Set<DataSchemaNode> mandatoryNotKeys)
+            throws ReadingException, IOException {
         final List<NormalizedNode<?, ?>> newNodes = new ArrayList<>();
         console.writeLn("Reading mandatory not keys nodes:");
 
index e558c56f2d5d467ccc6fcbb7d724b0d633c10c3a..cabb217b83e80ea449d4dfb8c429588b86587fa7 100644 (file)
@@ -23,8 +23,8 @@ class SeparatedNodes {
     private final Set<DataSchemaNode> mandatoryNotKey;
     private final Set<DataSchemaNode> otherNodes;
 
-    public SeparatedNodes(final Set<DataSchemaNode> keyNodes, final Set<DataSchemaNode> mandatoryNotKey,
-            final Set<DataSchemaNode> otherNodes) {
+    private SeparatedNodes(final Set<DataSchemaNode> keyNodes, final Set<DataSchemaNode> mandatoryNotKey,
+                           final Set<DataSchemaNode> otherNodes) {
         this.keyNodes = keyNodes;
         this.mandatoryNotKey = mandatoryNotKey;
         this.otherNodes = otherNodes;
@@ -46,7 +46,8 @@ class SeparatedNodes {
         return separateNodes(dataNodeContainer, false);
     }
 
-    static SeparatedNodes separateNodes(final DataNodeContainer dataNodeContainer, final boolean removeConfigFalseNodes) {
+    static SeparatedNodes separateNodes(final DataNodeContainer dataNodeContainer,
+                                        final boolean removeConfigFalseNodes) {
         final Set<DataSchemaNode> keys = new HashSet<>();
         final Set<DataSchemaNode> mandatoryNotKeys = new HashSet<>();
         final Set<DataSchemaNode> others = new HashSet<>();
index 7575a4b0b2f272596771511bc3b7cbba62cb6f66..5a899b5983df59105967543740db8ad5fd88e1ab 100644 (file)
@@ -32,7 +32,7 @@ class UnionTypeReader {
 
     private final ConsoleIO console;
 
-    public UnionTypeReader(final ConsoleIO console) {
+    UnionTypeReader(final ConsoleIO console) {
         this.console = console;
     }
 
@@ -50,9 +50,10 @@ class UnionTypeReader {
             }
             final TypeDefinition<?> value = mapping.get(rawValue);
             if (value != null) {
-                return Optional.<TypeDefinition<?>> of(value);
+                return Optional.of(value);
             } else {
-                final String message = String.format("Incorrect type (%s) was specified for union type definition", rawValue);
+                final String message = String.format(
+                    "Incorrect type (%s) was specified for union type definition", rawValue);
                 LOG.error(message);
                 throw new ReadingException(message);
             }
@@ -70,7 +71,7 @@ class UnionTypeReader {
         private final TypeDefinition<?> typeDef;
         private final Map<String, TypeDefinition<?>> menuItemsToTypeDefinitions = new HashMap<>();
 
-        public UnionConsoleContext(final TypeDefinition<?> typeDef) {
+        UnionConsoleContext(final TypeDefinition<?> typeDef) {
             this.typeDef = typeDef;
         }
 
@@ -83,7 +84,7 @@ class UnionTypeReader {
         public Completer getCompleter() {
             List<TypeDefinition<?>> subtypesForMenu = resolveSubtypesFrom(typeDef);
             if (subtypesForMenu.isEmpty()) {
-                subtypesForMenu = Collections.<TypeDefinition<?>> singletonList(typeDef);
+                subtypesForMenu = Collections.singletonList(typeDef);
             }
             final Collection<String> menuItems = toMenuItem(subtypesForMenu);
             return new AggregateCompleter(new StringsCompleter(menuItems), new StringsCompleter(IOUtil.SKIP));
@@ -104,7 +105,6 @@ class UnionTypeReader {
         }
 
         /**
-         *
          * If union type is found in potentialEndTypeCandidate as subtype then
          * it these subtypes become candidates.
          *
index 09564011e2b83b9b9c4188b018de07777facbebb..e7079304c68fc6e6b7109450003ba954a485e821 100644 (file)
@@ -11,8 +11,8 @@ public class WriteException extends Exception {
 
     private static final long serialVersionUID = 8401242676753560336L;
 
-    public WriteException(final String msg, final Exception e) {
-        super(msg, e);
+    public WriteException(final String msg, final Exception exc) {
+        super(msg, exc);
     }
 
     public WriteException(final String msg) {
index ad6cfa7d2720b5969287851374a6dc899e4983f5..6a20a30fcf6eb0bd8f391b5e24882f6e619b806d 100644 (file)
@@ -12,7 +12,7 @@ import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
 
 /**
- * Generic handler(writer) of output elements for commands
+ * Generic handler(writer) of output elements for commands.
  */
 public interface Writer<T extends DataSchemaNode> {
 
index 11957e0ad67ba82e7398782ca62b6ab7de0270da..05cca30c3d3aedc35bab4ee97c4672df1dd083c9 100644 (file)
@@ -36,20 +36,25 @@ public class DataWriter extends AbstractWriter<DataSchemaNode> {
     }
 
     @Override
-    protected void writeInner(final DataSchemaNode dataSchemaNode, final List<NormalizedNode<?, ?>> dataNodes) throws IOException, WriteException {
+    protected void writeInner(final DataSchemaNode dataSchemaNode, final List<NormalizedNode<?, ?>> dataNodes)
+            throws IOException, WriteException {
         Preconditions.checkArgument(dataNodes.size() == 1, "Expected only 1 element for data node");
         final NormalizedNode<?, ?> dataNode = dataNodes.get(0);
-        Preconditions.checkArgument(dataNode instanceof ContainerNode, "Unexpected node type: %s, should be %s", dataNode, ContainerNode.class);
+        Preconditions.checkArgument(dataNode instanceof ContainerNode, "Unexpected node type: %s, should be %s",
+            dataNode, ContainerNode.class);
 
         StringBuilder output = new StringBuilder();
-        out.increaseIndent().addStringWithIndent(output, dataSchemaNode.getQName().getLocalName()).openComposite(output);
+        out.increaseIndent().addStringWithIndent(
+            output, dataSchemaNode.getQName().getLocalName()).openComposite(output);
         console.writeLn(output.toString());
 
-        for (final Object oChildNode : ((DataContainerNode) dataNode).getValue()) {
-            final NormalizedNode<?, ?> childNode = (NormalizedNode<?, ?>) oChildNode;
-            final Optional<DataSchemaNode> schemaNode = XmlDocumentUtils.findFirstSchema(childNode.getNodeType(), remoteSchemaContext.getDataDefinitions());
-            Preconditions.checkState(schemaNode.isPresent(), "Unknown data node %s, not defined in schema", childNode.getNodeType());
-            new NormalizedNodeWriter(console, out).write(schemaNode.get(), Collections.<NormalizedNode<?, ?>>singletonList(childNode));
+        for (final Object childNodeObject : ((DataContainerNode) dataNode).getValue()) {
+            final NormalizedNode<?, ?> childNode = (NormalizedNode<?, ?>) childNodeObject;
+            final Optional<DataSchemaNode> schemaNode = XmlDocumentUtils.findFirstSchema(childNode.getNodeType(),
+                remoteSchemaContext.getDataDefinitions());
+            Preconditions.checkState(schemaNode.isPresent(), "Unknown data node %s, not defined in schema",
+                childNode.getNodeType());
+            new NormalizedNodeWriter(console, out).write(schemaNode.get(), Collections.singletonList(childNode));
         }
 
         output = new StringBuilder();
index 2296fe09eb75c2f7d357a07bee22cc0064860fa8..5ec1f9817c85b70b5f5949b90b7e045591c51fb0 100644 (file)
@@ -32,6 +32,6 @@ public abstract class AbstractWriter<T extends DataSchemaNode> implements Writer
         }
     }
 
-    protected abstract void writeInner(final T dataSchemaNode, final List<NormalizedNode<?, ?>> dataNodes) throws IOException,
-            WriteException;
+    protected abstract void writeInner(final T dataSchemaNode, final List<NormalizedNode<?, ?>> dataNodes)
+        throws IOException, WriteException;
 }
index 6968c9bf6ec24000f438b07558fbeeb62e9885b0..4509f1992b5e27391faea9352aa73d98b0072dba 100644 (file)
@@ -14,6 +14,7 @@ import org.opendaylight.yangtools.yang.data.api.schema.AugmentationNode;
 import org.opendaylight.yangtools.yang.data.impl.schema.transform.base.serializer.AugmentationNodeBaseSerializer;
 import org.opendaylight.yangtools.yang.data.impl.schema.transform.base.serializer.NodeSerializerDispatcher;
 import org.opendaylight.yangtools.yang.model.api.AugmentationSchema;
+
 final class AugmentationNodeCliSerializer extends AugmentationNodeBaseSerializer<String> {
 
     private final NodeSerializerDispatcher<String> dispatcher;
index 9fe8f9c1344acac729de10af3578c669722581ff..5c2bd170c7501a9f12d8406ec8e440b5fff45b83 100644 (file)
@@ -85,7 +85,8 @@ public final class CliOutputFromNormalizedNodeSerializerFactory implements FromN
     }
 
     @Override
-    public FromNormalizedNodeSerializer<String, LeafSetEntryNode<?>, LeafListSchemaNode> getLeafSetEntryNodeSerializer() {
+    public FromNormalizedNodeSerializer<
+            String, LeafSetEntryNode<?>, LeafListSchemaNode> getLeafSetEntryNodeSerializer() {
         return leafSetEntryNodeSerializer;
     }
 
index 54ebdc90eb14ddab661fe94e1d99d3e9ba2d6c5c..ee1e560279236392323ae0cec2f7102e1d357519 100644 (file)
@@ -16,7 +16,7 @@ final class LeafSetEntryNodeCliSerializer extends LeafSetEntryNodeBaseSerializer
 
     private final OutFormatter out;
 
-    public LeafSetEntryNodeCliSerializer(final OutFormatter out) {
+    LeafSetEntryNodeCliSerializer(final OutFormatter out) {
         this.out = out;
     }
 
index 6d3398277500d7c0c72034364ba05afafe101659..2d7778af654f9202c9a1d029698aab59915108f2 100644 (file)
@@ -55,13 +55,13 @@ final class MapEntryNodeCliSerializer extends ListEntryNodeBaseSerializer<String
             return;
         }
 
-        int i = 0;
+        int index = 0;
         output.append(" [");
-        for (final Entry<QName, Object> qNameObjectEntry : keyValues.entrySet()) {
-            output.append(qNameObjectEntry.getKey().getLocalName());
+        for (final Entry<QName, Object> keys : keyValues.entrySet()) {
+            output.append(keys.getKey().getLocalName());
             output.append("=");
-            output.append(qNameObjectEntry.getValue().toString());
-            if (++i != keyValues.size()) {
+            output.append(keys.getValue().toString());
+            if (++index != keyValues.size()) {
                 output.append(", ");
             }
         }
index 33d816f1d20b9f71915692afcbfa0cb2cf6d7233..4e671e9643f7d6cba1d7335b583bee1cc3b49713 100644 (file)
@@ -31,8 +31,8 @@ public class NormalizedNodeWriter extends AbstractWriter<DataSchemaNode> {
         this.out = out;
     }
 
-    public void writeInner(final DataSchemaNode dataSchemaNode, final List<NormalizedNode<?, ?>> dataNodes) throws WriteException,
-            IOException {
+    public void writeInner(final DataSchemaNode dataSchemaNode, final List<NormalizedNode<?, ?>> dataNodes)
+            throws WriteException, IOException {
         //Preconditions.checkState(dataNodes.size() == 1);
         // TODO - add getDispatcher method to CnSnToNormalizedNodeParserFactory
         // to be able call dispatchChildElement
@@ -46,10 +46,11 @@ public class NormalizedNodeWriter extends AbstractWriter<DataSchemaNode> {
 
     private String serializeToCliOutput(final NormalizedNode<?, ?> dataContainerChild,
             final DataSchemaNode childSchema) {
-        final CliOutputFromNormalizedNodeSerializerFactory factorySerialization = CliOutputFromNormalizedNodeSerializerFactory
-                .getInstance(out, DomUtils.defaultValueCodecProvider());
+        final CliOutputFromNormalizedNodeSerializerFactory factorySerialization =
+            CliOutputFromNormalizedNodeSerializerFactory.getInstance(out, DomUtils.defaultValueCodecProvider());
         final NodeSerializerDispatcher<String> dispatcher = factorySerialization.getDispatcher();
-        final Iterable<String> result = dispatcher.dispatchChildElement(childSchema, (DataContainerChild<?, ?>) dataContainerChild);
+        final Iterable<String> result = dispatcher.dispatchChildElement(childSchema,
+            (DataContainerChild<?, ?>) dataContainerChild);
 
         if (result == null) {
             return "";
index a3dcac085e1f47a5b6fca61802e0fcaaec7754dc..1e4c018571e466bb465b25595ab49300d38fa03e 100644 (file)
@@ -20,8 +20,8 @@ public class ConsoleIOTestImpl extends ConsoleIOImpl {
     String lastMessage;
     private final List<ValueForMessage> valuesForMessages;
 
-    public ConsoleIOTestImpl(final Map<String, Deque<String>> inputValues, final List<ValueForMessage> valuesForMessages)
-            throws IOException {
+    public ConsoleIOTestImpl(final Map<String, Deque<String>> inputValues,
+                             final List<ValueForMessage> valuesForMessages) throws IOException {
         super();
         this.inputValues = inputValues;
         this.valuesForMessages = valuesForMessages;
similarity index 89%
rename from netconf/tools/netconf-cli/src/test/java/org/opendaylight/netconf/cli/ValueForMessages.java
rename to netconf/tools/netconf-cli/src/test/java/org/opendaylight/netconf/cli/ValueForMessage.java
index 9bb5e656dd5135c802bb3b1ec38a369f4e7f5be0..d4c97bd34ba4881a540b7653fc34c34edc60321d 100644 (file)
@@ -14,7 +14,7 @@ class ValueForMessage {
     List<String> messageKeyWords;
     String value;
 
-    public ValueForMessage(final String value, final String... messageKeyWords) {
+    ValueForMessage(final String value, final String... messageKeyWords) {
         this.messageKeyWords = Arrays.asList(messageKeyWords);
         this.value = value;
     }