+/*
+ * 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;
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;
sb.append("\n");
}
}
- intends += StringUtils.countMatches(line, "{");
+ indents += StringUtils.countMatches(line, "{");
}
return ensureEndsWithSingleNewLine(sb.toString());
}