Class ResourceIdentifierUtils
- java.lang.Object
-
- com.commercetools.sync.commons.utils.ResourceIdentifierUtils
-
public final class ResourceIdentifierUtils extends java.lang.Object
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
REFERENCE_ID_FIELD
static java.lang.String
REFERENCE_TYPE_ID_FIELD
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static boolean
isReferenceOfType(com.fasterxml.jackson.databind.JsonNode referenceValue, java.lang.String referenceTypeId)
Given aJsonNode
referenceValue
which is the JSON representation of CTP Reference object, this method checks if it is has atypeId
with the value equal toreferenceTypeId
.static <T extends io.sphere.sdk.models.Referenceable<S>,S>
io.sphere.sdk.models.ResourceIdentifier<S>toResourceIdentifierIfNotNull(T resource)
Given aReferenceable
resource
of the typeT
, if it is not null, this method applies theReferenceable.toResourceIdentifier()
method to return it as aResourceIdentifier
of the typeT
.
-
-
-
Field Detail
-
REFERENCE_TYPE_ID_FIELD
public static final java.lang.String REFERENCE_TYPE_ID_FIELD
- See Also:
- Constant Field Values
-
REFERENCE_ID_FIELD
public static final java.lang.String REFERENCE_ID_FIELD
- See Also:
- Constant Field Values
-
-
Method Detail
-
toResourceIdentifierIfNotNull
@Nullable public static <T extends io.sphere.sdk.models.Referenceable<S>,S> io.sphere.sdk.models.ResourceIdentifier<S> toResourceIdentifierIfNotNull(@Nullable T resource)
Given aReferenceable
resource
of the typeT
, if it is not null, this method applies theReferenceable.toResourceIdentifier()
method to return it as aResourceIdentifier
of the typeT
. If it isnull
, this method returnsnull
.- Type Parameters:
T
- type of the resource supplied.S
- represents the type of theResourceIdentifier
returned.- Parameters:
resource
- represents the resource to return as aResourceIdentifier
if notnull
.- Returns:
- the supplied resource in the as a
ResourceIdentifier
if notnull
. If it isnull
, this method returnsnull
.
-
isReferenceOfType
public static boolean isReferenceOfType(@Nonnull com.fasterxml.jackson.databind.JsonNode referenceValue, java.lang.String referenceTypeId)
Given aJsonNode
referenceValue
which is the JSON representation of CTP Reference object, this method checks if it is has atypeId
with the value equal toreferenceTypeId
.- Parameters:
referenceValue
- JSON representation of CTP reference objectreferenceTypeId
- the typeId to check of the reference is of the same type or not.- Returns:
- true if the typeId field of the reference has the same value as
referenceTypeId
, otherwise, false.
-
-