Clean up a lot of JavaDoc etc. to conform to current Checkstyle rules 20/39620/1
authorMichael Vorburger <vorburger@redhat.com>
Mon, 30 May 2016 17:41:35 +0000 (19:41 +0200)
committerMichael Vorburger <vorburger@redhat.com>
Mon, 30 May 2016 17:41:35 +0000 (19:41 +0200)
Change-Id: I1b5613ad00633e6b59626dacca08f8c458f076f3
Signed-off-by: Michael Vorburger <vorburger@redhat.com>
restconf/sal-rest-docgen/src/main/java/org/opendaylight/netconf/sal/rest/doc/api/ApiDocService.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 71e54bb752ba49899675b2eacf280f38874ce0cc..e30dff77bf56824c6fa76fff1b5e84f39039e4b1 100644 (file)
@@ -28,9 +28,6 @@ public interface ApiDocService {
      * Generates index document for Swagger UI. This document lists out all
      * modules with link to get APIs for each module. The API for each module is
      * served by <code> getDocByModule()</code> method.
-     *
-     * @param uriInfo
-     * @return
      */
     @GET
     @Produces(MediaType.APPLICATION_JSON)
@@ -38,11 +35,6 @@ public interface ApiDocService {
 
     /**
      * Generates Swagger compliant document listing APIs for module.
-     *
-     * @param module
-     * @param revision
-     * @param uriInfo
-     * @return
      */
     @GET
     @Path("/{module}({revision})")
@@ -52,9 +44,6 @@ public interface ApiDocService {
 
     /**
      * Redirects to embedded swagger ui.
-     *
-     * @param uriInfo
-     * @return
      */
     @GET
     @Path("/ui")
@@ -65,9 +54,6 @@ public interface ApiDocService {
      * Generates index document for Swagger UI. This document lists out all
      * modules with link to get APIs for each module. The API for each module is
      * served by <code> getDocByModule()</code> method.
-     *
-     * @param uriInfo
-     * @return
      */
     @GET
     @Path("/mounts")
@@ -82,11 +68,6 @@ public interface ApiDocService {
 
     /**
      * Generates Swagger compliant document listing APIs for module.
-     *
-     * @param module
-     * @param revision
-     * @param uriInfo
-     * @return
      */
     @GET
     @Path("/mounts/{instance}/{module}({revision})")
index 64afdc79001b254b2f7bef57989c446a0c06d23e..59cbba0719489859e6bcd4a1bf122d7ea34dbad9 100644 (file)
@@ -15,7 +15,8 @@ import org.opendaylight.netconf.sal.rest.doc.swagger.ResourceList;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 
 /**
- * This class gathers all YANG-defined {@link org.opendaylight.yangtools.yang.model.api.Module}s and generates Swagger compliant documentation.
+ * This class gathers all YANG-defined {@link org.opendaylight.yangtools.yang.model.api.Module}s and
+ * generates Swagger compliant documentation.
  */
 public class ApiDocGenerator extends BaseYangSwaggerGenerator {
 
@@ -36,18 +37,12 @@ public class ApiDocGenerator extends BaseYangSwaggerGenerator {
     }
 
     /**
-     * Returns singleton instance
-     *
-     * @return
+     * Returns singleton instance.
      */
     public static ApiDocGenerator getInstance() {
         return INSTANCE;
     }
 
-    /**
-     *
-     * @param schemaService
-     */
     public void setSchemaService(SchemaService schemaService) {
         this.schemaService = schemaService;
     }
index 1f964a85004116a5ce01b16ab200fd7cf5043aa3..f3294ec3d0665c53a0f90c9e9442ac242d34d0a0 100644 (file)
@@ -26,12 +26,11 @@ import org.opendaylight.netconf.sal.rest.doc.swagger.ResourceList;
  * >https://helloreverb.com/developers/swagger</a>) compliant documentation for
  * RESTCONF APIs. The output of this is used by embedded Swagger UI.
  *
- * NOTE: These API's need to be synchronized due to bug 1198. Thread access to
+ * <p>NOTE: These API's need to be synchronized due to bug 1198. Thread access to
  * the SchemaContext is not synchronized properly and thus you can end up with
  * missing definitions without this synchronization. There are likely otherways
  * to work around this limitation, but given that this API is a dev only tool
  * and not dependent UI, this was the fastest work around.
- *
  */
 public class ApiDocServiceImpl implements ApiDocService {
 
@@ -45,9 +44,6 @@ public class ApiDocServiceImpl implements ApiDocService {
      * Generates index document for Swagger UI. This document lists out all
      * modules with link to get APIs for each module. The API for each module is
      * served by <code> getDocByModule()</code> method.
-     *
-     * @param uriInfo
-     * @return
      */
     @Override
     public synchronized Response getRootDoc(UriInfo uriInfo) {
@@ -59,11 +55,6 @@ public class ApiDocServiceImpl implements ApiDocService {
 
     /**
      * Generates Swagger compliant document listing APIs for module.
-     *
-     * @param module
-     * @param revision
-     * @param uriInfo
-     * @return
      */
     @Override
     public synchronized Response getDocByModule(String module, String revision, UriInfo uriInfo) {
@@ -75,9 +66,6 @@ public class ApiDocServiceImpl implements ApiDocService {
 
     /**
      * Redirects to embedded swagger ui.
-     *
-     * @param uriInfo
-     * @return
      */
     @Override
     public synchronized Response getApiExplorer(UriInfo uriInfo) {
index bc4c6bba8f090a029f59d580a4ec9113649abc69..1db67f830120eaac390c052b81a2d83ec9c9cb47 100644 (file)
@@ -22,7 +22,6 @@ import java.util.Arrays;
 import java.util.Calendar;
 import java.util.Collection;
 import java.util.Collections;
-import java.util.Comparator;
 import java.util.Date;
 import java.util.GregorianCalendar;
 import java.util.List;
@@ -64,7 +63,7 @@ public class BaseYangSwaggerGenerator {
     protected static final String RESTCONF_CONTEXT_ROOT = "restconf";
 
     static final String MODULE_NAME_SUFFIX = "_module";
-    protected final DateFormat SIMPLE_DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd");
+    protected static final DateFormat SIMPLE_DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd");
     private final ModelGenerator jsonConverter = new ModelGenerator();
 
     // private Map<String, ApiDeclaration> MODULE_DOC_CACHE = new HashMap<>()
@@ -76,11 +75,7 @@ public class BaseYangSwaggerGenerator {
     }
 
     /**
-     *
-     * @param uriInfo
-     * @param schemaContext
-     * @param context
-     * @return list of modules converted to swagger compliant resource list.
+     * Return list of modules converted to swagger compliant resource list.
      */
     public ResourceList getResourceListing(UriInfo uriInfo, SchemaContext schemaContext, String context) {
 
@@ -123,31 +118,32 @@ public class BaseYangSwaggerGenerator {
         return uri.toASCIIString();
     }
 
-    public ApiDeclaration getApiDeclaration(String module, String revision, UriInfo uriInfo, SchemaContext schemaContext, String context) {
+    public ApiDeclaration getApiDeclaration(String moduleName, String revision, UriInfo uriInfo, SchemaContext schemaContext, String context) {
         Date rev = null;
 
         try {
-            if(revision != null && !revision.equals("0000-00-00")) {
+            if (revision != null && !revision.equals("0000-00-00")) {
                 rev = SIMPLE_DATE_FORMAT.parse(revision);
             }
         } catch (ParseException e) {
             throw new IllegalArgumentException(e);
         }
 
-        if(rev != null) {
+        if (rev != null) {
             Calendar cal = new GregorianCalendar();
 
             cal.setTime(rev);
 
-            if(cal.get(Calendar.YEAR) < 1970) {
+            if (cal.get(Calendar.YEAR) < 1970) {
                 rev = null;
             }
         }
 
-        Module m = schemaContext.findModuleByName(module, rev);
-        Preconditions.checkArgument(m != null, "Could not find module by name,revision: " + module + "," + revision);
+        Module module = schemaContext.findModuleByName(moduleName, rev);
+        Preconditions.checkArgument(module != null,
+                "Could not find module by name,revision: " + moduleName + "," + revision);
 
-        return getApiDeclaration(m, rev, uriInfo, context, schemaContext);
+        return getApiDeclaration(module, rev, uriInfo, context, schemaContext);
     }
 
     public ApiDeclaration getApiDeclaration(Module module, Date revision, UriInfo uriInfo, String context, SchemaContext schemaContext) {
@@ -175,7 +171,7 @@ public class BaseYangSwaggerGenerator {
     public ApiDeclaration getSwaggerDocSpec(Module m, String basePath, String context, SchemaContext schemaContext) {
         ApiDeclaration doc = createApiDeclaration(basePath);
 
-        List<Api> apis = new ArrayList<Api>();
+        List<Api> apis = new ArrayList<>();
 
         Collection<DataSchemaNode> dataSchemaNodes = m.getChildNodes();
         LOG.debug("child nodes size [{}]", dataSchemaNodes.size());
@@ -184,12 +180,12 @@ public class BaseYangSwaggerGenerator {
 
                 LOG.debug("Is Configuration node [{}] [{}]", node.isConfiguration(), node.getQName().getLocalName());
 
-                List<Parameter> pathParams = new ArrayList<Parameter>();
+                List<Parameter> pathParams = new ArrayList<>();
                 String resourcePath = getDataStorePath("/config/", context);
                 addRootPostLink(m, (DataNodeContainer) node, pathParams, resourcePath, apis);
                 addApis(node, apis, resourcePath, pathParams, schemaContext, true);
 
-                pathParams = new ArrayList<Parameter>();
+                pathParams = new ArrayList<>();
                 resourcePath = getDataStorePath("/operational/", context);
                 addApis(node, apis, resourcePath, pathParams, schemaContext, false);
             }
@@ -222,12 +218,13 @@ public class BaseYangSwaggerGenerator {
         return null;
     }
 
-    private void addRootPostLink(final Module m, final DataNodeContainer node, final List<Parameter> pathParams,
+    private void addRootPostLink(final Module module, final DataNodeContainer node, final List<Parameter> pathParams,
             final String resourcePath, final List<Api> apis) {
-        if (containsListOrContainer(m.getChildNodes())) {
+        if (containsListOrContainer(module.getChildNodes())) {
             final Api apiForRootPostUri = new Api();
             apiForRootPostUri.setPath(resourcePath);
-            apiForRootPostUri.setOperations(operationPost(m.getName()+MODULE_NAME_SUFFIX, m.getDescription(), m, pathParams, true));
+            apiForRootPostUri.setOperations(operationPost(module.getName() + MODULE_NAME_SUFFIX,
+                    module.getDescription(), module, pathParams, true));
             apis.add(apiForRootPostUri);
         }
     }
@@ -245,10 +242,6 @@ public class BaseYangSwaggerGenerator {
         return dataStore + context;
     }
 
-    private String generateCacheKey(Module m) {
-        return generateCacheKey(m.getName(), SIMPLE_DATE_FORMAT.format(m.getRevision()));
-    }
-
     private String generateCacheKey(String module, String revision) {
         return module + "(" + revision + ")";
     }
@@ -257,13 +250,13 @@ public class BaseYangSwaggerGenerator {
             boolean addConfigApi) {
 
         Api api = new Api();
-        List<Parameter> pathParams = new ArrayList<Parameter>(parentPathParams);
+        List<Parameter> pathParams = new ArrayList<>(parentPathParams);
 
         String resourcePath = parentPath + createPath(node, pathParams, schemaContext) + "/";
         LOG.debug("Adding path: [{}]", resourcePath);
         api.setPath(resourcePath);
 
-        Iterable<DataSchemaNode> childSchemaNodes = Collections.<DataSchemaNode> emptySet();
+        Iterable<DataSchemaNode> childSchemaNodes = Collections.<DataSchemaNode>emptySet();
         if ((node instanceof ListSchemaNode) || (node instanceof ContainerSchemaNode)) {
             DataNodeContainer dataNodeContainer = (DataNodeContainer) node;
             childSchemaNodes = dataNodeContainer.getChildNodes();
@@ -291,11 +284,6 @@ public class BaseYangSwaggerGenerator {
         return false;
     }
 
-    /**
-     * @param node
-     * @param pathParams
-     * @return
-     */
     private List<Operation> operation(DataSchemaNode node, List<Parameter> pathParams, boolean isConfig, Iterable<DataSchemaNode> childSchemaNodes) {
         List<Operation> operations = new ArrayList<>();
 
@@ -311,18 +299,13 @@ public class BaseYangSwaggerGenerator {
             operations.add(deleteBuilder.pathParams(pathParams).build());
 
             if (containsListOrContainer(childSchemaNodes)) {
-                operations.addAll(operationPost(node.getQName().getLocalName(), node.getDescription(), (DataNodeContainer) node,
-                        pathParams, isConfig));
+                operations.addAll(operationPost(node.getQName().getLocalName(), node.getDescription(),
+                        (DataNodeContainer) node, pathParams, isConfig));
             }
         }
         return operations;
     }
 
-    /**
-     * @param node
-     * @param pathParams
-     * @return
-     */
     private List<Operation> operationPost(final String name, final String description, final DataNodeContainer dataNodeContainer, List<Parameter> pathParams, boolean isConfig) {
         List<Operation> operations = new ArrayList<>();
         if (isConfig) {
@@ -333,7 +316,7 @@ public class BaseYangSwaggerGenerator {
     }
 
     private String createPath(final DataSchemaNode schemaNode, List<Parameter> pathParams, SchemaContext schemaContext) {
-        ArrayList<LeafSchemaNode> pathListParams = new ArrayList<LeafSchemaNode>();
+        ArrayList<LeafSchemaNode> pathListParams = new ArrayList<>();
         StringBuilder path = new StringBuilder();
         String localName = resolvePathArgumentsName(schemaNode, schemaContext);
         path.append(localName);
@@ -341,8 +324,8 @@ public class BaseYangSwaggerGenerator {
         if ((schemaNode instanceof ListSchemaNode)) {
             final List<QName> listKeys = ((ListSchemaNode) schemaNode).getKeyDefinition();
             for (final QName listKey : listKeys) {
-                DataSchemaNode _dataChildByName = ((DataNodeContainer) schemaNode).getDataChildByName(listKey);
-                pathListParams.add(((LeafSchemaNode) _dataChildByName));
+                DataSchemaNode dataChildByName = ((DataNodeContainer) schemaNode).getDataChildByName(listKey);
+                pathListParams.add(((LeafSchemaNode) dataChildByName));
 
                 String pathParamIdentifier = new StringBuilder("/{").append(listKey.getLocalName()).append("}")
                         .toString();
@@ -350,7 +333,7 @@ public class BaseYangSwaggerGenerator {
 
                 Parameter pathParam = new Parameter();
                 pathParam.setName(listKey.getLocalName());
-                pathParam.setDescription(_dataChildByName.getDescription());
+                pathParam.setDescription(dataChildByName.getDescription());
                 pathParam.setType("string");
                 pathParam.setParamType("path");
 
@@ -392,20 +375,17 @@ public class BaseYangSwaggerGenerator {
 
         Set<Module> modules = schemaContext.getModules();
 
-        SortedSet<Module> sortedModules = new TreeSet<>(new Comparator<Module>() {
-            @Override
-            public int compare(Module module1, Module 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);
-                    result = module1Revision.compareTo(module2Revision);
-                }
-                if (result == 0) {
-                    result = module1.getNamespace().compareTo(module2.getNamespace());
-                }
-                return result;
+        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);
+                result = module1Revision.compareTo(module2Revision);
+            }
+            if (result == 0) {
+                result = module1.getNamespace().compareTo(module2.getNamespace());
             }
+            return result;
         });
         for (Module m : modules) {
             if (m != null) {
index c0490c857bd726bb6e713f6d6ab477e55f5431a7..04b80b94ce127333f1b63ffb448eb54409a67076 100644 (file)
@@ -54,7 +54,7 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 /**
- * Generates JSON Schema for data defined in Yang
+ * Generates JSON Schema for data defined in YANG.
  */
 @NotThreadSafe
 public class ModelGenerator {
@@ -123,7 +123,7 @@ public class ModelGenerator {
     }
 
     private void processModules(final Module module, final JSONObject models) throws JSONException {
-        createConcreteModelForPost(models, module.getName()+ BaseYangSwaggerGenerator.MODULE_NAME_SUFFIX, createPropertiesForPost(module));
+        createConcreteModelForPost(models, module.getName() + BaseYangSwaggerGenerator.MODULE_NAME_SUFFIX, createPropertiesForPost(module));
     }
 
     private void processContainersAndLists(final Module module, final JSONObject models, final SchemaContext schemaContext)
@@ -182,7 +182,6 @@ public class ModelGenerator {
      *            The module from which the identity stmt will be processed
      * @param models
      *            The JSONObject in which the parsed identity will be put as a 'model' obj
-     * @throws JSONException
      */
     private static void processIdentities(final Module module, final JSONObject models) throws JSONException {
 
@@ -229,13 +228,7 @@ public class ModelGenerator {
     }
 
     /**
-     * Processes the container and list nodes and populates the moduleJSON
-     *
-     * @param container
-     * @param moduleName
-     * @param isConfig
-     * @throws JSONException
-     * @throws IOException
+     * Processes the container and list nodes and populates the moduleJSON.
      */
     private JSONObject processDataNodeContainer(final DataNodeContainer dataNode, final String moduleName, final JSONObject models,
             final SchemaContext schemaContext) throws JSONException, IOException {
@@ -295,7 +288,7 @@ public class ModelGenerator {
                 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){
+            } else if (childNode instanceof LeafSchemaNode) {
                 JSONObject property = processLeafNode((LeafSchemaNode)childNode);
                 properties.put(childNode.getQName().getLocalName(), property);
             }
@@ -309,18 +302,11 @@ public class ModelGenerator {
     }
 
     /**
-     * Processes the nodes
-     *
-     * @param nodes
-     * @param parentQName
-     * @param moduleName
-     * @param isConfig
-     * @return
-     * @throws JSONException
-     * @throws IOException
+     * Processes the nodes.
      */
-    private JSONObject processChildren(final Iterable<DataSchemaNode> nodes, final QName parentQName, final String moduleName,
-            final JSONObject models, final boolean isConfig, final SchemaContext schemaContext) throws JSONException, IOException {
+    private JSONObject processChildren(final Iterable<DataSchemaNode> nodes, final QName parentQName,
+            final String moduleName, final JSONObject models, final boolean isConfig, final SchemaContext schemaContext)
+            throws JSONException, IOException {
 
         JSONObject properties = new JSONObject();
 
@@ -359,11 +345,6 @@ public class ModelGenerator {
         return properties;
     }
 
-    /**
-     *
-     * @param listNode
-     * @throws JSONException
-     */
     private JSONObject processLeafListNode(final LeafListSchemaNode listNode) throws JSONException {
         JSONObject props = new JSONObject();
         props.put(TYPE_KEY, ARRAY_TYPE);
@@ -378,13 +359,6 @@ public class ModelGenerator {
         return props;
     }
 
-    /**
-     *
-     * @param choiceNode
-     * @param moduleName
-     * @throws JSONException
-     * @throws IOException
-     */
     private JSONObject processChoiceNode(final ChoiceSchemaNode choiceNode, final String moduleName, final JSONObject models,
             final SchemaContext schemaContext) throws JSONException, IOException {
 
@@ -408,12 +382,6 @@ public class ModelGenerator {
         return oneOfProps;
     }
 
-    /**
-     *
-     * @param constraints
-     * @param props
-     * @throws JSONException
-     */
     private static void processConstraints(final ConstraintDefinition constraints, final JSONObject props) throws JSONException {
         boolean isMandatory = constraints.isMandatory();
         props.put(REQUIRED_KEY, isMandatory);
@@ -428,12 +396,6 @@ public class ModelGenerator {
         }
     }
 
-    /**
-     *
-     * @param leafNode
-     * @return
-     * @throws JSONException
-     */
     private JSONObject processLeafNode(final LeafSchemaNode leafNode) throws JSONException {
         JSONObject property = new JSONObject();
 
@@ -446,12 +408,6 @@ public class ModelGenerator {
         return property;
     }
 
-    /**
-     *
-     * @param leafNode
-     * @return
-     * @throws JSONException
-     */
     private static JSONObject processAnyXMLNode(final AnyXmlSchemaNode leafNode) throws JSONException {
         JSONObject property = new JSONObject();
 
@@ -463,12 +419,7 @@ public class ModelGenerator {
         return property;
     }
 
-    /**
-     * @param property
-     * @throws JSONException
-     */
     private void processTypeDef(final TypeDefinition<?> leafTypeDef, final JSONObject property) throws JSONException {
-
         if (leafTypeDef instanceof ExtendedType) {
             processExtendedType(leafTypeDef, property);
         } else if (leafTypeDef instanceof BinaryTypeDefinition) {
@@ -478,7 +429,8 @@ public class ModelGenerator {
         } else if (leafTypeDef instanceof EnumTypeDefinition) {
             processEnumType((EnumTypeDefinition) leafTypeDef, property);
         } else if (leafTypeDef instanceof IdentityrefTypeDefinition) {
-            property.putOpt(TYPE_KEY, ((IdentityrefTypeDefinition) leafTypeDef).getIdentity().getQName().getLocalName());
+            property.putOpt(TYPE_KEY,
+                    ((IdentityrefTypeDefinition) leafTypeDef).getIdentity().getQName().getLocalName());
         } else if (leafTypeDef instanceof StringTypeDefinition) {
             processStringType((StringTypeDefinition) leafTypeDef, property);
         } else if (leafTypeDef instanceof UnionTypeDefinition) {
@@ -492,12 +444,6 @@ public class ModelGenerator {
         }
     }
 
-    /**
-     *
-     * @param leafTypeDef
-     * @param property
-     * @throws JSONException
-     */
     private void processExtendedType(final TypeDefinition<?> leafTypeDef, final JSONObject property) throws JSONException {
         TypeDefinition<?> leafBaseType = leafTypeDef.getBaseType();
         if (leafBaseType instanceof ExtendedType) {
@@ -524,27 +470,15 @@ public class ModelGenerator {
         property.put(MEDIA_KEY, media);
     }
 
-    /**
-     *
-     * @param enumLeafType
-     * @param property
-     * @throws JSONException
-     */
     private static void processEnumType(final EnumTypeDefinition enumLeafType, final JSONObject property) throws JSONException {
         List<EnumPair> enumPairs = enumLeafType.getValues();
-        List<String> enumNames = new ArrayList<String>();
+        List<String> enumNames = new ArrayList<>();
         for (EnumPair enumPair : enumPairs) {
             enumNames.add(enumPair.getName());
         }
         property.putOpt(ENUM, new JSONArray(enumNames));
     }
 
-    /**
-     *
-     * @param bitsType
-     * @param property
-     * @throws JSONException
-     */
     private static void processBitsType(final BitsTypeDefinition bitsType, final JSONObject property) throws JSONException {
         property.put(TYPE_KEY, ARRAY_TYPE);
         property.put(MIN_ITEMS, 0);
@@ -564,8 +498,8 @@ public class ModelGenerator {
         StringTypeDefinition type = stringType;
         List<LengthConstraint> lengthConstraints = stringType.getLengthConstraints();
         while (lengthConstraints.isEmpty() && type.getBaseType() != null) {
-           type = type.getBaseType();
-           lengthConstraints = type.getLengthConstraints();
+            type = type.getBaseType();
+            lengthConstraints = type.getLengthConstraints();
         }
 
         // FIXME: json-schema is not expressive enough to capture min/max laternatives. We should find the true minimum
@@ -580,14 +514,7 @@ public class ModelGenerator {
         property.put(TYPE_KEY, STRING);
     }
 
-    /**
-     *
-     * @param unionType
-     * @param property
-     * @throws JSONException
-     */
     private static void processUnionType(final UnionTypeDefinition unionType, final JSONObject property) throws JSONException {
-
         StringBuilder type = new StringBuilder();
         for (TypeDefinition<?> typeDef : unionType.getTypes()) {
             if (type.length() > 0) {
@@ -601,9 +528,6 @@ public class ModelGenerator {
 
     /**
      * Helper method to generate a pre-filled JSON schema object.
-     *
-     * @return
-     * @throws JSONException
      */
     private static JSONObject getSchemaTemplate() throws JSONException {
         JSONObject schemaJSON = new JSONObject();
index 8208c8102caa842e04c5e312ae22e85e2f416985..de4e0a966f2f534500b63febb05c297c0d3c07a8 100644 (file)
@@ -33,13 +33,11 @@ public class JaxbContextResolver implements ContextResolver<ObjectMapper> {
     }
 
     @Override
-    public ObjectMapper getContext(Class<?> aClass) {
-
-        if (ApiDeclaration.class.isAssignableFrom(aClass)) {
+    public ObjectMapper getContext(Class<?> klass) {
+        if (ApiDeclaration.class.isAssignableFrom(klass)) {
             return ctx;
         }
 
-        return null;// must return null so that jax-rs can continue context
-                    // search
+        return null; // must return null so that JAX-RS can continue context search
     }
 }
index d4f01744cd0e2f629657edcf55584ed4f24a87e1..98f8af76d838163bf05d2eb938298dc2b6812955 100644 (file)
@@ -22,6 +22,7 @@ public final class OperationBuilder {
     public static final String CONFIG = "(config)";
 
     public static final List<String> CONSUMES_PUT_POST = new ArrayList<>();
+
     static {
         CONSUMES_PUT_POST.add("application/json");
         CONSUMES_PUT_POST.add("application/xml");
@@ -110,7 +111,7 @@ public final class OperationBuilder {
                     Parameter payload = new Parameter();
                     payload.setParamType("body");
                     payload.setType(CONFIG + node.getQName().getLocalName());
-                    payload.setName("**"+CONFIG + node.getQName().getLocalName());
+                    payload.setName("**" + CONFIG + node.getQName().getLocalName());
                     parameters.add(payload);
                 }
             }
index b20aa967b9e66f38a37cb1ee59e353a51190c15d..89a75b0c2834d9f27bd2671935bbaa0068f869d9 100644 (file)
@@ -9,7 +9,6 @@ package org.opendaylight.netconf.sal.rest.doc.mountpoints;
 
 import com.google.common.base.Optional;
 import java.util.Collections;
-import java.util.Comparator;
 import java.util.HashMap;
 import java.util.LinkedList;
 import java.util.List;
@@ -43,12 +42,7 @@ public class MountPointSwagger extends BaseYangSwaggerGenerator implements Mount
 
     private DOMMountPointService mountService;
     private final Map<YangInstanceIdentifier, Long> instanceIdToLongId = new TreeMap<>(
-            new Comparator<YangInstanceIdentifier>() {
-                @Override
-                public int compare(final YangInstanceIdentifier o1, final YangInstanceIdentifier o2) {
-                    return o1.toString().compareToIgnoreCase(o2.toString());
-                }
-            });
+            (o1, o2) -> o1.toString().compareToIgnoreCase(o2.toString()));
     private final Map<Long, YangInstanceIdentifier> longIdToInstanceId = new HashMap<>();
     private final Object lock = new Object();
 
@@ -116,7 +110,6 @@ public class MountPointSwagger extends BaseYangSwaggerGenerator implements Mount
             return null; // indicating not found.
         }
         SchemaContext context = getSchemaContext(iid);
-        String urlPrefix = getYangMountUrl(iid);
         if (context == null) {
             return createResourceList();
         }
@@ -125,6 +118,7 @@ public class MountPointSwagger extends BaseYangSwaggerGenerator implements Mount
         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);
         resources.addAll(list.getApis());
         list.setApis(resources);
@@ -172,8 +166,6 @@ public class MountPointSwagger extends BaseYangSwaggerGenerator implements Mount
     }
 
     private ApiDeclaration generateDataStoreApiDoc(final UriInfo uriInfo, final String context) {
-
-        ApiDeclaration declaration = super.createApiDeclaration(createBasePathFromUriInfo(uriInfo));
         List<Api> apis = new LinkedList<>();
         apis.add(createGetApi("config",
                 "Queries the config (startup) datastore on the mounted hosted.", context));
@@ -181,6 +173,8 @@ public class MountPointSwagger extends BaseYangSwaggerGenerator implements Mount
                 "Queries the operational (running) datastore on the mounted hosted.", context));
         apis.add(createGetApi("operations",
                 "Queries the available operations (RPC calls) on the mounted hosted.", context));
+
+        ApiDeclaration declaration = super.createApiDeclaration(createBasePathFromUriInfo(uriInfo));
         declaration.setApis(apis);
         return declaration;
 
index 697fdcc00ff474249b13d9d5cbe3e79bac367724..55d92c73f6b3b1a6c8fbf92f6127b8c8c20a0241 100644 (file)
@@ -22,13 +22,14 @@ public class RestDocgenUtil {
     private RestDocgenUtil() {
     }
 
-    private static Map<URI, Map<Date, Module>> namespaceAndRevisionToModule = new HashMap<URI, Map<Date, Module>>();
+    private static Map<URI, Map<Date, Module>> namespaceAndRevisionToModule = new HashMap<>();
 
     /**
      * Resolve path argument name for {@code node}.
      *
-     * The name can contain also prefix which consists of module name followed by colon. The module prefix is presented
-     * if namespace of {@code node} and its parent is different. In other cases only name of {@code node} is returned.
+     * <p>The name can contain also prefix which consists of module name followed by colon. The module
+     * prefix is presented if namespace of {@code node} and its parent is different. In other cases
+     * only name of {@code node} is returned.
      *
      * @return name of {@code node}
      */
@@ -48,7 +49,8 @@ public class RestDocgenUtil {
         }
     }
 
-    private synchronized static String resolveFullNameFromNode(final SchemaNode node, final SchemaContext schemaContext) {
+    private static synchronized String resolveFullNameFromNode(final SchemaNode node,
+            final SchemaContext schemaContext) {
         final URI namespace = node.getQName().getNamespace();
         final Date revision = node.getQName().getRevision();
 
@@ -68,7 +70,8 @@ public class RestDocgenUtil {
         return node.getQName().getLocalName();
     }
 
-    public static String resolveNodesName(final SchemaNode node, final Module module, final SchemaContext schemaContext) {
+    public static String resolveNodesName(final SchemaNode node, final Module module,
+            final SchemaContext schemaContext) {
         if (node.getQName().getNamespace().equals(module.getQNameModule().getNamespace())
                 && node.getQName().getRevision().equals(module.getQNameModule().getRevision())) {
             return node.getQName().getLocalName();