Class DefaultLocalizedPopulator
java.lang.Object
de.hybris.platform.cmsfacades.common.populator.impl.DefaultLocalizedPopulator
- All Implemented Interfaces:
LocalizedPopulator
Default implementation for the
LocalizedPopulator interface.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected Stream<LanguageData>Gets all the languages supported.protected CMSUserServiceprotected CommonI18NServiceprotected LanguageFacade<T> voidpopulate(BiConsumer<Locale, T> consumer, Function<Locale, T> function) Bi-directional method to populate the localized attributes.voidsetCmsUserService(CMSUserService cmsUserService) voidsetCommonI18NService(CommonI18NService commonI18NService) voidsetLanguageFacade(LanguageFacade languageFacade) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface de.hybris.platform.cmsfacades.common.populator.LocalizedPopulator
getLanguage, populateAsMapOfLanguages, populateAsMapOfLocales
-
Constructor Details
-
DefaultLocalizedPopulator
public DefaultLocalizedPopulator()
-
-
Method Details
-
populate
Description copied from interface:LocalizedPopulatorBi-directional method to populate the localized attributes. It can be used to populate Model classes by reading the content from thegetterfunction, and also populate localizedMaps by reading content from a localized data model. This method will iterate over all locales (Locale) available at the execution time. For each locale, it will execute the functiongetterto get the localized value that may be coming from different sources (see examples bellow). The result of thegetterfunction will then be used on theBiConsumersetterfunction. Examples of its usage: Populate aMap<String, String>from a localized modelfinal Map<String, String> map = new HashMap<>(); getLocalizedPopulator().populate( (locale, value) -> map.put(getLocalizedPopulator().getLanguage(locale), value), (locale) -> source.getSomeLocalizedField(locale) );* Populate anItemModelfrom a localizedMap<String, String>// source.getTitle() returns Map<String, String> Optional.ofNullable(source.getTitle()) .ifPresent(title -> getLocalizedPopulator() .populate((locale, value) -> target.setTitle(value, locale), (locale) -> title.get(getLocalizedPopulator().getLanguage(locale))));- Specified by:
populatein interfaceLocalizedPopulator- Parameters:
consumer- ABiConsumerfunction that will accept the Locale and the Value extracted from thegetterfunction.function- AFunctionthat will be applied to get the localized value for a givenLocale.
-
getAllLanguages
Gets all the languages supported.- Returns:
- - a Map containing all the required locales where the keys maps the
Locale.getLanguage()to a boolean value, indicating if the language is the default language.
-
getLanguageFacade
-
setLanguageFacade
-
getCommonI18NService
-
setCommonI18NService
-
getCmsUserService
-
setCmsUserService
-