Class AssetActionFactory<T extends io.sphere.sdk.models.Resource,​D>

  • Type Parameters:
    T - the type of the resource the asset update actions are built for.
    D - the type of the draft, which contains the changes the asset update actions are built for.
    Direct Known Subclasses:
    CategoryAssetActionFactory, ProductAssetActionFactory

    public abstract class AssetActionFactory<T extends io.sphere.sdk.models.Resource,​D>
    extends java.lang.Object
    Helper class for building update actions for assets that are contained in the resource of type T.
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      abstract io.sphere.sdk.commands.UpdateAction<T> buildAddAssetAction​(io.sphere.sdk.models.AssetDraft newAssetDraft, java.lang.Integer position)
      Takes an asset draft and an asset position to build an AddAsset action of the type T.
      abstract java.util.List<io.sphere.sdk.commands.UpdateAction<T>> buildAssetActions​(T oldResource, D newResource, io.sphere.sdk.models.Asset oldAsset, io.sphere.sdk.models.AssetDraft newAssetDraft)
      Takes a matching old asset and a new asset and computes the update actions needed to sync them.
      abstract io.sphere.sdk.commands.UpdateAction<T> buildChangeAssetOrderAction​(java.util.List<java.lang.String> newAssetOrder)
      Takes a list of asset ids to build a ChangeAssetOrder action of the type T.
      abstract io.sphere.sdk.commands.UpdateAction<T> buildRemoveAssetAction​(java.lang.String assetKey)
      Takes an asset key to build a RemoveAsset action of the type T.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • AssetActionFactory

        public AssetActionFactory()
    • Method Detail

      • buildAssetActions

        public abstract java.util.List<io.sphere.sdk.commands.UpdateAction<T>> buildAssetActions​(@Nonnull
                                                                                                 T oldResource,
                                                                                                 @Nonnull
                                                                                                 D newResource,
                                                                                                 @Nonnull
                                                                                                 io.sphere.sdk.models.Asset oldAsset,
                                                                                                 @Nonnull
                                                                                                 io.sphere.sdk.models.AssetDraft newAssetDraft)
        Takes a matching old asset and a new asset and computes the update actions needed to sync them.
        Parameters:
        oldResource - mainresource, whose asset should be updated.
        newResource - new mainresource draft, which contains the asset to update.
        oldAsset - the old asset to compare.
        newAssetDraft - the matching new asset draft.
        Returns:
        update actions needed to sync the two assets.
      • buildRemoveAssetAction

        public abstract io.sphere.sdk.commands.UpdateAction<T> buildRemoveAssetAction​(@Nonnull
                                                                                      java.lang.String assetKey)
        Takes an asset key to build a RemoveAsset action of the type T.
        Parameters:
        assetKey - the key of the asset used un building the update action.
        Returns:
        the built remove asset update action.
      • buildChangeAssetOrderAction

        public abstract io.sphere.sdk.commands.UpdateAction<T> buildChangeAssetOrderAction​(@Nonnull
                                                                                           java.util.List<java.lang.String> newAssetOrder)
        Takes a list of asset ids to build a ChangeAssetOrder action of the type T.
        Parameters:
        newAssetOrder - the new asset order needed to build the action.
        Returns:
        the built update action.
      • buildAddAssetAction

        public abstract io.sphere.sdk.commands.UpdateAction<T> buildAddAssetAction​(@Nonnull
                                                                                   io.sphere.sdk.models.AssetDraft newAssetDraft,
                                                                                   @Nonnull
                                                                                   java.lang.Integer position)
        Takes an asset draft and an asset position to build an AddAsset action of the type T.
        Parameters:
        newAssetDraft - the new asset draft to create an Add asset action for.
        position - the position to add the new asset to.
        Returns:
        the built update action.