Package org.incendo.cloud.translations
Interface LocaleExtractor.Builder<C>
- Type Parameters:
C- command sender type
- Enclosing interface:
- LocaleExtractor<C>
public static interface LocaleExtractor.Builder<C>
Builder for a
LocaleExtractor that delegates to functions based on
command sender type.-
Method Summary
Modifier and TypeMethodDescriptionbuild()Builds aLocaleExtractorfrom the state of this builder.default @NonNull LocaleExtractor.Builder<C>Setsfallback(LocaleExtractor)with a constant locale.fallback(@NonNull LocaleExtractor<C> fallback) Sets the fallbackLocaleExtractorfor when none of the configuredsenderType(TypeToken, Function)extractors match the sender.<S extends C>
@NonNull LocaleExtractor.Builder<C>Registers a locale extractor for a specific sender type to this builder.default <S extends C>
@NonNull LocaleExtractor.Builder<C>Registers a locale extractor for a specific sender type to this builder.
-
Method Details
-
fallback
Sets the fallbackLocaleExtractorfor when none of the configuredsenderType(TypeToken, Function)extractors match the sender. Defaults toLocaleExtractor<C> default = recipient -> Locale.getDefault().- Parameters:
fallback- fallback extractor- Returns:
- this builder
-
fallback
Setsfallback(LocaleExtractor)with a constant locale.- Parameters:
fallback- fallback locale- Returns:
- this builder
-
senderType
<S extends C> @NonNull LocaleExtractor.Builder<C> senderType(@NonNull TypeToken<S> senderType, @NonNull Function<S, @Nullable Locale> extractor) Registers a locale extractor for a specific sender type to this builder.Extractors are tried in LIFO registration order. Extractors may return
nullto pass the recipient to the next extractor, even when the type matches.- Type Parameters:
S- specific command sender type- Parameters:
senderType- specific command sender typeextractor- locale extractor- Returns:
- this builder
-
senderType
default <S extends C> @NonNull LocaleExtractor.Builder<C> senderType(@NonNull Class<S> senderType, @NonNull Function<S, @Nullable Locale> extractor) Registers a locale extractor for a specific sender type to this builder.Extractors are tried in LIFO registration order. Extractors may return
nullto pass the recipient to the next extractor, even when the type matches.- Type Parameters:
S- specific command sender type- Parameters:
senderType- specific command sender typeextractor- locale extractor- Returns:
- this builder
-
build
@NonNull LocaleExtractor<C> build()Builds aLocaleExtractorfrom the state of this builder.- Returns:
- new locale extractor
-