public final class TaxCategoryServiceImpl extends java.lang.Object implements TaxCategoryService
| Modifier and Type | Field and Description |
|---|---|
protected com.github.benmanes.caffeine.cache.Cache<java.lang.String,java.lang.String> |
keyToIdCache |
protected static int |
MAXIMUM_ALLOWED_UPDATE_ACTIONS |
| Constructor and Description |
|---|
TaxCategoryServiceImpl(TaxCategorySyncOptions syncOptions) |
| Modifier and Type | Method and Description |
|---|---|
java.util.concurrent.CompletionStage<java.util.Map<java.lang.String,java.lang.String>> |
cacheKeysToIds(java.util.Set<java.lang.String> taxCategoryKeys)
Filters out the keys which are already cached and fetches only the not-cached tax category keys
from the CTP project defined in an injected
SphereClient and stores a mapping for every
tax category to id in the cached map of keys -> ids and returns this cached map. |
java.util.concurrent.CompletionStage<java.util.Optional<io.sphere.sdk.taxcategories.TaxCategory>> |
createTaxCategory(io.sphere.sdk.taxcategories.TaxCategoryDraft taxCategoryDraft)
Given a resource draft of
TaxCategoryDraft, this method attempts to create a resource
TaxCategory based on it in the CTP project defined by the sync options. |
java.util.concurrent.CompletionStage<java.util.Optional<java.lang.String>> |
fetchCachedTaxCategoryId(java.lang.String key)
Given a
key, this method first checks if a cached map of TaxCategory keys -> ids is
not empty. |
java.util.concurrent.CompletionStage<java.util.Set<io.sphere.sdk.taxcategories.TaxCategory>> |
fetchMatchingTaxCategoriesByKeys(java.util.Set<java.lang.String> keys)
Given a
Set of tax category keys, this method fetches a set of all the taxCategories,
matching given set of keys in the CTP project, defined in an injected SphereClient. |
java.util.concurrent.CompletionStage<java.util.Optional<io.sphere.sdk.taxcategories.TaxCategory>> |
fetchTaxCategory(java.lang.String key)
Given a tax category key, this method fetches a tax category that matches given key in the CTP
project defined in a potentially injected
SphereClient. |
java.util.concurrent.CompletionStage<io.sphere.sdk.taxcategories.TaxCategory> |
updateTaxCategory(io.sphere.sdk.taxcategories.TaxCategory taxCategory,
java.util.List<io.sphere.sdk.commands.UpdateAction<io.sphere.sdk.taxcategories.TaxCategory>> updateActions)
Given a
TaxCategory and a List<UpdateAction<TaxCategory>>, this method issues an update request with these update actions on this
TaxCategory in the CTP project defined in a potentially injected SphereClient. |
protected final com.github.benmanes.caffeine.cache.Cache<java.lang.String,java.lang.String> keyToIdCache
protected static final int MAXIMUM_ALLOWED_UPDATE_ACTIONS
public TaxCategoryServiceImpl(@Nonnull
TaxCategorySyncOptions syncOptions)
@Nonnull
public java.util.concurrent.CompletionStage<java.util.Map<java.lang.String,java.lang.String>> cacheKeysToIds(@Nonnull
java.util.Set<java.lang.String> taxCategoryKeys)
TaxCategoryServiceSphereClient and stores a mapping for every
tax category to id in the cached map of keys -> ids and returns this cached map.cacheKeysToIds in interface TaxCategoryServicetaxCategoryKeys - - a set of tax category keys to fetch and cache the ids forCompletionStage<Map> in which the result of it's completion
contains a map of requested tax category keys -> ids@Nonnull
public java.util.concurrent.CompletionStage<java.util.Optional<java.lang.String>> fetchCachedTaxCategoryId(@Nullable
java.lang.String key)
TaxCategoryServicekey, this method first checks if a cached map of TaxCategory keys -> ids is
not empty. If not, it returns a completed future that contains an optional that contains what
this key maps to in the cache. If the cache is empty, the method populates the cache with the
mapping of all TaxCategory keys to ids in the CTP project, by querying the CTP project for all
Tax categories.
After that, the method returns a CompletionStage<Optional<String>> in which the result of it's completion could contain an Optional with
the id inside of it or an empty Optional if no TaxCategory was found in the CTP
project with this key.
fetchCachedTaxCategoryId in interface TaxCategoryServicekey - the key by which a TaxCategory id should be fetched from the CTP project.CompletionStage<Optional<String>> in which the
result of its completion could contain an Optional with the id inside of it or an
empty Optional if no TaxCategory was found in the CTP project with this
key.@Nonnull
public java.util.concurrent.CompletionStage<java.util.Set<io.sphere.sdk.taxcategories.TaxCategory>> fetchMatchingTaxCategoriesByKeys(@Nonnull
java.util.Set<java.lang.String> keys)
TaxCategoryServiceSet of tax category keys, this method fetches a set of all the taxCategories,
matching given set of keys in the CTP project, defined in an injected SphereClient. A
mapping of the key to the id of the fetched taxCategories is persisted in an in-memory map.
fetchMatchingTaxCategoriesByKeys in interface TaxCategoryServicekeys - set of tax category keys to fetch matching taxCategories by.CompletionStage<Map> in which the result of it's completion
contains a Set of all matching taxCategories.@Nonnull
public java.util.concurrent.CompletionStage<java.util.Optional<io.sphere.sdk.taxcategories.TaxCategory>> fetchTaxCategory(@Nullable
java.lang.String key)
TaxCategoryServiceSphereClient. If there is no matching tax
category an empty Optional will be returned in the returned future. A mapping of the
key to the id of the fetched category is persisted in an in-memory map.fetchTaxCategory in interface TaxCategoryServicekey - the key of the tax category to fetch.CompletionStage<Optional> in which the result of it's completion
contains an Optional that contains the matching TaxCategory if exists,
otherwise empty.@Nonnull
public java.util.concurrent.CompletionStage<java.util.Optional<io.sphere.sdk.taxcategories.TaxCategory>> createTaxCategory(@Nonnull
io.sphere.sdk.taxcategories.TaxCategoryDraft taxCategoryDraft)
TaxCategoryServiceTaxCategoryDraft, this method attempts to create a resource
TaxCategory based on it in the CTP project defined by the sync options.
A completion stage containing an empty option and the error callback will be triggered in those cases:
On the other hand, if the resource gets created successfully on CTP, then the created
resource's id and key are cached and the method returns a CompletionStage in which the
result of it's completion contains an instance Optional of the resource which was
created.
createTaxCategory in interface TaxCategoryServicetaxCategoryDraft - the resource draft to create a resource based off of.CompletionStage containing an optional with the created resource if
successful otherwise an empty optional.@Nonnull
public java.util.concurrent.CompletionStage<io.sphere.sdk.taxcategories.TaxCategory> updateTaxCategory(@Nonnull
io.sphere.sdk.taxcategories.TaxCategory taxCategory,
@Nonnull
java.util.List<io.sphere.sdk.commands.UpdateAction<io.sphere.sdk.taxcategories.TaxCategory>> updateActions)
TaxCategoryServiceTaxCategory and a List<UpdateAction<TaxCategory>>, this method issues an update request with these update actions on this
TaxCategory in the CTP project defined in a potentially injected SphereClient. This method returns CompletionStage<TaxCategory> in which the result of it's completion contains an instance of the TaxCategory which was updated in the CTP project.updateTaxCategory in interface TaxCategoryServicetaxCategory - the TaxCategory to update.updateActions - the update actions to update the TaxCategory with.CompletionStage<TaxCategory> containing as a result of it's
completion an instance of the TaxCategory which was updated in the CTP project or a
SphereException.