Class AttributeUtils
- java.lang.Object
-
- com.commercetools.sync.products.utils.AttributeUtils
-
public final class AttributeUtils extends java.lang.Object
-
-
Constructor Summary
Constructors Constructor Description AttributeUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static com.fasterxml.jackson.databind.JsonNodecleanupAttributeValue(com.fasterxml.jackson.databind.JsonNode attributeValueAsJson, com.commercetools.api.models.product.Attribute attribute)Given aJsonNoderepresenting an attribute value of a givenAttributethis method removes all nodes containing invalid data, which is a null orSELF_REFERENCING_ID_PLACE_HOLDER.static java.util.List<com.fasterxml.jackson.databind.JsonNode>getAttributeReferences(com.fasterxml.jackson.databind.JsonNode attributeValueAsJson)Given aJsonNodethis method extracts the nodes containing a "typeId" field which is representing a reference type.static com.fasterxml.jackson.databind.JsonNodereplaceAttributeValueWithJsonAndReturnValue(com.commercetools.api.models.product.Attribute attribute)Given an attribute this method converts it's value intoJsonNodeand set's the converted value in the attribute.
-
-
-
Method Detail
-
replaceAttributeValueWithJsonAndReturnValue
@Nonnull public static com.fasterxml.jackson.databind.JsonNode replaceAttributeValueWithJsonAndReturnValue(@Nonnull com.commercetools.api.models.product.Attribute attribute)Given an attribute this method converts it's value intoJsonNodeand set's the converted value in the attribute.- Parameters:
attribute- - Attribute to replace it's value with a JSON representation- Returns:
- - a
JsonNoderepresenting the attribute's value.
-
getAttributeReferences
public static java.util.List<com.fasterxml.jackson.databind.JsonNode> getAttributeReferences(@Nonnull com.fasterxml.jackson.databind.JsonNode attributeValueAsJson)Given aJsonNodethis method extracts the nodes containing a "typeId" field which is representing a reference type.- Parameters:
attributeValueAsJson- - JsonNode to find the "reference" nodes- Returns:
- a
ListofJsonNodeextracted from the given JSON or empty list if the value doesn't contain reference types.
-
cleanupAttributeValue
@Nonnull public static com.fasterxml.jackson.databind.JsonNode cleanupAttributeValue(@Nonnull com.fasterxml.jackson.databind.JsonNode attributeValueAsJson, @Nonnull com.commercetools.api.models.product.Attribute attribute)Given aJsonNoderepresenting an attribute value of a givenAttributethis method removes all nodes containing invalid data, which is a null orSELF_REFERENCING_ID_PLACE_HOLDER. The method set's the cleaned up value in the attribute and returns cleaned up value.Note: This might return an empty JsonNode.
- Parameters:
attributeValueAsJson- - a JsonNode representing an attribute valueattribute- - Attribute to replace it's value with cleaned-up value- Returns:
- - a
JsonNodeattribute's value which contains valid data for further processing, it might be an empty node in case all data was removed.
-
-