test_class.file: spring/shedlock-spring/src/test/java/net/javacrumbs/shedlock/spring/aop/StringToDurationConverterTest.java
test_class.identifier: StringToDurationConverterTest
test_case.body: @Test
      public void convertWhenSimpleMillisShouldReturnDuration() {
          assertThat(convert("10ms")).isEqualTo(Duration.ofMillis(10));
          assertThat(convert("10MS")).isEqualTo(Duration.ofMillis(10));
          assertThat(convert("+10ms")).isEqualTo(Duration.ofMillis(10));
          assertThat(convert("-10ms")).isEqualTo(Duration.ofMillis(-10));
      }
test_case.class_method_signature: StringToDurationConverterTest.convertWhenSimpleMillisShouldReturnDuration()
test_case.full_signature: @Test public void convertWhenSimpleMillisShouldReturnDuration()
test_case.identifier: convertWhenSimpleMillisShouldReturnDuration
test_case.invocations: isEqualTo assertThat convert ofMillis isEqualTo assertThat convert ofMillis isEqualTo assertThat convert ofMillis isEqualTo assertThat convert ofMillis
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void convertWhenSimpleMillisShouldReturnDuration()
focal_class.declarator: INSTANCE = new StringToDurationConverter()
focal_class.modifier: static final
focal_class.original_string: static final StringToDurationConverter INSTANCE = new StringToDurationConverter();
focal_class.type: StringToDurationConverter
focal_class.var_name: INSTANCE
focal_class.declarator: ISO8601 = Pattern.compile("^[\\+\\-]?P.*$")
focal_class.modifier: private static final
focal_class.original_string: private static final Pattern ISO8601 = Pattern.compile("^[\\+\\-]?P.*$");
focal_class.type: Pattern
focal_class.var_name: ISO8601
focal_class.declarator: SIMPLE = Pattern.compile("^([\\+\\-]?\\d+)([a-zA-Z]{0,2})$")
focal_class.modifier: private static final
focal_class.original_string: private static final Pattern SIMPLE = Pattern.compile("^([\\+\\-]?\\d+)([a-zA-Z]{0,2})$");
focal_class.type: Pattern
focal_class.var_name: SIMPLE
focal_class.declarator: UNITS
focal_class.modifier: private static final
focal_class.original_string: private static final Map<String, ChronoUnit> UNITS;
focal_class.type: Map<String, ChronoUnit>
focal_class.var_name: UNITS
focal_class.file: spring/shedlock-spring/src/main/java/net/javacrumbs/shedlock/spring/aop/StringToDurationConverter.java
focal_class.identifier: StringToDurationConverter
focal_class.interfaces: implements Converter<String, Duration>
focal_class.class_method_signature: StringToDurationConverter.convert(String source)
focal_class.full_signature: @Override public Duration convert(String source)
focal_class.identifier: convert
focal_class.modifiers: @Override public
focal_class.parameters: (String source)
focal_class.return: Duration
focal_class.signature: Duration convert(String source)
focal_class.class_method_signature: StringToDurationConverter.getUnit(String value)
focal_class.full_signature: private ChronoUnit getUnit(String value)
focal_class.identifier: getUnit
focal_class.modifiers: private
focal_class.parameters: (String value)
focal_class.return: ChronoUnit
focal_class.signature: ChronoUnit getUnit(String value)
focal_method.body: @Override
      public Duration convert(String source) {
          try {
              if (ISO8601.matcher(source).matches()) {
                  return Duration.parse(source);
              }
              Matcher matcher = SIMPLE.matcher(source);
              Assert.state(matcher.matches(), "'" + source + "' is not a valid duration");
              long amount = Long.parseLong(matcher.group(1));
              ChronoUnit unit = getUnit(matcher.group(2));
              return Duration.of(amount, unit);
          } catch (Exception ex) {
              throw new IllegalStateException("'" + source + "' is not a valid duration", ex);
          }
      }
focal_method.class_method_signature: StringToDurationConverter.convert(String source)
focal_method.full_signature: @Override public Duration convert(String source)
focal_method.identifier: convert
focal_method.invocations: matches matcher parse matcher state matches parseLong group getUnit group of
focal_method.modifiers: @Override public
focal_method.parameters: (String source)
focal_method.return: Duration
focal_method.signature: Duration convert(String source)