public static boolean isValidCloudLabel(String value) {
    Matcher m = VALID_CLOUD_LABEL_PATTERN.matcher(value);
    return m.find();
  }
@Test
  @SuppressWarnings("LoopOverCharArray")
  public void testIsValidCloudLabel() {
    // A dataflow job ID.
    // Lowercase letters, numbers, underscores and hyphens are allowed.
    String testStr = "2020-06-29_15_26_09-12838749047888422749";
    assertTrue(BigQueryIOMetadata.isValidCloudLabel(testStr));

    // At least one character.
    testStr = "0";
    assertTrue(BigQueryIOMetadata.isValidCloudLabel(testStr));

    // Up to 63 characters.
    testStr = "0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij012";
    assertTrue(BigQueryIOMetadata.isValidCloudLabel(testStr));

    // Lowercase letters allowed
    testStr = "abcdefghijklmnopqrstuvwxyz";
    for (char testChar : testStr.toCharArray()) {
      assertTrue(BigQueryIOMetadata.isValidCloudLabel(String.valueOf(testChar)));
    }

    // Empty strings not allowed.
    testStr = "";
    assertFalse(BigQueryIOMetadata.isValidCloudLabel(testStr));

    // 64 or more characters not allowed.
    testStr = "0123456789abcdefghij0123456789abcdefghij0123456789abcdefghij0123";
    assertFalse(BigQueryIOMetadata.isValidCloudLabel(testStr));

    // Uppercase letters not allowed
    testStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
    for (char testChar : testStr.toCharArray()) {
      assertFalse(BigQueryIOMetadata.isValidCloudLabel(String.valueOf(testChar)));
    }

    // Special characters besides hyphens are not allowed
    testStr = "!@#$%^&*()+=[{]};:\'\"\\|,<.>?/`~";
    for (char testChar : testStr.toCharArray()) {
      assertFalse(BigQueryIOMetadata.isValidCloudLabel(String.valueOf(testChar)));
    }
  }