/** * Concatenate {@code messages} parameter to the {@code messages} list property of this builder. * * @param messages the value for {@link SubscriptionDraft#getMessages()} * @return this builder */ public SubscriptionDraftBuilder plusMessages(final List<MessageSubscription> messages) { this.messages = SphereInternalUtils.listOf(Optional.ofNullable(this.messages).orElseGet(ArrayList::new), messages); return this; }
public static String slugify(final String s) { return SphereInternalUtils.slugify(s); }
@Test public void usesForSetOfLocalizedEnumJustKey() throws Exception { final AttributeDraft draft = AttributeDraft.of("foo", asSet(green, red)); final Set<String> expected = asSet("green", "red"); final Set<String> actual = objectMapper.readerFor(new TypeReference<Set<String>>() { }).readValue(draft.getValue()); assertThat(actual).isEqualTo(expected); }
/** * Concatenate {@code values} parameter to the {@code values} set property of this builder. * * @param values the value for {@link CartClassificationDraft#getValues()} * @return this builder */ public CartClassificationDraftBuilder plusValues(final Set<LocalizedEnumValue> values) { this.values = SphereInternalUtils.setOf(Optional.ofNullable(this.values).orElseGet(HashSet::new), values); return this; }
protected List<String> normalizeIterable(final Iterable<String> items) { return toStream(items) .map(StringQuerySortingModel::normalize).collect(toList()); }
CategoryTreeImpl(final List<Category> roots, final List<Category> allAsFlatList, final Map<LocalizedStringEntry, Category> categoriesByLocaleAndSlug, final Map<String, Category> categoriesById, final Map<String, Category> categoriesByKey, final Map<String, List<Category>> childrenByParentId, final List<Category> subtreeRoots) { this.childrenByParentId = childrenByParentId; this.roots = immutableCopyOf(roots); this.subtreeRoots = roots == subtreeRoots ? this.roots : immutableCopyOf(subtreeRoots); this.allAsFlatList = immutableCopyOf(allAsFlatList); this.categoriesByLocaleAndSlug = immutableCopyOf(categoriesByLocaleAndSlug); this.categoriesById = immutableCopyOf(categoriesById); this.categoriesByKey = immutableCopyOf(categoriesByKey); }
@JsonIgnore static SearchKeywords of(final Locale locale, final List<SearchKeyword> keywords) { return of(mapOf(locale, keywords)); }
/** * 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 usesForSetOfPlainEnumJustKey() throws Exception { final AttributeDraft draft = AttributeDraft.of("foo", asSet(s, m)); final Set<String> expected = asSet("S", "M"); final Set<String> actual = objectMapper.readerFor(new TypeReference<Set<String>>() { }).readValue(draft.getValue()); assertThat(actual).isEqualTo(expected); }
/** * Concatenate {@code locations} parameter to the {@code locations} set property of this builder. * * @param locations the value for {@link ZoneDraft#getLocations()} * @return this builder */ public ZoneDraftBuilder plusLocations(final Set<Location> locations) { this.locations = SphereInternalUtils.setOf(Optional.ofNullable(this.locations).orElseGet(HashSet::new), locations); return this; }
private List<String> quotify(final Iterable<ZonedDateTime> values) { return toStream(values).map(this::quotify).collect(Collectors.toList()); }
CategoryTreeImpl(final List<Category> roots, final List<Category> allAsFlatList, final Map<LocalizedStringEntry, Category> categoriesByLocaleAndSlug, final Map<String, Category> categoriesById, final Map<String, Category> categoriesByKey, final Map<String, List<Category>> childrenByParentId, final List<Category> subtreeRoots) { this.childrenByParentId = childrenByParentId; this.roots = immutableCopyOf(roots); this.subtreeRoots = roots == subtreeRoots ? this.roots : immutableCopyOf(subtreeRoots); this.allAsFlatList = immutableCopyOf(allAsFlatList); this.categoriesByLocaleAndSlug = immutableCopyOf(categoriesByLocaleAndSlug); this.categoriesById = immutableCopyOf(categoriesById); this.categoriesByKey = immutableCopyOf(categoriesByKey); }
/** * Creates an instance with one locale translation pair. * * {@include.example io.sphere.sdk.models.LocalizedStringTest#createFromOneValue()} * * @param locale the locale for the one translation * @param value the translation for the specified locale * @return translation for one language */ @JsonIgnore public static LocalizedString of(final Locale locale, final String value) { requireNonNull(locale); requireNonNull(value); return of(mapOf(locale, value)); }
@Test public void slugifyUniqueAppendsANumeric() throws Exception { assertThat(SphereInternalUtils.slugifyUnique("alpha")).matches("alpha-\\d{6,14}"); } }
/** * Concatenate {@code transactions} parameter to the {@code transactions} list property of this builder. * * @param transactions the value for {@link PaymentDraft#getTransactions()} * @return this builder */ public PaymentDraftBuilder plusTransactions(final List<TransactionDraft> transactions) { this.transactions = SphereInternalUtils.listOf(Optional.ofNullable(this.transactions).orElseGet(ArrayList::new), transactions); return this; }
/** * Concatenate {@code roles} parameter to the {@code roles} set property of this builder. * * @param roles the value for {@link ChannelDraft#getRoles()} * @return this builder */ public ChannelDraftBuilder plusRoles(final Set<ChannelRole> roles) { this.roles = SphereInternalUtils.setOf(Optional.ofNullable(this.roles).orElseGet(HashSet::new), roles); return this; }
/** * 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)); }
/** * {@inheritDoc} */ @Override public List<FilterExpression<T>> containsAll(final Iterable<V> values) { return toStream(values) .map(value -> filterBy(value)) .collect(toList()); }