Add final where needed 79/45579/2
authormiroslav.kovac <miroslav.kovac@pantheon.tech>
Tue, 13 Sep 2016 15:41:34 +0000 (17:41 +0200)
committerMiroslav Kovac <miroslav.kovac@pantheon.tech>
Wed, 21 Sep 2016 13:08:44 +0000 (13:08 +0000)
Change-Id: I4d0856a611f4fea5a9994fd375454d3fc14998b6
Signed-off-by: miroslav.kovac <miroslav.kovac@pantheon.tech>
restconf/sal-rest-docgen/src/main/java/org/opendaylight/netconf/sal/rest/doc/DocProvider.java
restconf/sal-rest-docgen/src/main/java/org/opendaylight/netconf/sal/rest/doc/impl/ApiDocGenerator.java
restconf/sal-rest-docgen/src/main/java/org/opendaylight/netconf/sal/rest/doc/impl/ApiDocServiceImpl.java
restconf/sal-rest-docgen/src/main/java/org/opendaylight/netconf/sal/rest/doc/impl/BaseYangSwaggerGenerator.java
restconf/sal-rest-docgen/src/main/java/org/opendaylight/netconf/sal/rest/doc/impl/ModelGenerator.java
restconf/sal-rest-docgen/src/main/java/org/opendaylight/netconf/sal/rest/doc/jaxrs/JaxbContextResolver.java
restconf/sal-rest-docgen/src/main/java/org/opendaylight/netconf/sal/rest/doc/model/builder/OperationBuilder.java
restconf/sal-rest-docgen/src/main/java/org/opendaylight/netconf/sal/rest/doc/mountpoints/MountPointSwagger.java
restconf/sal-rest-docgen/src/main/java/org/opendaylight/netconf/sal/rest/doc/util/RestDocgenUtil.java

index aec9a6f02ce947d5f4f267241aec26c3af9810b5..2541dc68cf3a07f0e38d74522a7a63c63430e7f8 100644 (file)
@@ -44,13 +44,13 @@ public class DocProvider implements BundleActivator, ServiceTrackerCustomizer<Br
     }
 
     @Override
-    public void onSessionInitiated(Broker.ProviderSession providerSession) {
-        SchemaService schemaService = providerSession.getService(SchemaService.class);
+    public void onSessionInitiated(final Broker.ProviderSession providerSession) {
+        final SchemaService schemaService = providerSession.getService(SchemaService.class);
         ApiDocGenerator.getInstance().setSchemaService(schemaService);
 
-        DOMMountPointService mountService = providerSession
+        final DOMMountPointService mountService = providerSession
                 .getService(DOMMountPointService.class);
-        ListenerRegistration<MountProvisionListener> registration = mountService
+        final ListenerRegistration<MountProvisionListener> registration = mountService
                 .registerProvisionListener(MountPointSwagger.getInstance());
         MountPointSwagger.getInstance().setGlobalSchema(schemaService);
         synchronized (toClose) {
@@ -67,14 +67,14 @@ public class DocProvider implements BundleActivator, ServiceTrackerCustomizer<Br
     }
 
     @Override
-    public void start(BundleContext context) throws Exception {
+    public void start(final BundleContext context) throws Exception {
         bundleContext = context;
         brokerServiceTracker = new ServiceTracker<>(context, Broker.class, this);
         brokerServiceTracker.open();
     }
 
     @Override
-    public void stop(BundleContext context) throws Exception {
+    public void stop(final BundleContext context) throws Exception {
         if (brokerServiceTracker != null) {
             brokerServiceTracker.close();
         }
@@ -84,31 +84,31 @@ public class DocProvider implements BundleActivator, ServiceTrackerCustomizer<Br
         }
 
         synchronized (toClose) {
-            for (AutoCloseable close : toClose) {
+            for (final AutoCloseable close : toClose) {
                 close.close();
             }
         }
     }
 
     @Override
-    public Broker addingService(ServiceReference<Broker> reference) {
-        Broker broker = bundleContext.getService(reference);
+    public Broker addingService(final ServiceReference<Broker> reference) {
+        final Broker broker = bundleContext.getService(reference);
         session = broker.registerProvider(this, bundleContext);
         return broker;
     }
 
     @Override
-    public void modifiedService(ServiceReference<Broker> reference, Broker service) {
+    public void modifiedService(final ServiceReference<Broker> reference, final Broker service) {
         if (session != null) {
             session.close();
         }
 
-        Broker broker = bundleContext.getService(reference);
+        final Broker broker = bundleContext.getService(reference);
         session = broker.registerProvider(this, bundleContext);
     }
 
     @Override
-    public void removedService(ServiceReference<Broker> reference, Broker service) {
+    public void removedService(final ServiceReference<Broker> reference, final Broker service) {
         bundleContext.ungetService(reference);
     }
 }
index 59cbba0719489859e6bcd4a1bf122d7ea34dbad9..f78d61951eeea0d94d3f4a4103e2566016c43c16 100644 (file)
@@ -23,15 +23,15 @@ public class ApiDocGenerator extends BaseYangSwaggerGenerator {
     private static final ApiDocGenerator INSTANCE = new ApiDocGenerator();
     private SchemaService schemaService;
 
-    public ResourceList getResourceListing(UriInfo uriInfo) {
+    public ResourceList getResourceListing(final UriInfo uriInfo) {
         Preconditions.checkState(schemaService != null);
-        SchemaContext schemaContext = schemaService.getGlobalContext();
+        final SchemaContext schemaContext = schemaService.getGlobalContext();
         Preconditions.checkState(schemaContext != null);
         return super.getResourceListing(uriInfo, schemaContext, "");
     }
 
-    public ApiDeclaration getApiDeclaration(String module, String revision, UriInfo uriInfo) {
-        SchemaContext schemaContext = schemaService.getGlobalContext();
+    public ApiDeclaration getApiDeclaration(final String module, final String revision, final UriInfo uriInfo) {
+        final SchemaContext schemaContext = schemaService.getGlobalContext();
         Preconditions.checkState(schemaContext != null);
         return super.getApiDeclaration(module, revision, uriInfo, schemaContext, "");
     }
@@ -43,7 +43,7 @@ public class ApiDocGenerator extends BaseYangSwaggerGenerator {
         return INSTANCE;
     }
 
-    public void setSchemaService(SchemaService schemaService) {
+    public void setSchemaService(final SchemaService schemaService) {
         this.schemaService = schemaService;
     }
 }
index d50eaadac40a87b8ea921ae07157095d32e0004b..dba66b416e82badc1f7084f8446e57a0e51432bf 100644 (file)
@@ -44,9 +44,9 @@ public class ApiDocServiceImpl implements ApiDocService {
      * served by <code> getDocByModule()</code> method.
      */
     @Override
-    public synchronized Response getRootDoc(UriInfo uriInfo) {
-        ApiDocGenerator generator = ApiDocGenerator.getInstance();
-        ResourceList rootDoc = generator.getResourceListing(uriInfo);
+    public synchronized Response getRootDoc(final UriInfo uriInfo) {
+        final ApiDocGenerator generator = ApiDocGenerator.getInstance();
+        final ResourceList rootDoc = generator.getResourceListing(uriInfo);
 
         return Response.ok(rootDoc).build();
     }
@@ -55,10 +55,10 @@ public class ApiDocServiceImpl implements ApiDocService {
      * Generates Swagger compliant document listing APIs for module.
      */
     @Override
-    public synchronized Response getDocByModule(String module, String revision, UriInfo uriInfo) {
-        ApiDocGenerator generator = ApiDocGenerator.getInstance();
+    public synchronized Response getDocByModule(final String module, final String revision, final UriInfo uriInfo) {
+        final ApiDocGenerator generator = ApiDocGenerator.getInstance();
 
-        ApiDeclaration doc = generator.getApiDeclaration(module, revision, uriInfo);
+        final ApiDeclaration doc = generator.getApiDeclaration(module, revision, uriInfo);
         return Response.ok(doc).build();
     }
 
@@ -66,19 +66,19 @@ public class ApiDocServiceImpl implements ApiDocService {
      * Redirects to embedded swagger ui.
      */
     @Override
-    public synchronized Response getApiExplorer(UriInfo uriInfo) {
+    public synchronized Response getApiExplorer(final UriInfo uriInfo) {
         return Response
                 .seeOther(uriInfo.getBaseUriBuilder().path("../explorer/index.html").build())
                 .build();
     }
 
     @Override
-    public synchronized Response getListOfMounts(UriInfo uriInfo) {
-        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+    public synchronized Response getListOfMounts(final UriInfo uriInfo) {
+        final ByteArrayOutputStream baos = new ByteArrayOutputStream();
         try (OutputStreamWriter streamWriter = new OutputStreamWriter(baos)) {
-            JSONWriter writer = new JSONWriter(streamWriter);
+            final JSONWriter writer = new JSONWriter(streamWriter);
             writer.array();
-            for (Entry<String, Long> entry : MountPointSwagger.getInstance()
+            for (final Entry<String, Long> entry : MountPointSwagger.getInstance()
                     .getInstanceIdentifiers().entrySet()) {
                 writer.object();
                 writer.key("instance").value(entry.getKey());
@@ -86,23 +86,23 @@ public class ApiDocServiceImpl implements ApiDocService {
                 writer.endObject();
             }
             writer.endArray();
-        } catch (Exception e) {
+        } catch (final Exception e) {
             return Response.status(500).entity(e.getMessage()).build();
         }
         return Response.status(200).entity(baos.toString()).build();
     }
 
     @Override
-    public synchronized Response getMountRootDoc(String instanceNum, UriInfo uriInfo) {
-        ResourceList resourceList = MountPointSwagger.getInstance().getResourceList(uriInfo,
+    public synchronized Response getMountRootDoc(final String instanceNum, final UriInfo uriInfo) {
+        final ResourceList resourceList = MountPointSwagger.getInstance().getResourceList(uriInfo,
                 Long.parseLong(instanceNum));
         return Response.ok(resourceList).build();
     }
 
     @Override
-    public synchronized Response getMountDocByModule(String instanceNum, String module,
-            String revision, UriInfo uriInfo) {
-        ApiDeclaration api = MountPointSwagger.getInstance().getMountPointApi(uriInfo,
+    public synchronized Response getMountDocByModule(final String instanceNum, final String module,
+                                                     final String revision, final UriInfo uriInfo) {
+        final ApiDeclaration api = MountPointSwagger.getInstance().getMountPointApi(uriInfo,
                 Long.parseLong(instanceNum), module, revision);
         return Response.ok(api).build();
     }
index 7696ce6732baa6b4b2fc9756290fc5eeeeff75c0..647e88fa900e2d1d723b5149d423d814376bbf58 100644 (file)
@@ -78,21 +78,21 @@ public class BaseYangSwaggerGenerator {
     /**
      * Return list of modules converted to swagger compliant resource list.
      */
-    public ResourceList getResourceListing(UriInfo uriInfo, SchemaContext schemaContext, String context) {
+    public ResourceList getResourceListing(final UriInfo uriInfo, final SchemaContext schemaContext, final String context) {
 
-        ResourceList resourceList = createResourceList();
+        final ResourceList resourceList = createResourceList();
 
-        Set<Module> modules = getSortedModules(schemaContext);
+        final Set<Module> modules = getSortedModules(schemaContext);
 
-        List<Resource> resources = new ArrayList<>(modules.size());
+        final List<Resource> resources = new ArrayList<>(modules.size());
 
         LOG.info("Modules found [{}]", modules.size());
 
-        for (Module module : modules) {
-            String revisionString = SIMPLE_DATE_FORMAT.format(module.getRevision());
-            Resource resource = new Resource();
+        for (final Module module : modules) {
+            final String revisionString = SIMPLE_DATE_FORMAT.format(module.getRevision());
+            final Resource resource = new Resource();
             LOG.debug("Working on [{},{}]...", module.getName(), revisionString);
-            ApiDeclaration doc = getApiDeclaration(module.getName(), revisionString, uriInfo, schemaContext, context);
+            final ApiDeclaration doc = getApiDeclaration(module.getName(), revisionString, uriInfo, schemaContext, context);
 
             if (doc != null) {
                 resource.setPath(generatePath(uriInfo, module.getName(), revisionString));
@@ -108,30 +108,30 @@ public class BaseYangSwaggerGenerator {
     }
 
     protected ResourceList createResourceList() {
-        ResourceList resourceList = new ResourceList();
+        final ResourceList resourceList = new ResourceList();
         resourceList.setApiVersion(API_VERSION);
         resourceList.setSwaggerVersion(SWAGGER_VERSION);
         return resourceList;
     }
 
-    protected String generatePath(UriInfo uriInfo, String name, String revision) {
-        URI uri = uriInfo.getRequestUriBuilder().path(generateCacheKey(name, revision)).build();
+    protected String generatePath(final UriInfo uriInfo, final String name, final String revision) {
+        final URI uri = uriInfo.getRequestUriBuilder().path(generateCacheKey(name, revision)).build();
         return uri.toASCIIString();
     }
 
-    public ApiDeclaration getApiDeclaration(String moduleName, String revision, UriInfo uriInfo, SchemaContext schemaContext, String context) {
+    public ApiDeclaration getApiDeclaration(final String moduleName, final String revision, final UriInfo uriInfo, final SchemaContext schemaContext, final String context) {
         Date rev = null;
 
         try {
             if (revision != null && !revision.equals("0000-00-00")) {
                 rev = SIMPLE_DATE_FORMAT.parse(revision);
             }
-        } catch (ParseException e) {
+        } catch (final ParseException e) {
             throw new IllegalArgumentException(e);
         }
 
         if (rev != null) {
-            Calendar cal = new GregorianCalendar();
+            final Calendar cal = new GregorianCalendar();
 
             cal.setTime(rev);
 
@@ -140,44 +140,44 @@ public class BaseYangSwaggerGenerator {
             }
         }
 
-        Module module = schemaContext.findModuleByName(moduleName, rev);
+        final Module module = schemaContext.findModuleByName(moduleName, rev);
         Preconditions.checkArgument(module != null,
                 "Could not find module by name,revision: " + moduleName + "," + revision);
 
         return getApiDeclaration(module, rev, uriInfo, context, schemaContext);
     }
 
-    public ApiDeclaration getApiDeclaration(Module module, Date revision, UriInfo uriInfo, String context, SchemaContext schemaContext) {
-        String basePath = createBasePathFromUriInfo(uriInfo);
+    public ApiDeclaration getApiDeclaration(final Module module, final Date revision, final UriInfo uriInfo, final String context, final SchemaContext schemaContext) {
+        final String basePath = createBasePathFromUriInfo(uriInfo);
 
-        ApiDeclaration doc = getSwaggerDocSpec(module, basePath, context, schemaContext);
+        final ApiDeclaration doc = getSwaggerDocSpec(module, basePath, context, schemaContext);
         if (doc != null) {
             return doc;
         }
         return null;
     }
 
-    protected String createBasePathFromUriInfo(UriInfo uriInfo) {
+    protected String createBasePathFromUriInfo(final UriInfo uriInfo) {
         String portPart = "";
-        int port = uriInfo.getBaseUri().getPort();
+        final int port = uriInfo.getBaseUri().getPort();
         if (port != -1) {
             portPart = ":" + port;
         }
-        String basePath = new StringBuilder(uriInfo.getBaseUri().getScheme()).append("://")
+        final String basePath = new StringBuilder(uriInfo.getBaseUri().getScheme()).append("://")
                 .append(uriInfo.getBaseUri().getHost()).append(portPart).append("/").append(RESTCONF_CONTEXT_ROOT)
                 .toString();
         return basePath;
     }
 
-    public ApiDeclaration getSwaggerDocSpec(Module m, String basePath, String context, SchemaContext schemaContext) {
-        ApiDeclaration doc = createApiDeclaration(basePath);
+    public ApiDeclaration getSwaggerDocSpec(final Module m, final String basePath, final String context, final SchemaContext schemaContext) {
+        final ApiDeclaration doc = createApiDeclaration(basePath);
 
-        List<Api> apis = new ArrayList<>();
+        final List<Api> apis = new ArrayList<>();
         boolean hasAddRootPostLink = false;
 
-        Collection<DataSchemaNode> dataSchemaNodes = m.getChildNodes();
+        final Collection<DataSchemaNode> dataSchemaNodes = m.getChildNodes();
         LOG.debug("child nodes size [{}]", dataSchemaNodes.size());
-        for (DataSchemaNode node : dataSchemaNodes) {
+        for (final DataSchemaNode node : dataSchemaNodes) {
             if ((node instanceof ListSchemaNode) || (node instanceof ContainerSchemaNode)) {
                 LOG.debug("Is Configuration node [{}] [{}]", node.isConfiguration(), node.getQName().getLocalName());
 
@@ -210,9 +210,9 @@ public class BaseYangSwaggerGenerator {
             }
         }
 
-        Set<RpcDefinition> rpcs = m.getRpcs();
-        for (RpcDefinition rpcDefinition : rpcs) {
-            String resourcePath = getDataStorePath("/operations/", context);
+        final Set<RpcDefinition> rpcs = m.getRpcs();
+        for (final RpcDefinition rpcDefinition : rpcs) {
+            final String resourcePath = getDataStorePath("/operations/", context);
             addRpcs(rpcDefinition, apis, resourcePath, schemaContext);
         }
 
@@ -248,8 +248,8 @@ public class BaseYangSwaggerGenerator {
         }
     }
 
-    protected ApiDeclaration createApiDeclaration(String basePath) {
-        ApiDeclaration doc = new ApiDeclaration();
+    protected ApiDeclaration createApiDeclaration(final String basePath) {
+        final ApiDeclaration doc = new ApiDeclaration();
         doc.setApiVersion(API_VERSION);
         doc.setSwaggerVersion(SWAGGER_VERSION);
         doc.setBasePath(basePath);
@@ -257,33 +257,33 @@ public class BaseYangSwaggerGenerator {
         return doc;
     }
 
-    protected String getDataStorePath(String dataStore, String context) {
+    protected String getDataStorePath(final String dataStore, final String context) {
         return dataStore + context;
     }
 
-    private String generateCacheKey(String module, String revision) {
+    private String generateCacheKey(final String module, final String revision) {
         return module + "(" + revision + ")";
     }
 
-    private void addApis(DataSchemaNode node, List<Api> apis, String parentPath, List<Parameter> parentPathParams, SchemaContext schemaContext,
-            boolean addConfigApi) {
+    private void addApis(final DataSchemaNode node, final List<Api> apis, final String parentPath, final List<Parameter> parentPathParams, final SchemaContext schemaContext,
+                         final boolean addConfigApi) {
 
-        Api api = new Api();
-        List<Parameter> pathParams = new ArrayList<>(parentPathParams);
+        final Api api = new Api();
+        final List<Parameter> pathParams = new ArrayList<>(parentPathParams);
 
-        String resourcePath = parentPath + createPath(node, pathParams, schemaContext) + "/";
+        final String resourcePath = parentPath + createPath(node, pathParams, schemaContext) + "/";
         LOG.debug("Adding path: [{}]", resourcePath);
         api.setPath(resourcePath);
 
         Iterable<DataSchemaNode> childSchemaNodes = Collections.<DataSchemaNode>emptySet();
         if ((node instanceof ListSchemaNode) || (node instanceof ContainerSchemaNode)) {
-            DataNodeContainer dataNodeContainer = (DataNodeContainer) node;
+            final DataNodeContainer dataNodeContainer = (DataNodeContainer) node;
             childSchemaNodes = dataNodeContainer.getChildNodes();
         }
         api.setOperations(operation(node, pathParams, addConfigApi, childSchemaNodes));
         apis.add(api);
 
-        for (DataSchemaNode childNode : childSchemaNodes) {
+        for (final DataSchemaNode childNode : childSchemaNodes) {
             if (childNode instanceof ListSchemaNode || childNode instanceof ContainerSchemaNode) {
                 // keep config and operation attributes separate.
                 if (childNode.isConfiguration() == addConfigApi) {
@@ -295,7 +295,7 @@ public class BaseYangSwaggerGenerator {
     }
 
     private boolean containsListOrContainer(final Iterable<DataSchemaNode> nodes) {
-        for (DataSchemaNode child : nodes) {
+        for (final DataSchemaNode child : nodes) {
             if (child instanceof ListSchemaNode || child instanceof ContainerSchemaNode) {
                 return true;
             }
@@ -303,18 +303,18 @@ public class BaseYangSwaggerGenerator {
         return false;
     }
 
-    private List<Operation> operation(DataSchemaNode node, List<Parameter> pathParams, boolean isConfig, Iterable<DataSchemaNode> childSchemaNodes) {
-        List<Operation> operations = new ArrayList<>();
+    private List<Operation> operation(final DataSchemaNode node, final List<Parameter> pathParams, final boolean isConfig, final Iterable<DataSchemaNode> childSchemaNodes) {
+        final List<Operation> operations = new ArrayList<>();
 
-        Get getBuilder = new Get(node, isConfig);
+        final Get getBuilder = new Get(node, isConfig);
         operations.add(getBuilder.pathParams(pathParams).build());
 
         if (isConfig) {
-            Put putBuilder = new Put(node.getQName().getLocalName(),
+            final Put putBuilder = new Put(node.getQName().getLocalName(),
                     node.getDescription());
             operations.add(putBuilder.pathParams(pathParams).build());
 
-            Delete deleteBuilder = new Delete(node);
+            final Delete deleteBuilder = new Delete(node);
             operations.add(deleteBuilder.pathParams(pathParams).build());
 
             if (containsListOrContainer(childSchemaNodes)) {
@@ -325,32 +325,32 @@ public class BaseYangSwaggerGenerator {
         return operations;
     }
 
-    private List<Operation> operationPost(final String name, final String description, final DataNodeContainer dataNodeContainer, List<Parameter> pathParams, boolean isConfig) {
-        List<Operation> operations = new ArrayList<>();
+    private List<Operation> operationPost(final String name, final String description, final DataNodeContainer dataNodeContainer, final List<Parameter> pathParams, final boolean isConfig) {
+        final List<Operation> operations = new ArrayList<>();
         if (isConfig) {
-            Post postBuilder = new Post(name, description, dataNodeContainer);
+            final Post postBuilder = new Post(name, description, dataNodeContainer);
             operations.add(postBuilder.pathParams(pathParams).build());
         }
         return operations;
     }
 
-    private String createPath(final DataSchemaNode schemaNode, List<Parameter> pathParams, SchemaContext schemaContext) {
-        ArrayList<LeafSchemaNode> pathListParams = new ArrayList<>();
-        StringBuilder path = new StringBuilder();
-        String localName = resolvePathArgumentsName(schemaNode, schemaContext);
+    private String createPath(final DataSchemaNode schemaNode, final List<Parameter> pathParams, final SchemaContext schemaContext) {
+        final ArrayList<LeafSchemaNode> pathListParams = new ArrayList<>();
+        final StringBuilder path = new StringBuilder();
+        final String localName = resolvePathArgumentsName(schemaNode, schemaContext);
         path.append(localName);
 
         if ((schemaNode instanceof ListSchemaNode)) {
             final List<QName> listKeys = ((ListSchemaNode) schemaNode).getKeyDefinition();
             for (final QName listKey : listKeys) {
-                DataSchemaNode dataChildByName = ((DataNodeContainer) schemaNode).getDataChildByName(listKey);
+                final DataSchemaNode dataChildByName = ((DataNodeContainer) schemaNode).getDataChildByName(listKey);
                 pathListParams.add(((LeafSchemaNode) dataChildByName));
 
-                String pathParamIdentifier = new StringBuilder("/{").append(listKey.getLocalName()).append("}")
+                final String pathParamIdentifier = new StringBuilder("/{").append(listKey.getLocalName()).append("}")
                         .toString();
                 path.append(pathParamIdentifier);
 
-                Parameter pathParam = new Parameter();
+                final Parameter pathParam = new Parameter();
                 pathParam.setName(listKey.getLocalName());
                 pathParam.setDescription(dataChildByName.getDescription());
                 pathParam.setType("string");
@@ -362,12 +362,12 @@ public class BaseYangSwaggerGenerator {
         return path.toString();
     }
 
-    protected void addRpcs(RpcDefinition rpcDefn, List<Api> apis, String parentPath, SchemaContext schemaContext) {
-        Api rpc = new Api();
-        String resourcePath = parentPath + resolvePathArgumentsName(rpcDefn, schemaContext);
+    protected void addRpcs(final RpcDefinition rpcDefn, final List<Api> apis, final String parentPath, final SchemaContext schemaContext) {
+        final Api rpc = new Api();
+        final String resourcePath = parentPath + resolvePathArgumentsName(rpcDefn, schemaContext);
         rpc.setPath(resourcePath);
 
-        Operation operationSpec = new Operation();
+        final Operation operationSpec = new Operation();
         operationSpec.setMethod("POST");
         operationSpec.setNotes(rpcDefn.getDescription());
         operationSpec.setNickname(rpcDefn.getQName().getLocalName());
@@ -375,7 +375,7 @@ public class BaseYangSwaggerGenerator {
             operationSpec.setType("(" + rpcDefn.getQName().getLocalName() + ")output");
         }
         if (rpcDefn.getInput() != null) {
-            Parameter payload = new Parameter();
+            final Parameter payload = new Parameter();
             payload.setParamType("body");
             payload.setType("(" + rpcDefn.getQName().getLocalName() + ")input");
             operationSpec.setParameters(Collections.singletonList(payload));
@@ -387,18 +387,18 @@ public class BaseYangSwaggerGenerator {
         apis.add(rpc);
     }
 
-    protected SortedSet<Module> getSortedModules(SchemaContext schemaContext) {
+    protected SortedSet<Module> getSortedModules(final SchemaContext schemaContext) {
         if (schemaContext == null) {
             return new TreeSet<>();
         }
 
-        Set<Module> modules = schemaContext.getModules();
+        final Set<Module> modules = schemaContext.getModules();
 
-        SortedSet<Module> sortedModules = new TreeSet<>((module1, module2) -> {
+        final SortedSet<Module> sortedModules = new TreeSet<>((module1, module2) -> {
             int result = module1.getName().compareTo(module2.getName());
             if (result == 0) {
-                Date module1Revision = module1.getRevision() != null ? module1.getRevision() : new Date(0);
-                Date module2Revision = module2.getRevision() != null ? module2.getRevision() : new Date(0);
+                final Date module1Revision = module1.getRevision() != null ? module1.getRevision() : new Date(0);
+                final Date module2Revision = module2.getRevision() != null ? module2.getRevision() : new Date(0);
                 result = module1Revision.compareTo(module2Revision);
             }
             if (result == 0) {
@@ -406,7 +406,7 @@ public class BaseYangSwaggerGenerator {
             }
             return result;
         });
-        for (Module m : modules) {
+        for (final Module m : modules) {
             if (m != null) {
                 sortedModules.add(m);
             }
index fdbd7b4997120c5572fca34b79f6a4befd201ce4..1a94b21141cdf65bf013a6f99ccec6fc8a8c1c82 100644 (file)
@@ -113,7 +113,7 @@ public class ModelGenerator {
     }
 
     public JSONObject convertToJsonSchema(final Module module, final SchemaContext schemaContext) throws IOException, JSONException {
-        JSONObject models = new JSONObject();
+        final JSONObject models = new JSONObject();
         topLevelModule = module;
         processModules(module, models);
         processContainersAndLists(module, models, schemaContext);
@@ -129,9 +129,9 @@ public class ModelGenerator {
     private void processContainersAndLists(final Module module, final JSONObject models, final SchemaContext schemaContext)
             throws IOException, JSONException {
 
-        String moduleName = module.getName();
+        final String moduleName = module.getName();
 
-        for (DataSchemaNode childNode : module.getChildNodes()) {
+        for (final DataSchemaNode childNode : module.getChildNodes()) {
             // For every container and list in the module
             if (childNode instanceof ContainerSchemaNode || childNode instanceof ListSchemaNode) {
                 processDataNodeContainer((DataNodeContainer) childNode, moduleName, models, true, schemaContext);
@@ -152,23 +152,23 @@ public class ModelGenerator {
     private void processRPCs(final Module module, final JSONObject models, final SchemaContext schemaContext) throws JSONException,
             IOException {
 
-        Set<RpcDefinition> rpcs = module.getRpcs();
-        String moduleName = module.getName();
-        for (RpcDefinition rpc : rpcs) {
+        final Set<RpcDefinition> rpcs = module.getRpcs();
+        final String moduleName = module.getName();
+        for (final RpcDefinition rpc : rpcs) {
 
-            ContainerSchemaNode input = rpc.getInput();
+            final ContainerSchemaNode input = rpc.getInput();
             if (input != null) {
-                JSONObject inputJSON = processDataNodeContainer(input, moduleName, models, schemaContext);
-                String filename = "(" + rpc.getQName().getLocalName() + ")input";
+                final JSONObject inputJSON = processDataNodeContainer(input, moduleName, models, schemaContext);
+                final String filename = "(" + rpc.getQName().getLocalName() + ")input";
                 inputJSON.put("id", filename);
                 // writeToFile(filename, inputJSON.toString(2), moduleName);
                 models.put(filename, inputJSON);
             }
 
-            ContainerSchemaNode output = rpc.getOutput();
+            final ContainerSchemaNode output = rpc.getOutput();
             if (output != null) {
-                JSONObject outputJSON = processDataNodeContainer(output, moduleName, models, schemaContext);
-                String filename = "(" + rpc.getQName().getLocalName() + ")output";
+                final JSONObject outputJSON = processDataNodeContainer(output, moduleName, models, schemaContext);
+                final String filename = "(" + rpc.getQName().getLocalName() + ")output";
                 outputJSON.put("id", filename);
                 models.put(filename, outputJSON);
             }
@@ -185,31 +185,31 @@ public class ModelGenerator {
      */
     private static void processIdentities(final Module module, final JSONObject models) throws JSONException {
 
-        String moduleName = module.getName();
-        Set<IdentitySchemaNode> idNodes = module.getIdentities();
+        final String moduleName = module.getName();
+        final Set<IdentitySchemaNode> idNodes = module.getIdentities();
         LOG.debug("Processing Identities for module {} . Found {} identity statements", moduleName, idNodes.size());
 
-        for (IdentitySchemaNode idNode : idNodes) {
-            JSONObject identityObj = new JSONObject();
-            String identityName = idNode.getQName().getLocalName();
+        for (final IdentitySchemaNode idNode : idNodes) {
+            final JSONObject identityObj = new JSONObject();
+            final String identityName = idNode.getQName().getLocalName();
             LOG.debug("Processing Identity: {}", identityName);
 
             identityObj.put(ID_KEY, identityName);
             identityObj.put(DESCRIPTION_KEY, idNode.getDescription());
 
-            JSONObject props = new JSONObject();
-            IdentitySchemaNode baseId = idNode.getBaseIdentity();
+            final JSONObject props = new JSONObject();
+            final IdentitySchemaNode baseId = idNode.getBaseIdentity();
 
             if (baseId == null) {
                 /**
                  * This is a base identity. So lets see if it has sub types. If it does, then add them to the model
                  * definition.
                  */
-                Set<IdentitySchemaNode> derivedIds = idNode.getDerivedIdentities();
+                final Set<IdentitySchemaNode> derivedIds = idNode.getDerivedIdentities();
 
                 if (derivedIds != null) {
-                    JSONArray subTypes = new JSONArray();
-                    for (IdentitySchemaNode derivedId : derivedIds) {
+                    final JSONArray subTypes = new JSONArray();
+                    for (final IdentitySchemaNode derivedId : derivedIds) {
                         subTypes.put(derivedId.getQName().getLocalName());
                     }
                     identityObj.put(SUB_TYPES_KEY, subTypes);
@@ -239,14 +239,14 @@ public class ModelGenerator {
             final boolean isConfig, final SchemaContext schemaContext) throws JSONException, IOException {
         if (dataNode instanceof ListSchemaNode || dataNode instanceof ContainerSchemaNode) {
             Preconditions.checkArgument(dataNode instanceof SchemaNode, "Data node should be also schema node");
-            Iterable<DataSchemaNode> containerChildren = dataNode.getChildNodes();
-            JSONObject properties = processChildren(containerChildren, ((SchemaNode) dataNode).getQName(), moduleName,
+            final Iterable<DataSchemaNode> containerChildren = dataNode.getChildNodes();
+            final JSONObject properties = processChildren(containerChildren, ((SchemaNode) dataNode).getQName(), moduleName,
                     models, isConfig, schemaContext);
 
-            String nodeName = (isConfig ? OperationBuilder.CONFIG : OperationBuilder.OPERATIONAL)
+            final String nodeName = (isConfig ? OperationBuilder.CONFIG : OperationBuilder.OPERATIONAL)
                     + ((SchemaNode) dataNode).getQName().getLocalName();
 
-            JSONObject childSchema = getSchemaTemplate();
+            final JSONObject childSchema = getSchemaTemplate();
             childSchema.put(TYPE_KEY, OBJECT_TYPE);
             childSchema.put(PROPERTIES_KEY, properties);
             childSchema.put("id", nodeName);
@@ -257,9 +257,9 @@ public class ModelGenerator {
                         createPropertiesForPost(dataNode));
             }
 
-            JSONObject items = new JSONObject();
+            final JSONObject items = new JSONObject();
             items.put(REF_KEY, nodeName);
-            JSONObject dataNodeProperties = new JSONObject();
+            final JSONObject dataNodeProperties = new JSONObject();
             dataNodeProperties.put(TYPE_KEY, dataNode instanceof ListSchemaNode ? ARRAY_TYPE : OBJECT_TYPE);
             dataNodeProperties.put(ITEMS_KEY, items);
 
@@ -270,8 +270,8 @@ public class ModelGenerator {
 
     private static void createConcreteModelForPost(final JSONObject models, final String localName,
             final JSONObject properties) throws JSONException {
-        String nodePostName = OperationBuilder.CONFIG + localName + Post.METHOD_NAME;
-        JSONObject postSchema = getSchemaTemplate();
+        final String nodePostName = OperationBuilder.CONFIG + localName + Post.METHOD_NAME;
+        final JSONObject postSchema = getSchemaTemplate();
         postSchema.put(TYPE_KEY, OBJECT_TYPE);
         postSchema.put("id", nodePostName);
         postSchema.put(PROPERTIES_KEY, properties);
@@ -279,17 +279,17 @@ public class ModelGenerator {
     }
 
     private JSONObject createPropertiesForPost(final DataNodeContainer dataNodeContainer) throws JSONException {
-        JSONObject properties = new JSONObject();
-        for (DataSchemaNode childNode : dataNodeContainer.getChildNodes()) {
+        final JSONObject properties = new JSONObject();
+        for (final DataSchemaNode childNode : dataNodeContainer.getChildNodes()) {
             if (childNode instanceof ListSchemaNode || childNode instanceof ContainerSchemaNode) {
-                JSONObject items = new JSONObject();
+                final JSONObject items = new JSONObject();
                 items.put(REF_KEY, "(config)" + childNode.getQName().getLocalName());
-                JSONObject property = new JSONObject();
+                final JSONObject property = new JSONObject();
                 property.put(TYPE_KEY, childNode instanceof ListSchemaNode ? ARRAY_TYPE : OBJECT_TYPE);
                 property.put(ITEMS_KEY, items);
                 properties.put(childNode.getQName().getLocalName(), property);
             } else if (childNode instanceof LeafSchemaNode) {
-                JSONObject property = processLeafNode((LeafSchemaNode)childNode);
+                final JSONObject property = processLeafNode((LeafSchemaNode) childNode);
                 properties.put(childNode.getQName().getLocalName(), property);
             }
         }
@@ -308,12 +308,12 @@ public class ModelGenerator {
             final String moduleName, final JSONObject models, final boolean isConfig, final SchemaContext schemaContext)
             throws JSONException, IOException {
 
-        JSONObject properties = new JSONObject();
+        final JSONObject properties = new JSONObject();
 
-        for (DataSchemaNode node : nodes) {
+        for (final DataSchemaNode node : nodes) {
             if (node.isConfiguration() == isConfig) {
 
-                String name = resolveNodesName(node, topLevelModule, schemaContext);
+                final String name = resolveNodesName(node, topLevelModule, schemaContext);
                 JSONObject property = null;
                 if (node instanceof LeafSchemaNode) {
                     property = processLeafNode((LeafSchemaNode) node);
@@ -346,14 +346,14 @@ public class ModelGenerator {
     }
 
     private JSONObject processLeafListNode(final LeafListSchemaNode listNode) throws JSONException {
-        JSONObject props = new JSONObject();
+        final JSONObject props = new JSONObject();
         props.put(TYPE_KEY, ARRAY_TYPE);
 
-        JSONObject itemsVal = new JSONObject();
+        final JSONObject itemsVal = new JSONObject();
         processTypeDef(listNode.getType(), itemsVal);
         props.put(ITEMS_KEY, itemsVal);
 
-        ConstraintDefinition constraints = listNode.getConstraints();
+        final ConstraintDefinition constraints = listNode.getConstraints();
         processConstraints(constraints, props);
 
         return props;
@@ -362,20 +362,20 @@ public class ModelGenerator {
     private JSONObject processChoiceNode(final ChoiceSchemaNode choiceNode, final String moduleName, final JSONObject models,
             final SchemaContext schemaContext) throws JSONException, IOException {
 
-        Set<ChoiceCaseNode> cases = choiceNode.getCases();
+        final Set<ChoiceCaseNode> cases = choiceNode.getCases();
 
-        JSONArray choiceProps = new JSONArray();
-        for (ChoiceCaseNode choiceCase : cases) {
-            String choiceName = choiceCase.getQName().getLocalName();
-            JSONObject choiceProp = processChildren(choiceCase.getChildNodes(), choiceCase.getQName(), moduleName,
+        final JSONArray choiceProps = new JSONArray();
+        for (final ChoiceCaseNode choiceCase : cases) {
+            final String choiceName = choiceCase.getQName().getLocalName();
+            final JSONObject choiceProp = processChildren(choiceCase.getChildNodes(), choiceCase.getQName(), moduleName,
                     models, schemaContext);
-            JSONObject choiceObj = new JSONObject();
+            final JSONObject choiceObj = new JSONObject();
             choiceObj.put(choiceName, choiceProp);
             choiceObj.put(TYPE_KEY, OBJECT_TYPE);
             choiceProps.put(choiceObj);
         }
 
-        JSONObject oneOfProps = new JSONObject();
+        final JSONObject oneOfProps = new JSONObject();
         oneOfProps.put(ONE_OF_KEY, choiceProps);
         oneOfProps.put(TYPE_KEY, OBJECT_TYPE);
 
@@ -383,11 +383,11 @@ public class ModelGenerator {
     }
 
     private static void processConstraints(final ConstraintDefinition constraints, final JSONObject props) throws JSONException {
-        boolean isMandatory = constraints.isMandatory();
+        final boolean isMandatory = constraints.isMandatory();
         props.put(REQUIRED_KEY, isMandatory);
 
-        Integer minElements = constraints.getMinElements();
-        Integer maxElements = constraints.getMaxElements();
+        final Integer minElements = constraints.getMinElements();
+        final Integer maxElements = constraints.getMaxElements();
         if (minElements != null) {
             props.put(MIN_ITEMS, minElements);
         }
@@ -397,9 +397,9 @@ public class ModelGenerator {
     }
 
     private JSONObject processLeafNode(final LeafSchemaNode leafNode) throws JSONException {
-        JSONObject property = new JSONObject();
+        final JSONObject property = new JSONObject();
 
-        String leafDescription = leafNode.getDescription();
+        final String leafDescription = leafNode.getDescription();
         property.put(DESCRIPTION_KEY, leafDescription);
 
         processConstraints(leafNode.getConstraints(), property);
@@ -409,9 +409,9 @@ public class ModelGenerator {
     }
 
     private static JSONObject processAnyXMLNode(final AnyXmlSchemaNode leafNode) throws JSONException {
-        JSONObject property = new JSONObject();
+        final JSONObject property = new JSONObject();
 
-        String leafDescription = leafNode.getDescription();
+        final String leafDescription = leafNode.getDescription();
         property.put(DESCRIPTION_KEY, leafDescription);
 
         processConstraints(leafNode.getConstraints(), property);
@@ -444,15 +444,15 @@ public class ModelGenerator {
 
     private static void processBinaryType(final BinaryTypeDefinition binaryType, final JSONObject property) throws JSONException {
         property.put(TYPE_KEY, STRING);
-        JSONObject media = new JSONObject();
+        final JSONObject media = new JSONObject();
         media.put(BINARY_ENCODING_KEY, BASE_64);
         property.put(MEDIA_KEY, media);
     }
 
     private static void processEnumType(final EnumTypeDefinition enumLeafType, final JSONObject property) throws JSONException {
-        List<EnumPair> enumPairs = enumLeafType.getValues();
-        List<String> enumNames = new ArrayList<>();
-        for (EnumPair enumPair : enumPairs) {
+        final List<EnumPair> enumPairs = enumLeafType.getValues();
+        final List<String> enumNames = new ArrayList<>();
+        for (final EnumPair enumPair : enumPairs) {
             enumNames.add(enumPair.getName());
         }
         property.putOpt(ENUM, new JSONArray(enumNames));
@@ -462,13 +462,13 @@ public class ModelGenerator {
         property.put(TYPE_KEY, ARRAY_TYPE);
         property.put(MIN_ITEMS, 0);
         property.put(UNIQUE_ITEMS_KEY, true);
-        JSONArray enumValues = new JSONArray();
+        final JSONArray enumValues = new JSONArray();
 
-        List<Bit> bits = bitsType.getBits();
-        for (Bit bit : bits) {
+        final List<Bit> bits = bitsType.getBits();
+        for (final Bit bit : bits) {
             enumValues.put(bit.getName());
         }
-        JSONObject itemsValue = new JSONObject();
+        final JSONObject itemsValue = new JSONObject();
         itemsValue.put(ENUM, enumValues);
         property.put(ITEMS_KEY, itemsValue);
     }
@@ -483,9 +483,9 @@ public class ModelGenerator {
 
         // FIXME: json-schema is not expressive enough to capture min/max laternatives. We should find the true minimum
         //        and true maximum implied by the constraints and use that.
-        for (LengthConstraint lengthConstraint : lengthConstraints) {
-            Number min = lengthConstraint.getMin();
-            Number max = lengthConstraint.getMax();
+        for (final LengthConstraint lengthConstraint : lengthConstraints) {
+            final Number min = lengthConstraint.getMin();
+            final Number max = lengthConstraint.getMax();
             property.putOpt(MIN_LENGTH_KEY, min);
             property.putOpt(MAX_LENGTH_KEY, max);
         }
@@ -494,8 +494,8 @@ public class ModelGenerator {
     }
 
     private static void processUnionType(final UnionTypeDefinition unionType, final JSONObject property) throws JSONException {
-        StringBuilder type = new StringBuilder();
-        for (TypeDefinition<?> typeDef : unionType.getTypes()) {
+        final StringBuilder type = new StringBuilder();
+        for (final TypeDefinition<?> typeDef : unionType.getTypes()) {
             if (type.length() > 0) {
                 type.append(" or ");
             }
@@ -509,7 +509,7 @@ public class ModelGenerator {
      * Helper method to generate a pre-filled JSON schema object.
      */
     private static JSONObject getSchemaTemplate() throws JSONException {
-        JSONObject schemaJSON = new JSONObject();
+        final JSONObject schemaJSON = new JSONObject();
         schemaJSON.put(SCHEMA_KEY, SCHEMA_URL);
 
         return schemaJSON;
index 3cedb11a8c4afb2263e17bbe8e987c80d414c5b4..de8c5bc50163f590e8aa37dc088cb6ab59fcf23b 100644 (file)
@@ -31,7 +31,7 @@ public class JaxbContextResolver implements ContextResolver<ObjectMapper> {
     }
 
     @Override
-    public ObjectMapper getContext(Class<?> klass) {
+    public ObjectMapper getContext(final Class<?> klass) {
         if (ApiDeclaration.class.isAssignableFrom(klass)) {
             return ctx;
         }
index 98f8af76d838163bf05d2eb938298dc2b6812955..e0bc84d7367a3d2d3478607469a6de0ae16e5a5d 100644 (file)
@@ -34,7 +34,7 @@ public final class OperationBuilder {
         protected DataSchemaNode schemaNode;
         private static final String METHOD_NAME = "GET";
 
-        public Get(DataSchemaNode node, boolean isConfig) {
+        public Get(final DataSchemaNode node, final boolean isConfig) {
             this.schemaNode = node;
             spec = new Operation();
             spec.setMethod(METHOD_NAME);
@@ -43,8 +43,8 @@ public final class OperationBuilder {
             spec.setNotes(node.getDescription());
         }
 
-        public Get pathParams(List<Parameter> params) {
-            List<Parameter> pathParameters = new ArrayList<>(params);
+        public Get pathParams(final List<Parameter> params) {
+            final List<Parameter> pathParameters = new ArrayList<>(params);
             spec.setParameters(pathParameters);
             return this;
         }
@@ -59,7 +59,7 @@ public final class OperationBuilder {
         protected String nodeName;
         private static final String METHOD_NAME = "PUT";
 
-        public Put(String nodeName, final String description) {
+        public Put(final String nodeName, final String description) {
             this.nodeName = nodeName;
             spec = new Operation();
             spec.setType(CONFIG + nodeName);
@@ -67,9 +67,9 @@ public final class OperationBuilder {
             spec.setConsumes(CONSUMES_PUT_POST);
         }
 
-        public Put pathParams(List<Parameter> params) {
-            List<Parameter> parameters = new ArrayList<>(params);
-            Parameter payload = new Parameter();
+        public Put pathParams(final List<Parameter> params) {
+            final List<Parameter> parameters = new ArrayList<>(params);
+            final Parameter payload = new Parameter();
             payload.setParamType("body");
             payload.setType(CONFIG + nodeName);
             parameters.add(payload);
@@ -104,11 +104,11 @@ public final class OperationBuilder {
         }
 
         @Override
-        public Put pathParams(List<Parameter> params) {
-            List<Parameter> parameters = new ArrayList<>(params);
-            for (DataSchemaNode node : dataNodeContainer.getChildNodes()) {
+        public Put pathParams(final List<Parameter> params) {
+            final List<Parameter> parameters = new ArrayList<>(params);
+            for (final DataSchemaNode node : dataNodeContainer.getChildNodes()) {
                 if (node instanceof ListSchemaNode || node instanceof ContainerSchemaNode) {
-                    Parameter payload = new Parameter();
+                    final Parameter payload = new Parameter();
                     payload.setParamType("body");
                     payload.setType(CONFIG + node.getQName().getLocalName());
                     payload.setName("**" + CONFIG + node.getQName().getLocalName());
@@ -129,7 +129,7 @@ public final class OperationBuilder {
     public static final class Delete extends Get {
         private static final String METHOD_NAME = "DELETE";
 
-        public Delete(DataSchemaNode node) {
+        public Delete(final DataSchemaNode node) {
             super(node, false);
         }
 
index 89a75b0c2834d9f27bd2671935bbaa0068f869d9..98268495b86e5ef8069301a20ed7bdddcf755234 100644 (file)
@@ -48,15 +48,15 @@ public class MountPointSwagger extends BaseYangSwaggerGenerator implements Mount
 
     private final AtomicLong idKey = new AtomicLong(0);
 
-    private static AtomicReference<MountPointSwagger> selfRef = new AtomicReference<>();
+    private static final AtomicReference<MountPointSwagger> selfRef = new AtomicReference<>();
     private SchemaService globalSchema;
 
     public Map<String, Long> getInstanceIdentifiers() {
-        Map<String, Long> urlToId = new HashMap<>();
+        final Map<String, Long> urlToId = new HashMap<>();
         synchronized (lock) {
-            SchemaContext context = globalSchema.getGlobalContext();
-            for (Entry<YangInstanceIdentifier, Long> entry : instanceIdToLongId.entrySet()) {
-                String modName = findModuleName(entry.getKey(), context);
+            final SchemaContext context = globalSchema.getGlobalContext();
+            for (final Entry<YangInstanceIdentifier, Long> entry : instanceIdToLongId.entrySet()) {
+                final String modName = findModuleName(entry.getKey(), context);
                 urlToId.put(generateUrlPrefixFromInstanceID(entry.getKey(), modName),
                         entry.getValue());
             }
@@ -69,8 +69,8 @@ public class MountPointSwagger extends BaseYangSwaggerGenerator implements Mount
     }
 
     private String findModuleName(final YangInstanceIdentifier id, final SchemaContext context) {
-        PathArgument rootQName = id.getPathArguments().iterator().next();
-        for (Module mod : context.getModules()) {
+        final PathArgument rootQName = id.getPathArguments().iterator().next();
+        for (final Module mod : context.getModules()) {
             if (mod.getDataChildByName(rootQName.getNodeType()) != null) {
                 return mod.getName();
             }
@@ -79,16 +79,16 @@ public class MountPointSwagger extends BaseYangSwaggerGenerator implements Mount
     }
 
     private String generateUrlPrefixFromInstanceID(final YangInstanceIdentifier key, final String moduleName) {
-        StringBuilder builder = new StringBuilder();
+        final StringBuilder builder = new StringBuilder();
         if (moduleName != null) {
             builder.append(moduleName);
             builder.append(':');
         }
-        for (PathArgument arg : key.getPathArguments()) {
-            String name = arg.getNodeType().getLocalName();
+        for (final PathArgument arg : key.getPathArguments()) {
+            final String name = arg.getNodeType().getLocalName();
             if (arg instanceof YangInstanceIdentifier.NodeIdentifierWithPredicates) {
-                NodeIdentifierWithPredicates nodeId = (NodeIdentifierWithPredicates) arg;
-                for (Entry<QName, Object> entry : nodeId.getKeyValues().entrySet()) {
+                final NodeIdentifierWithPredicates nodeId = (NodeIdentifierWithPredicates) arg;
+                for (final Entry<QName, Object> entry : nodeId.getKeyValues().entrySet()) {
                     builder.append(entry.getValue()).append('/');
                 }
             } else {
@@ -100,33 +100,33 @@ public class MountPointSwagger extends BaseYangSwaggerGenerator implements Mount
     }
 
     private String getYangMountUrl(final YangInstanceIdentifier key) {
-        String modName = findModuleName(key, globalSchema.getGlobalContext());
+        final String modName = findModuleName(key, globalSchema.getGlobalContext());
         return generateUrlPrefixFromInstanceID(key, modName) + "yang-ext:mount/";
     }
 
     public ResourceList getResourceList(final UriInfo uriInfo, final Long id) {
-        YangInstanceIdentifier iid = getInstanceId(id);
+        final YangInstanceIdentifier iid = getInstanceId(id);
         if (iid == null) {
             return null; // indicating not found.
         }
-        SchemaContext context = getSchemaContext(iid);
+        final SchemaContext context = getSchemaContext(iid);
         if (context == null) {
             return createResourceList();
         }
-        List<Resource> resources = new LinkedList<>();
-        Resource dataStores = new Resource();
+        final List<Resource> resources = new LinkedList<>();
+        final Resource dataStores = new Resource();
         dataStores.setDescription("Provides methods for accessing the data stores.");
         dataStores.setPath(generatePath(uriInfo, DATASTORES_LABEL, DATASTORES_REVISION));
         resources.add(dataStores);
-        String urlPrefix = getYangMountUrl(iid);
-        ResourceList list = super.getResourceListing(uriInfo, context, urlPrefix);
+        final String urlPrefix = getYangMountUrl(iid);
+        final ResourceList list = super.getResourceListing(uriInfo, context, urlPrefix);
         resources.addAll(list.getApis());
         list.setApis(resources);
         return list;
     }
 
     private YangInstanceIdentifier getInstanceId(final Long id) {
-        YangInstanceIdentifier instanceId;
+        final YangInstanceIdentifier instanceId;
         synchronized (lock) {
             instanceId = longIdToInstanceId.get(id);
         }
@@ -139,12 +139,12 @@ public class MountPointSwagger extends BaseYangSwaggerGenerator implements Mount
             return null;
         }
 
-        Optional<DOMMountPoint> mountPoint = mountService.getMountPoint(id);
+        final Optional<DOMMountPoint> mountPoint = mountService.getMountPoint(id);
         if (!mountPoint.isPresent()) {
             return null;
         }
 
-        SchemaContext context = mountPoint.get().getSchemaContext();
+        final SchemaContext context = mountPoint.get().getSchemaContext();
         if (context == null) {
             return null;
         }
@@ -152,9 +152,9 @@ public class MountPointSwagger extends BaseYangSwaggerGenerator implements Mount
     }
 
     public ApiDeclaration getMountPointApi(final UriInfo uriInfo, final Long id, final String module, final String revision) {
-        YangInstanceIdentifier iid = getInstanceId(id);
-        SchemaContext context = getSchemaContext(iid);
-        String urlPrefix = getYangMountUrl(iid);
+        final YangInstanceIdentifier iid = getInstanceId(id);
+        final SchemaContext context = getSchemaContext(iid);
+        final String urlPrefix = getYangMountUrl(iid);
         if (context == null) {
             return null;
         }
@@ -166,7 +166,7 @@ public class MountPointSwagger extends BaseYangSwaggerGenerator implements Mount
     }
 
     private ApiDeclaration generateDataStoreApiDoc(final UriInfo uriInfo, final String context) {
-        List<Api> apis = new LinkedList<>();
+        final List<Api> apis = new LinkedList<>();
         apis.add(createGetApi("config",
                 "Queries the config (startup) datastore on the mounted hosted.", context));
         apis.add(createGetApi("operational",
@@ -174,19 +174,19 @@ public class MountPointSwagger extends BaseYangSwaggerGenerator implements Mount
         apis.add(createGetApi("operations",
                 "Queries the available operations (RPC calls) on the mounted hosted.", context));
 
-        ApiDeclaration declaration = super.createApiDeclaration(createBasePathFromUriInfo(uriInfo));
+        final ApiDeclaration declaration = super.createApiDeclaration(createBasePathFromUriInfo(uriInfo));
         declaration.setApis(apis);
         return declaration;
 
     }
 
     private Api createGetApi(final String datastore, final String note, final String context) {
-        Operation getConfig = new Operation();
+        final Operation getConfig = new Operation();
         getConfig.setMethod("GET");
         getConfig.setNickname("GET " + datastore);
         getConfig.setNotes(note);
 
-        Api api = new Api();
+        final Api api = new Api();
         api.setPath(getDataStorePath("/" + datastore + "/", context));
         api.setOperations(Collections.singletonList(getConfig));
 
@@ -200,7 +200,7 @@ public class MountPointSwagger extends BaseYangSwaggerGenerator implements Mount
     @Override
     public void onMountPointCreated(final YangInstanceIdentifier path) {
         synchronized (lock) {
-            Long idLong = idKey.incrementAndGet();
+            final Long idLong = idKey.incrementAndGet();
             instanceIdToLongId.put(path, idLong);
             longIdToInstanceId.put(idLong, path);
         }
@@ -209,7 +209,7 @@ public class MountPointSwagger extends BaseYangSwaggerGenerator implements Mount
     @Override
     public void onMountPointRemoved(final YangInstanceIdentifier path) {
         synchronized (lock) {
-            Long id = instanceIdToLongId.remove(path);
+            final Long id = instanceIdToLongId.remove(path);
             longIdToInstanceId.remove(id);
         }
     }
index 55d92c73f6b3b1a6c8fbf92f6127b8c8c20a0241..409378ae88ee16d9aac17f6f27ee0b643e33766f 100644 (file)
@@ -22,7 +22,7 @@ public class RestDocgenUtil {
     private RestDocgenUtil() {
     }
 
-    private static Map<URI, Map<Date, Module>> namespaceAndRevisionToModule = new HashMap<>();
+    private static final Map<URI, Map<Date, Module>> namespaceAndRevisionToModule = new HashMap<>();
 
     /**
      * Resolve path argument name for {@code node}.
@@ -34,9 +34,9 @@ public class RestDocgenUtil {
      * @return name of {@code node}
      */
     public static String resolvePathArgumentsName(final SchemaNode node, final SchemaContext schemaContext) {
-        Iterable<QName> schemaPath = node.getPath().getPathTowardsRoot();
-        Iterator<QName> it = schemaPath.iterator();
-        QName nodeQName = it.next();
+        final Iterable<QName> schemaPath = node.getPath().getPathTowardsRoot();
+        final Iterator<QName> it = schemaPath.iterator();
+        final QName nodeQName = it.next();
 
         QName parentQName = null;
         if (it.hasNext()) {
@@ -80,7 +80,7 @@ public class RestDocgenUtil {
         }
     }
 
-    private static boolean isEqualNamespaceAndRevision(QName parentQName, QName nodeQName) {
+    private static boolean isEqualNamespaceAndRevision(final QName parentQName, final QName nodeQName) {
         if (parentQName == null) {
             if (nodeQName == null) {
                 return true;
@@ -90,4 +90,5 @@ public class RestDocgenUtil {
         return parentQName.getNamespace().equals(nodeQName.getNamespace())
                 && parentQName.getRevision().equals(nodeQName.getRevision());
     }
+
 }