io.sphere.sdk.categories.Category Maven / Gradle / Ivy
package io.sphere.sdk.categories;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import io.sphere.sdk.models.*;
import io.sphere.sdk.types.Custom;
import io.sphere.sdk.types.CustomFields;
import org.apache.commons.lang3.builder.ToStringBuilder;
import javax.annotation.Nullable;
import java.util.List;
import static io.sphere.sdk.utils.ListUtils.join;
/**
* Categories are used to organize products in a hierarchical structure.
*
* A category can have {@link io.sphere.sdk.types.Custom custom fields}.
*
* Operations:
*
* - Create a category with {@link io.sphere.sdk.categories.commands.CategoryCreateCommand}.
* - Update a category with {@link io.sphere.sdk.categories.commands.CategoryUpdateCommand}.
* - Delete a category with {@link io.sphere.sdk.categories.commands.CategoryDeleteCommand}.
*
*
* Consult the documentation for categories for more information.
*/
@JsonDeserialize(as=CategoryImpl.class)
public interface Category extends Resource, WithLocalizedSlug, MetaAttributes, Custom {
LocalizedString getName();
LocalizedString getSlug();
@Nullable
LocalizedString getDescription();
List> getAncestors();
@Nullable
Reference getParent();
@Nullable
String getOrderHint();
@Nullable
String getExternalId();
@Nullable
@Override
LocalizedString getMetaTitle();
@Nullable
@Override
LocalizedString getMetaDescription();
@Nullable
@Override
LocalizedString getMetaKeywords();
@Nullable
CustomFields getCustom();
@Override
default Reference toReference() {
return Reference.of(referenceTypeId(), getId(), this);
}
static String resourceTypeId() {
return "category";
}
static String referenceTypeId() {
return "category";
}
/**
*
* @deprecated use {@link #referenceTypeId()} instead
* @return referenceTypeId
*/
@Deprecated
static String typeId(){
return "category";
}
static Reference reference(final String id) {
return Reference.of(referenceTypeId(), id);
}
static TypeReference typeReference() {
return new TypeReference() {
@Override
public String toString() {
return "TypeReference";
}
};
}
static String toString(final Category category) {
return new ToStringBuilder(category, SdkDefaults.TO_STRING_STYLE)
.append("id", category.getId())
.append("version", category.getVersion())
.append("createdAt", category.getCreatedAt())
.append("lastModifiedAt", category.getLastModifiedAt())
.append("name", category.getName())
.append("slug", category.getSlug())
.append("description", category.getDescription())
.append("ancestors", join(category.getAncestors()))
.append("parent", category.getParent())
.append("orderHint", category.getOrderHint())
.toString();
}
}