generateRegexMapper method

String generateRegexMapper(
  1. Iterable<ConstantReader> annotatedMethods
)

Implementation

String generateRegexMapper(Iterable<ConstantReader> annotatedMethods) {
  final classBuffer = StringBuffer();

  for (final method in annotatedMethods) {
    final regexes =
        method.peek('regexes')?.listValue.map((e) => e.toStringValue());
    final customMapperType =
        method.peek('customParamsMapper')?.typeValue.getDisplayString();

    if (regexes != null) {
      for (final regex in regexes) {
        classBuffer.writeln(
          'r\'$regex\': $customMapperType(),',
        );
      }
    }
  }

  return classBuffer.toString();
}