tech.kronicle.utils.EnumUtils Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of kronicle-utils Show documentation
Show all versions of kronicle-utils Show documentation
Kronicle utils library that contains utility classes for use by Kronicle and its plugins
package tech.kronicle.utils;
import tech.kronicle.common.CaseUtils;
import java.util.List;
import java.util.stream.Collectors;
import static java.util.Objects.isNull;
import static java.util.Objects.requireNonNull;
public final class EnumUtils {
public static > List getEnumListFromJsonValues(Class enumType, List values) {
requireNonNull(enumType, "enumType");
if (isNull(values)) {
return List.of();
}
return values.stream()
.map(value -> getEnumFromJsonValue(enumType, value))
.collect(Collectors.toList());
}
public static > T getEnumFromJsonValue(Class enumType, String value) {
requireNonNull(enumType, "enumType");
return Enum.valueOf(enumType, CaseUtils.toScreamingSnakeCase(value));
}
private EnumUtils() {
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy