BUG-4351: remove use of commons-lang from sal-rest-docgen 75/29675/3
authorRobert Varga <robert.varga@pantheon.sk>
Fri, 13 Nov 2015 18:54:30 +0000 (19:54 +0100)
committerRobert Varga <robert.varga@pantheon.sk>
Sat, 14 Nov 2015 13:46:52 +0000 (14:46 +0100)
Simple internal use of null-for-true. Fixup methods and also make
potentially-static methods static.

Change-Id: I1d3d3e48332e24b0b667a7ac189e72e213f95d81
Signed-off-by: Robert Varga <robert.varga@pantheon.sk>
opendaylight/restconf/sal-rest-docgen/pom.xml
opendaylight/restconf/sal-rest-docgen/src/main/java/org/opendaylight/netconf/sal/rest/doc/impl/ModelGenerator.java

index f31d1dc572be3196a4fc55f75b05820fc6683461..2a14fe28aaa8f0f44cfb53b1dc80b9c6440e033c 100644 (file)
       <artifactId>guava</artifactId>
     </dependency>
 
-    <dependency>
-      <groupId>org.apache.commons</groupId>
-      <artifactId>commons-lang3</artifactId>
-    </dependency>
-
     <!-- Jax rs -->
     <dependency>
       <groupId>org.jboss.resteasy</groupId>
index bb7a50e7a49d82658dd354578176add780a8d357..40a163b57ab7395b84e51b03045c0b7d79b89c3f 100644 (file)
@@ -17,7 +17,6 @@ import java.util.List;
 import java.util.Map;
 import java.util.Set;
 import javax.annotation.concurrent.NotThreadSafe;
-import org.apache.commons.lang3.BooleanUtils;
 import org.json.JSONArray;
 import org.json.JSONException;
 import org.json.JSONObject;
@@ -197,7 +196,7 @@ public class ModelGenerator {
      *            The JSONObject in which the parsed identity will be put as a 'model' obj
      * @throws JSONException
      */
-    private void processIdentities(final Module module, final JSONObject models) throws JSONException {
+    private static void processIdentities(final Module module, final JSONObject models) throws JSONException {
 
         String moduleName = module.getName();
         Set<IdentitySchemaNode> idNodes = module.getIdentities();
@@ -252,19 +251,19 @@ public class ModelGenerator {
      */
     private JSONObject processDataNodeContainer(final DataNodeContainer dataNode, final String moduleName, final JSONObject models,
             final SchemaContext schemaContext) throws JSONException, IOException {
-        return processDataNodeContainer(dataNode, moduleName, models, (Boolean) null, schemaContext);
+        return processDataNodeContainer(dataNode, moduleName, models, true, schemaContext);
     }
 
     private JSONObject processDataNodeContainer(final DataNodeContainer dataNode, final String moduleName, final JSONObject models,
-            final Boolean isConfig, final SchemaContext schemaContext) throws JSONException, IOException {
+            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,
                     models, isConfig, schemaContext);
 
-            String nodeName = (BooleanUtils.isNotFalse(isConfig) ? OperationBuilder.CONFIG
-                    : OperationBuilder.OPERATIONAL) + ((SchemaNode) dataNode).getQName().getLocalName();
+            String nodeName = (isConfig ? OperationBuilder.CONFIG : OperationBuilder.OPERATIONAL)
+                    + ((SchemaNode) dataNode).getQName().getLocalName();
 
             JSONObject childSchema = getSchemaTemplate();
             childSchema.put(TYPE_KEY, OBJECT_TYPE);
@@ -272,7 +271,7 @@ public class ModelGenerator {
             childSchema.put("id", nodeName);
             models.put(nodeName, childSchema);
 
-            if (BooleanUtils.isNotFalse(isConfig)) {
+            if (isConfig) {
                 createConcreteModelForPost(models, ((SchemaNode) dataNode).getQName().getLocalName(),
                         createPropertiesForPost(dataNode));
             }
@@ -288,8 +287,8 @@ public class ModelGenerator {
         return null;
     }
 
-    private void createConcreteModelForPost(final JSONObject models, final String localName, final JSONObject properties)
-            throws JSONException {
+    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();
         postSchema.put(TYPE_KEY, OBJECT_TYPE);
@@ -318,7 +317,7 @@ public class ModelGenerator {
 
     private JSONObject processChildren(final Iterable<DataSchemaNode> nodes, final QName parentQName, final String moduleName,
             final JSONObject models, final SchemaContext schemaContext) throws JSONException, IOException {
-        return processChildren(nodes, parentQName, moduleName, models, null, schemaContext);
+        return processChildren(nodes, parentQName, moduleName, models, true, schemaContext);
     }
 
     /**
@@ -333,12 +332,12 @@ public class ModelGenerator {
      * @throws 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 {
+            final JSONObject models, final boolean isConfig, final SchemaContext schemaContext) throws JSONException, IOException {
 
         JSONObject properties = new JSONObject();
 
         for (DataSchemaNode node : nodes) {
-            if (isConfig == null || node.isConfiguration() == isConfig) {
+            if (node.isConfiguration() == isConfig) {
 
                 String name = resolveNodesName(node, topLevelModule, schemaContext);
                 JSONObject property = null;
@@ -427,7 +426,7 @@ public class ModelGenerator {
      * @param props
      * @throws JSONException
      */
-    private void processConstraints(final ConstraintDefinition constraints, final JSONObject props) throws JSONException {
+    private static void processConstraints(final ConstraintDefinition constraints, final JSONObject props) throws JSONException {
         boolean isMandatory = constraints.isMandatory();
         props.put(REQUIRED_KEY, isMandatory);
 
@@ -465,7 +464,7 @@ public class ModelGenerator {
      * @return
      * @throws JSONException
      */
-    private JSONObject processAnyXMLNode(final AnyXmlSchemaNode leafNode) throws JSONException {
+    private static JSONObject processAnyXMLNode(final AnyXmlSchemaNode leafNode) throws JSONException {
         JSONObject property = new JSONObject();
 
         String leafDescription = leafNode.getDescription();
@@ -532,10 +531,7 @@ public class ModelGenerator {
 
     }
 
-    /*
-   *
-   */
-    private void processBinaryType(final BinaryTypeDefinition binaryType, final JSONObject property) throws JSONException {
+    private static void processBinaryType(final BinaryTypeDefinition binaryType, final JSONObject property) throws JSONException {
         property.put(TYPE_KEY, STRING);
         JSONObject media = new JSONObject();
         media.put(BINARY_ENCODING_KEY, BASE_64);
@@ -548,7 +544,7 @@ public class ModelGenerator {
      * @param property
      * @throws JSONException
      */
-    private void processEnumType(final EnumerationType enumLeafType, final JSONObject property) throws JSONException {
+    private static void processEnumType(final EnumerationType enumLeafType, final JSONObject property) throws JSONException {
         List<EnumPair> enumPairs = enumLeafType.getValues();
         List<String> enumNames = new ArrayList<String>();
         for (EnumPair enumPair : enumPairs) {
@@ -563,7 +559,7 @@ public class ModelGenerator {
      * @param property
      * @throws JSONException
      */
-    private void processBitsType(final BitsTypeDefinition bitsType, final JSONObject 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);
         property.put(UNIQUE_ITEMS_KEY, true);
@@ -584,7 +580,7 @@ public class ModelGenerator {
      * @param property
      * @throws JSONException
      */
-    private void processUnionType(final UnionTypeDefinition unionType, final JSONObject property) throws JSONException {
+    private static void processUnionType(final UnionTypeDefinition unionType, final JSONObject property) throws JSONException {
 
         StringBuilder type = new StringBuilder();
         for (TypeDefinition<?> typeDef : unionType.getTypes()) {
@@ -603,7 +599,7 @@ public class ModelGenerator {
      * @return
      * @throws JSONException
      */
-    private JSONObject getSchemaTemplate() throws JSONException {
+    private static JSONObject getSchemaTemplate() throws JSONException {
         JSONObject schemaJSON = new JSONObject();
         schemaJSON.put(SCHEMA_KEY, SCHEMA_URL);