Yang code generator cleanup
[controller.git] / opendaylight / config / yang-jmx-generator-plugin / src / main / java / org / opendaylight / controller / config / yangjmxgenerator / plugin / util / StringUtil.java
index bcc55a203eb05a17aa6cb7b386e649f9f69d7043..02ab91b817cb20bda841c4cc671076d41cba49da 100644 (file)
@@ -1,19 +1,26 @@
+/*
+ * Copyright (c) 2013, 2015 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
 package org.opendaylight.controller.config.yangjmxgenerator.plugin.util;
 
 import com.google.common.base.Joiner;
 import com.google.common.base.Optional;
 import com.google.common.base.Splitter;
 import com.google.common.base.Strings;
+import java.util.List;
+import java.util.regex.Pattern;
 import org.apache.commons.lang3.StringUtils;
 import org.opendaylight.controller.config.yangjmxgenerator.plugin.java.FullyQualifiedName;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import java.util.List;
-import java.util.regex.Pattern;
-
 public class StringUtil {
-    private static final Logger logger = LoggerFactory.getLogger(StringUtils.class);
+    private static final Logger LOG = LoggerFactory.getLogger(StringUtil.class);
 
     /**
      * @param list   of strings to be joined by ','
@@ -66,7 +73,7 @@ public class StringUtil {
                     return Optional.of(IOUtils.toString(in));
                 }
             } catch (IOException e) {
-                logger.warn("Cannot load copyright.txt", e);
+                LOG.warn("Cannot load copyright.txt", e);
             }
 
         */
@@ -78,14 +85,14 @@ public class StringUtil {
 
         int basicIndent = 4;
         StringBuilder sb = new StringBuilder();
-        int intends = 0, empty = 0;
+        int indents = 0, empty = 0;
         for (String line : split) {
-            intends -= StringUtils.countMatches(line, "}");
-            if (intends < 0) {
-                intends = 0;
+            indents -= StringUtils.countMatches(line, "}");
+            if (indents < 0) {
+                indents = 0;
             }
-            if (line.isEmpty() == false) {
-                sb.append(Strings.repeat(" ", basicIndent * intends));
+            if (!line.isEmpty()) {
+                sb.append(Strings.repeat(" ", basicIndent * indents));
                 sb.append(line);
                 sb.append("\n");
                 empty = 0;
@@ -95,7 +102,7 @@ public class StringUtil {
                     sb.append("\n");
                 }
             }
-            intends += StringUtils.countMatches(line, "{");
+            indents += StringUtils.countMatches(line, "{");
         }
         return ensureEndsWithSingleNewLine(sb.toString());
     }