AnnoUtils.java
/*
* SPDX-FileCopyrightText: 2026 kaumei.io
* SPDX-License-Identifier: Apache-2.0
*/
package io.kaumei.jdbc.anno.utils;
import org.jspecify.annotations.Nullable;
import java.util.Collections;
import java.util.LinkedHashSet;
import java.util.Set;
import java.util.function.Supplier;
public final class AnnoUtils {
private AnnoUtils() {
}
public static <T> T requireState(@Nullable T value, Supplier<String> messageSupplier) {
if (value == null) {
throw new IllegalStateException(messageSupplier.get());
}
return value;
}
public static <T> T requireState(@Nullable T value, String message) {
if (value == null) {
throw new IllegalStateException(message);
}
return value;
}
public static <T> Set<T> immutableSet(T[] elements) {
var set = new LinkedHashSet<T>(elements.length);
Collections.addAll(set, elements);
return Collections.unmodifiableSet(set);
}
}