S - a subclass implementation of BaseSyncOptions that is used to allow/deny some specific options,
specified by the user, on reference resolution.public abstract class BaseReferenceResolver<T,S extends BaseSyncOptions>
extends java.lang.Object
| Modifier | Constructor and Description |
|---|---|
protected |
BaseReferenceResolver(S options) |
| Modifier and Type | Method and Description |
|---|---|
protected static java.lang.String |
getKeyFromExpansionOrReference(boolean allowUuidKeys,
java.lang.String keyFromExpansion,
io.sphere.sdk.models.Reference reference)
Given a key value (
keyFromExpansion) which is potentially fetched from the expansion of a reference. |
protected static java.lang.String |
getKeyFromResourceIdentifier(io.sphere.sdk.models.ResourceIdentifier resourceIdentifier,
boolean allowUuidKeys)
This method fetches the id value on the passed
ResourceIdentifier, if valid. |
protected static boolean |
isReferenceExpanded(io.sphere.sdk.models.Reference reference)
Helper method to check if passed
Reference instance is expanded. |
abstract java.util.concurrent.CompletionStage<T> |
resolveReferences(T draft)
Given a draft this method attempts to resolve the all the references on the draft to
return a
CompletionStage which contains a new instance of the draft with the resolved
references. |
protected S extends BaseSyncOptions options
protected BaseReferenceResolver(@Nonnull
S options)
public abstract java.util.concurrent.CompletionStage<T> resolveReferences(@Nonnull T draft)
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.draft - the productDraft to resolve it's references.CompletionStage that contains as a result a new draft instance with resolved references
or, in case an error occurs during reference resolution, a ReferenceResolutionException.@Nonnull
protected static java.lang.String getKeyFromResourceIdentifier(@Nonnull
io.sphere.sdk.models.ResourceIdentifier resourceIdentifier,
boolean allowUuidKeys)
throws ReferenceResolutionException
ResourceIdentifier, if valid. If it is not valid, a
ReferenceResolutionException will be thrown. The validity checks are:
allowUuidKeys flag set to true, or the id value
doesn't have a UUID format.ReferenceResolutionException is thrown.resourceIdentifier - the reference from which the id value is validated and returned.allowUuidKeys - flag that signals whether the key could be UUID format or not.ResourceIdentifierReferenceResolutionException - if any of the validation checks fail.@Nonnull
protected static java.lang.String getKeyFromExpansionOrReference(boolean allowUuidKeys,
@Nullable
java.lang.String keyFromExpansion,
@Nonnull
io.sphere.sdk.models.Reference reference)
throws ReferenceResolutionException
keyFromExpansion) which is potentially fetched from the expansion of a reference. This
method checks if this value is not blank (empty string/null), if it is, it tries to fetch the key value from the
id field on the reference. If it's not blank it returns it. Whether the value is fetched from the expansion or
from the reference's id field, this method makes sure the key is valid:
options instance of this class.ReferenceResolutionException will be thrown.allowUuidKeys - flag that signals whether the key could be UUID format or not.keyFromExpansion - the key value fetched after expansion of the reference.reference - the reference object to get the key from.ReferenceResolutionException - thrown if the key is not valid.protected static boolean isReferenceExpanded(@Nonnull
io.sphere.sdk.models.Reference reference)
Reference instance is expanded.reference - the reference to check.Reference is expanded.