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

io.sphere.client.model.products.BackendCategory Maven / Gradle / Ivy

There is a newer version: 0.72.1
Show newest version
package io.sphere.client.model.products;

import com.google.common.collect.ImmutableMap;
import io.sphere.client.model.LocalizedString;
import io.sphere.client.model.Reference;
import io.sphere.client.model.EmptyReference;
import io.sphere.client.model.VersionedId;
import io.sphere.client.shop.model.Attribute;
import org.codehaus.jackson.annotate.JsonProperty;

import javax.annotation.Nonnull;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;

/** Internal representation of a category in the form the backend returns it.
 *  See {@link io.sphere.client.shop.model.Category} for a more user friendly version. */
public class BackendCategory {
    @Nonnull private String id = "";
    @JsonProperty("version") private int version;
    private LocalizedString name        = Attribute.defaultLocalizedString;
    private LocalizedString slug        = Attribute.defaultLocalizedString;
    private LocalizedString description = Attribute.defaultLocalizedString;
    private String orderHint = "";
    @Nonnull private List> ancestors = new ArrayList>();
    @Nonnull private Reference parent = EmptyReference.create("parent");
    @Nonnull private List children = new ArrayList();

    // for JSON deserializer
    private BackendCategory() { }

    /** The unique id. */
    @Nonnull public String getId() { return id; }

    /** The {@link #getId() id} plus version. */
    @Nonnull public VersionedId getIdAndVersion() { return VersionedId.create(id, version); }

    /** Gets the name of this category. */
    public LocalizedString getName() { return name; }

    /** Gets the slug of this category. */
    public LocalizedString getSlug() { return slug; }

    /** Gets the description of this category. */
    public LocalizedString getDescription() { return description; }

    /** Gets a hint for custom category sorters. */
    public String getOrderHint() { return orderHint; }

    /** Gets a reference to the parent category. */
    @Nonnull public Reference getParent() { return parent; }

    /** Gets references to all ancestors (parents of parents) of this category.
     *  The list is sorted from the farthest parent to the closest (the last element being the direct parent). */
    @Nonnull public List> getAncestors() { return ancestors; }

    /** Gets child categories of this category. */
    @Nonnull public List getChildren() { return children; }

    @Override
    public String toString() {
        return "BackendCategory{" +
                "id='" + id + '\'' +
                ", version=" + version +
                ", name=" + name +
                ", slug=" + slug +
                ", description=" + description +
                ", orderHint='" + orderHint + '\'' +
                ", ancestors=" + ancestors +
                ", parent=" + parent +
                ", children=" + children +
                '}';
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy