Class CustomTypeReferenceResolutionUtils


  • public final class CustomTypeReferenceResolutionUtils
    extends java.lang.Object
    Util class which provides utilities that can be used when syncing resources from a source commercetools project to a target one.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static com.commercetools.api.models.type.CustomFieldsDraft mapToCustomFieldsDraft​(com.commercetools.api.models.type.CustomFields custom, ReferenceIdToKeyCache referenceIdToKeyCache)
      Given a custom CustomFields, this method provides checking to certain resources which do not extends Custom.
      static <T extends com.commercetools.api.models.Customizable<T>>
      com.commercetools.api.models.type.CustomFieldsDraft
      mapToCustomFieldsDraft​(T resource, ReferenceIdToKeyCache referenceIdToKeyCache)
      Given a resource of type T that extends Custom (i.e.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • mapToCustomFieldsDraft

        @Nullable
        public static <T extends com.commercetools.api.models.Customizable<T>> com.commercetools.api.models.type.CustomFieldsDraft mapToCustomFieldsDraft​(@Nonnull
                                                                                                                                                          T resource,
                                                                                                                                                          @Nonnull
                                                                                                                                                          ReferenceIdToKeyCache referenceIdToKeyCache)
        Given a resource of type T that extends Custom (i.e. it has CustomFields, this method checks if the custom fields are existing (not null) and they are reference cached(reference idToKey value stored in the map). If they are then it returns a CustomFieldsDraft instance with the custom type key in place of the key of the reference. Otherwise, if it's not reference cached it returns a CustomFieldsDraft without the key. If the resource has null Custom, then it returns null.
        Type Parameters:
        T - the type of the resource.
        Parameters:
        resource - the resource to replace its custom type key, if possible.
        referenceIdToKeyCache - the instance that manages cache.
        Returns:
        an instance of CustomFieldsDraft instance with the custom type key, if the custom type reference was existing and reference cached on the resource. Otherwise, if its not reference cached it returns a CustomFieldsDraft without a key. If the resource has no or null Custom, then it returns null.
      • mapToCustomFieldsDraft

        @Nullable
        public static com.commercetools.api.models.type.CustomFieldsDraft mapToCustomFieldsDraft​(@Nullable
                                                                                                 com.commercetools.api.models.type.CustomFields custom,
                                                                                                 @Nonnull
                                                                                                 ReferenceIdToKeyCache referenceIdToKeyCache)
        Given a custom CustomFields, this method provides checking to certain resources which do not extends Custom. If the custom fields are existing (not null) and they are reference cached(reference idToKey value stored in the map). If they are then it returns a CustomFieldsDraft instance with the custom type key in place of the key of the reference. Otherwise, if it's not reference cached it returns a CustomFieldsDraft without the key. If the resource has null Custom, then it returns null.
        Parameters:
        custom - the resource to replace its custom type key, if possible.
        referenceIdToKeyCache - the instance that manages cache.
        Returns:
        an instance of CustomFieldsDraft instance with the custom type key, if the custom type reference was existing and reference cached on the resource. Otherwise, if its not reference cached it returns a CustomFieldsDraft without a key. If the resource has no or null Custom, then it returns null.