when<_T> method

_T when<_T>({
  1. required _T ref(
    1. String ref
    ),
  2. required _T single(
    1. T value
    ),
  3. required _T list(
    1. List<CompVal<T>> values
    ),
})

Implementation

_T when<_T>({
  required _T Function(String ref) ref,
  required _T Function(T value) single,
  required _T Function(List<CompVal<T>> values) list,
}) {
  final v = this;
  if (v is CompValueRef<T>) {
    return ref(v.ref);
  } else if (v is CompValueSingle<T>) {
    return single(v.value);
  } else if (v is CompValueList<T>) {
    return list(v.values);
  }
  throw Exception();
}