![JAR search and dependency download from the Maven repository](/logo.png)
io.evitadb.utils.NamingConvention Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of evita_common Show documentation
Show all versions of evita_common Show documentation
Module contains external API of the evitaDB.
/*
*
* _ _ ____ ____
* _____ _(_) |_ __ _| _ \| __ )
* / _ \ \ / / | __/ _` | | | | _ \
* | __/\ V /| | || (_| | |_| | |_) |
* \___| \_/ |_|\__\__,_|____/|____/
*
* Copyright (c) 2023-2024
*
* Licensed under the Business Source License, Version 1.1 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://github.com/FgForrest/evitaDB/blob/master/LICENSE
*
* 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 io.evitadb.utils;
import io.evitadb.exception.GenericEvitaInternalError;
import javax.annotation.Nonnull;
import java.util.Arrays;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;
/**
* String cases that are supported to convert strings to.
*
* @author Lukáš Hornych, FG Forrest a.s. (c) 2022
*/
public enum NamingConvention {
/**
* Camel case.
*
* @see Camel case
*/
CAMEL_CASE,
/**
* Pascal case.
*
* @see Pascal case
*/
PASCAL_CASE,
/**
* Snake case.
*
* @see Snake case
*/
SNAKE_CASE,
/**
* Capitalized snake case.
*
* @see Snake case
*/
UPPER_SNAKE_CASE,
/**
* Kebab case.
*
* @see Kebab case
*/
KEBAB_CASE;
private static final NamingConvention[] ALL_CONVENTIONS = NamingConvention.values();
/**
* Method generates all name variants in all supported naming conventions.
*
* @param name to translate
* @return index of translated names indexed by name convention
*/
public static Map generate(@Nonnull String name) {
return Collections.unmodifiableMap(
Arrays.stream(ALL_CONVENTIONS)
.collect(
Collectors.toMap(
Function.identity(),
it -> StringUtils.toSpecificCase(name, it),
(s, s2) -> { throw new GenericEvitaInternalError("Should not ever occur!"); },
LinkedHashMap::new
)
)
);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy