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

io.sphere.sdk.search.SearchKeywords Maven / Gradle / Ivy

There is a newer version: 1.0.0-M26
Show newest version
package io.sphere.sdk.search;

import com.fasterxml.jackson.annotation.JsonAnyGetter;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonIgnore;
import io.sphere.sdk.models.Base;

import java.util.*;

import static io.sphere.sdk.utils.MapUtils.*;

public class SearchKeywords extends Base {
    @JsonIgnore
    private final Map> content;

    @JsonCreator
    private SearchKeywords() {
        this(new HashMap<>());
    }

    @JsonIgnore
    private SearchKeywords(final Map> content) {
        this.content = content;
    }

    @JsonAnyGetter//@JsonUnwrap supports not maps, but this construct puts map content on top level
    public Map> getContent() {
        return immutableCopyOf(content);
    }

    @JsonAnySetter
    private void setContent(final String languageTag, final List value) {
        content.put(Locale.forLanguageTag(languageTag), value);
    }

    @JsonIgnore
    public static SearchKeywords of(final Locale locale, final List keywords) {
        return of(mapOf(locale, keywords));
    }

    @JsonIgnore
    public static SearchKeywords of(final Locale locale1, final List keywords1, final Locale locale2, final List keywords2) {
        final Map> map = new HashMap<>();
        map.put(locale1, keywords1);
        map.put(locale2, keywords2);
        return of(map);
    }

    @JsonIgnore
    public static SearchKeywords of(final Map> content) {
        return new SearchKeywords(content);
    }

    @JsonIgnore
    public static SearchKeywords of() {
        return of(Collections.emptyMap());
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy