All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.jinahya.kftc.financial.institution.info._StringUtils Maven / Gradle / Ivy

package com.github.jinahya.kftc.financial.institution.info;

/*-
 * #%L
 * kftc-financial-institution-info
 * %%
 * Copyright (C) 2024 Jinahya, Inc.
 * %%
 * 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
 *
 *      http://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.
 * #L%
 */

import java.util.Objects;

@SuppressWarnings({"java:S101"})
final class _StringUtils {

    static int half(final int c) {
        if (c >= '!' && c <= '~') {
            return c - 0xfee0;
        }
        if (c == 0x3000) {
            return 0x20;
        }
        return c;
    }

    static String half(final String string) {
        Objects.requireNonNull(string, "string is null");
        final var codePoints = string.codePoints().map(_StringUtils::half).toArray();
        return new String(codePoints, 0, codePoints.length);
    }

    private _StringUtils() {
        throw new AssertionError("instantiation is not allowed");
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy