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

io.sphere.sdk.products.commands.updateactions.AddToCategory Maven / Gradle / Ivy

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

import io.sphere.sdk.categories.Category;
import io.sphere.sdk.commands.UpdateActionImpl;
import io.sphere.sdk.models.Reference;
import io.sphere.sdk.models.Referenceable;
import io.sphere.sdk.products.Product;

import javax.annotation.Nullable;

/**
 * Adds a product to a category.
 *
 * {@doc.gen intro}
 *
 * {@include.example io.sphere.sdk.products.commands.ProductUpdateCommandTest#addToCategory()}
 *
 * @see io.sphere.sdk.products.commands.updateactions.RemoveFromCategory
 */
public class AddToCategory extends UpdateActionImpl {
    private final Reference category;
    @Nullable
    private final String orderHint;

    private AddToCategory(final Reference category, @Nullable final String orderHint) {
        super("addToCategory");
        this.category = category;
        this.orderHint = orderHint;
    }

    public Reference getCategory() {
        return category;
    }

    public static AddToCategory of(final Referenceable category) {
        return new AddToCategory(category.toReference(), null);
    }

    public static AddToCategory of(final Referenceable category, final String orderHint) {
        return new AddToCategory(category.toReference(), orderHint);
    }

    @Nullable
    public String getOrderHint() {
        return orderHint;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy