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

io.avaje.validation.core.LocaleResolver Maven / Gradle / Ivy

Go to download

validator for annotated pojos using constraint annotations and source code generation

There is a newer version: 2.9
Show newest version
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