OutputUtilities.java

/*
 *    Copyright 2006-2026 the original author or authors.
 *
 *    Licensed under the Apache License, Version 2.0 (the "License");
 *    you may not use this file except in compliance with the License.
 *    You may obtain a copy of the License at
 *
 *       https://www.apache.org/licenses/LICENSE-2.0
 *
 *    Unless required by applicable law or agreed to in writing, software
 *    distributed under the License is distributed on an "AS IS" BASIS,
 *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *    See the License for the specific language governing permissions and
 *    limitations under the License.
 */
package org.mybatis.generator.api.dom;

public class OutputUtilities {

    /**
     * Utility class - no instances allowed.
     */
    private OutputUtilities() {
        super();
    }

    /**
     * Utility method that indents the buffer by the default amount for Java
     * (four spaces per indent level).
     *
     * @param sb
     *            a StringBuilder to append to
     * @param indentLevel
     *            the required indent level
     */
    public static void javaIndent(StringBuilder sb, int indentLevel) {
        sb.append(javaIndent(indentLevel));
    }

    public static String javaIndent(int indentLevel) {
        return "    ".repeat(indentLevel); //$NON-NLS-1$
    }

    /**
     * Utility method that indents the buffer by the default amount for Kotlin
     * (four spaces per indent level).
     *
     * @param sb
     *            a StringBuilder to append to
     * @param indentLevel
     *            the required indent level
     */
    public static void kotlinIndent(StringBuilder sb, int indentLevel) {
        sb.append(kotlinIndent(indentLevel));
    }

    public static String kotlinIndent(int indentLevel) {
        return "    ".repeat(indentLevel); //$NON-NLS-1$
    }

    /**
     * Utility method that indents the buffer by the default amount for XML (two
     * spaces per indent level).
     *
     * @param sb
     *            a StringBuilder to append to
     * @param indentLevel
     *            the required indent level
     */
    public static void xmlIndent(StringBuilder sb, int indentLevel) {
        sb.append(xmlIndent(indentLevel));
    }

    public static String xmlIndent(int indentLevel) {
        return "  ".repeat(indentLevel); //$NON-NLS-1$
    }
}