View Javadoc
1   /*
2    *    Copyright 2006-2026 the original author or authors.
3    *
4    *    Licensed under the Apache License, Version 2.0 (the "License");
5    *    you may not use this file except in compliance with the License.
6    *    You may obtain a copy of the License at
7    *
8    *       https://www.apache.org/licenses/LICENSE-2.0
9    *
10   *    Unless required by applicable law or agreed to in writing, software
11   *    distributed under the License is distributed on an "AS IS" BASIS,
12   *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   *    See the License for the specific language governing permissions and
14   *    limitations under the License.
15   */
16  package org.mybatis.generator.api.dom;
17  
18  public class OutputUtilities {
19  
20      /**
21       * Utility class - no instances allowed.
22       */
23      private OutputUtilities() {
24          super();
25      }
26  
27      /**
28       * Utility method that indents the buffer by the default amount for Java
29       * (four spaces per indent level).
30       *
31       * @param sb
32       *            a StringBuilder to append to
33       * @param indentLevel
34       *            the required indent level
35       */
36      public static void javaIndent(StringBuilder sb, int indentLevel) {
37          sb.append(javaIndent(indentLevel));
38      }
39  
40      public static String javaIndent(int indentLevel) {
41          return "    ".repeat(indentLevel); //$NON-NLS-1$
42      }
43  
44      /**
45       * Utility method that indents the buffer by the default amount for Kotlin
46       * (four spaces per indent level).
47       *
48       * @param sb
49       *            a StringBuilder to append to
50       * @param indentLevel
51       *            the required indent level
52       */
53      public static void kotlinIndent(StringBuilder sb, int indentLevel) {
54          sb.append(kotlinIndent(indentLevel));
55      }
56  
57      public static String kotlinIndent(int indentLevel) {
58          return "    ".repeat(indentLevel); //$NON-NLS-1$
59      }
60  
61      /**
62       * Utility method that indents the buffer by the default amount for XML (two
63       * spaces per indent level).
64       *
65       * @param sb
66       *            a StringBuilder to append to
67       * @param indentLevel
68       *            the required indent level
69       */
70      public static void xmlIndent(StringBuilder sb, int indentLevel) {
71          sb.append(xmlIndent(indentLevel));
72      }
73  
74      public static String xmlIndent(int indentLevel) {
75          return "  ".repeat(indentLevel); //$NON-NLS-1$
76      }
77  }