static Map<String, String> parseResourceLabels(@Nullable String rawEnvLabels) {
    if (rawEnvLabels == null) {
      return Collections.<String, String>emptyMap();
    } else {
      Map<String, String> labels = new HashMap<String, String>();
      String[] rawLabels = rawEnvLabels.split(LABEL_LIST_SPLITTER, -1);
      for (String rawLabel : rawLabels) {
        String[] keyValuePair = rawLabel.split(LABEL_KEY_VALUE_SPLITTER, -1);
        if (keyValuePair.length != 2) {
          continue;
        }
        String key = keyValuePair[0].trim();
        String value = keyValuePair[1].trim().replaceAll("^\"|\"$", "");
        Utils.checkArgument(isValidAndNotEmpty(key), "Label key" + ERROR_MESSAGE_INVALID_CHARS);
        Utils.checkArgument(isValid(value), "Label value" + ERROR_MESSAGE_INVALID_VALUE);
        labels.put(key, value);
      }
      return Collections.unmodifiableMap(labels);
    }
  }
static Map < String , String > parseResourceLabels ( @ Nullable String rawEnvLabels ) { if ( rawEnvLabels == null ) { return Collections . < String , String > emptyMap ( ) ; } else { Map < String , String > labels = new HashMap < String , String > ( ) ; String [ ] rawLabels = rawEnvLabels . split ( LABEL_LIST_SPLITTER , - 1 ) ; for ( String rawLabel : rawLabels ) { String [ ] keyValuePair = rawLabel . split ( LABEL_KEY_VALUE_SPLITTER , - 1 ) ; if ( keyValuePair . length != 2 ) { continue ; } String key = keyValuePair [ 0 ] . trim ( ) ; String value = keyValuePair [ 1 ] . trim ( ) . replaceAll ( "^\"|\"$" , "" ) ; Utils . checkArgument ( isValidAndNotEmpty ( key ) , "Label key" + ERROR_MESSAGE_INVALID_CHARS ) ; Utils . checkArgument ( isValid ( value ) , "Label value" + ERROR_MESSAGE_INVALID_VALUE ) ; labels . put ( key , value ) ; } return Collections . unmodifiableMap ( labels ) ; } }
/*
Creates a label map from the OC_RESOURCE_LABELS environment variable.

<p>OC_RESOURCE_LABELS: A comma-separated list of labels describing the source in more detail,
e.g. “key1=val1,key2=val2”. Domain names and paths are accepted as label keys. Values may be
quoted or unquoted in general. If a value contains whitespaces, =, or " characters, it must
always be quoted.