
io.avaje.validation.core.LocaleResolver Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of avaje-validator Show documentation
Show all versions of avaje-validator Show documentation
validator for annotated pojos using constraint annotations and source code generation
package io.avaje.validation.core;
import java.util.Collection;
import java.util.HashSet;
import java.util.Locale;
import java.util.Set;
import org.jspecify.annotations.Nullable;
final class LocaleResolver {
private final Locale defaultLocale;
private final Set otherLocales = new HashSet<>();
LocaleResolver(Locale defaultLocale, Collection others) {
this.defaultLocale = defaultLocale;
otherLocales.addAll(others);
}
public Locale defaultLocale() {
return defaultLocale;
}
public Set otherLocales() {
return otherLocales;
}
public Locale resolve(@Nullable Locale requestLocale) {
if (requestLocale == null || !otherLocales.contains(requestLocale)) {
return defaultLocale;
}
return requestLocale;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy