/** * Creates a new {@link LocalizedString} where all translations are slugified (remove whitespace, etc.). * * {@include.example io.sphere.sdk.models.LocalizedStringTest#slugified()} * * @return new instance */ public LocalizedString slugified() { return mapValue((locale, value) -> slugify(value)); }
/** * Creates a new {@link LocalizedString} where all translations are slugified (remove whitespace, etc.) and a random supplement is added. * This slugify methods appends a random string for a little uniqueness. * * {@include.example io.sphere.sdk.models.LocalizedStringTest#slugifyUniqueDemo()} * * @return new instance */ public LocalizedString slugifiedUnique() { return mapValue((locale, value) -> slugifyUnique(value)); }
@Test public void mapValue() throws Exception { final LocalizedString upperCased = LocalizedString.of(Locale.GERMAN, "Hundefutter", Locale.ENGLISH, "dog food") .mapValue((locale, value) -> value.toUpperCase(locale)); assertThat(upperCased).isEqualTo(LocalizedString.of(Locale.GERMAN, "HUNDEFUTTER", Locale.ENGLISH, "DOG FOOD")); }