CreditReturnEvent constructor

CreditReturnEvent({
  1. required int countWidth,
  2. int poolCount = 1,
  3. String name = 'credit_return_event',
})

Creates a counted credit-return payload.

Implementation

CreditReturnEvent(
    {required this.countWidth,
    this.poolCount = 1,
    String name = 'credit_return_event'})
    : super([
        Logic(name: 'count', width: countWidth),
        Logic(
            name: 'pool',
            width: (poolCount - 1).bitLength < 1
                ? 1
                : (poolCount - 1).bitLength),
      ], name: name) {
  if (countWidth < 1) {
    throw ArgumentError.value(
        countWidth, 'countWidth', 'Must be at least one.');
  }
  if (poolCount < 1) {
    throw ArgumentError.value(poolCount, 'poolCount', 'Must be positive.');
  }
}