public final class CategoryReferenceResolver extends CustomReferenceResolver<io.sphere.sdk.categories.CategoryDraft,io.sphere.sdk.categories.CategoryDraftBuilder,CategorySyncOptions>
options| Constructor and Description |
|---|
CategoryReferenceResolver(CategorySyncOptions options,
TypeService typeService,
CategoryService categoryService) |
| Modifier and Type | Method and Description |
|---|---|
static java.lang.String |
getKeyFromExpansion(io.sphere.sdk.models.Reference<io.sphere.sdk.categories.Category> categoryReference)
Helper method that returns the value of the key field from the passed category
Reference object,
if expanded. |
static java.util.Optional<java.lang.String> |
getParentCategoryKey(io.sphere.sdk.categories.CategoryDraft draft,
boolean shouldAllowUuidKeys) |
static java.util.Optional<java.lang.String> |
getParentCategoryKey(io.sphere.sdk.categories.CategoryDraftBuilder draftBuilder,
boolean shouldAllowUuidKeys) |
static java.util.Optional<java.lang.String> |
getParentCategoryKey(io.sphere.sdk.models.Reference<io.sphere.sdk.categories.Category> parentCategoryReference,
java.lang.String categoryKey,
boolean shouldAllowUuidKeys)
Given a category parent, this method first checks if this value is meaningful.
|
protected java.util.concurrent.CompletionStage<io.sphere.sdk.categories.CategoryDraftBuilder> |
resolveCustomTypeReference(io.sphere.sdk.categories.CategoryDraftBuilder draftBuilder)
Given a draft of
D (e.g. |
java.util.concurrent.CompletionStage<io.sphere.sdk.categories.CategoryDraft> |
resolveReferences(io.sphere.sdk.categories.CategoryDraft categoryDraft)
Given a
CategoryDraft this method attempts to resolve the custom type and parent category references to
return a CompletionStage which contains a new instance of the draft with the resolved
references. |
getCustomTypeIdgetKeyFromExpansionOrReference, getKeyFromResourceIdentifier, isReferenceExpandedpublic CategoryReferenceResolver(@Nonnull
CategorySyncOptions options,
@Nonnull
TypeService typeService,
@Nonnull
CategoryService categoryService)
public java.util.concurrent.CompletionStage<io.sphere.sdk.categories.CategoryDraft> resolveReferences(@Nonnull
io.sphere.sdk.categories.CategoryDraft categoryDraft)
CategoryDraft this method attempts to resolve the custom type and parent category references to
return a CompletionStage which contains a new instance of the draft with the resolved
references. The keys of the references are either taken from the expanded references or
taken from the id field of the references.resolveReferences in class BaseReferenceResolver<io.sphere.sdk.categories.CategoryDraft,CategorySyncOptions>categoryDraft - the categoryDraft to resolve it's references.CompletionStage that contains as a result a new categoryDraft instance with resolved category
references or, in case an error occurs during reference resolution,
a ReferenceResolutionException.@Nonnull
protected java.util.concurrent.CompletionStage<io.sphere.sdk.categories.CategoryDraftBuilder> resolveCustomTypeReference(@Nonnull
io.sphere.sdk.categories.CategoryDraftBuilder draftBuilder)
CustomReferenceResolverD (e.g. CategoryDraft) this method attempts to resolve it's custom type
reference to return CompletionStage which contains a new instance of the draft with the resolved
custom type reference. The key of the custom type is taken from the from the id field of the reference.
The method then tries to fetch the key of the custom type, optimistically from a cache. If the key is is not found, the resultant draft would remain exactly the same as the passed draft (without a custom type reference resolution).
resolveCustomTypeReference in class CustomReferenceResolver<io.sphere.sdk.categories.CategoryDraft,io.sphere.sdk.categories.CategoryDraftBuilder,CategorySyncOptions>draftBuilder - the draft builder to resolve it's references.CompletionStage that contains as a result a new draft instance with resolved custom
type references or, in case an error occurs during reference resolution,
a ReferenceResolutionException.public static java.util.Optional<java.lang.String> getParentCategoryKey(@Nullable
io.sphere.sdk.models.Reference<io.sphere.sdk.categories.Category> parentCategoryReference,
@Nullable
java.lang.String categoryKey,
boolean shouldAllowUuidKeys)
throws ReferenceResolutionException
shouldAllowUuidKeys is false, then a ReferenceResolutionException is thrown. If there is a parent
reference but an blank (null/empty) key value, then a ReferenceResolutionException is also thrown. If
there is no parent reference set, then an empty optional is returned.parentCategoryReference - the category parent reference. If empty - empty result is returnedcategoryKey - the category key to be logged if the reference resolution failsshouldAllowUuidKeys - a flag that specifies whether the key could be in UUID format or not.ReferenceResolutionException - thrown if the key is invalid (empty/null/in UUID when the flag is false).public static java.util.Optional<java.lang.String> getParentCategoryKey(@Nonnull
io.sphere.sdk.categories.CategoryDraft draft,
boolean shouldAllowUuidKeys)
throws ReferenceResolutionException
ReferenceResolutionExceptionpublic static java.util.Optional<java.lang.String> getParentCategoryKey(@Nonnull
io.sphere.sdk.categories.CategoryDraftBuilder draftBuilder,
boolean shouldAllowUuidKeys)
throws ReferenceResolutionException
ReferenceResolutionException@Nullable
public static java.lang.String getKeyFromExpansion(@Nonnull
io.sphere.sdk.models.Reference<io.sphere.sdk.categories.Category> categoryReference)
Reference object,
if expanded. Otherwise, returns null.categoryReference - the category reference to get the key from it's expansion.Reference object, if expanded.
Otherwise, returns null.