getItemId method

  1. @protected
  2. @visibleForTesting
String getItemId(
  1. IDMapper<T> idMapper
)

Returns the id of the item.

If the current instance of ModificationEvent is created using the byId constructor, then it returns itemId, otherwise, it generates the id using idMapper and item(as it should not be null).

In case of it is null, throws an ArgumentError.

Implementation

@protected
@visibleForTesting
String getItemId(IDMapper<T> idMapper) {
  return itemId ??
      idMapper(
        ArgumentError.checkNotNull(
          item,
          'Either "item" or "itemId" should be specified',
        ),
      );
}