private void initEnv() { if (this.environment != null) { return; } ContainerLaunchContextProtoOrBuilder p = viaProto ? proto : builder; List<StringStringMapProto> list = p.getEnvironmentList(); this.environment = new HashMap<String, String>(); for (StringStringMapProto c : list) { this.environment.put(c.getKey(), c.getValue()); } }
private void addEnvToProto() { maybeInitBuilder(); builder.clearEnvironment(); if (environment == null) return; Iterable<StringStringMapProto> iterable = new Iterable<StringStringMapProto>() { @Override public Iterator<StringStringMapProto> iterator() { return new Iterator<StringStringMapProto>() { Iterator<String> keyIter = environment.keySet().iterator(); @Override public void remove() { throw new UnsupportedOperationException(); } @Override public StringStringMapProto next() { String key = keyIter.next(); return StringStringMapProto.newBuilder().setKey(key).setValue( (environment.get(key))).build(); } @Override public boolean hasNext() { return keyIter.hasNext(); } }; } }; builder.addAllEnvironment(iterable); }