/*
 * Copyright DataStax, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.datastax.oss.driver.internal.core;

import com.datastax.oss.driver.api.core.CqlIdentifier;
import com.datastax.oss.driver.shaded.guava.common.collect.ImmutableList;
import com.datastax.oss.driver.shaded.guava.common.collect.ImmutableMap;
import java.util.List;
import java.util.Map;

public class CqlIdentifiers {

  public static List<CqlIdentifier> wrap(Iterable<String> in) {
    ImmutableList.Builder<CqlIdentifier> out = ImmutableList.builder();
    for (String name : in) {
      out.add(CqlIdentifier.fromCql(name));
    }
    return out.build();
  }

  public static <V> Map<CqlIdentifier, V> wrapKeys(Map<String, V> in) {
    ImmutableMap.Builder<CqlIdentifier, V> out = ImmutableMap.builder();
    for (Map.Entry<String, V> entry : in.entrySet()) {
      out.put(CqlIdentifier.fromCql(entry.getKey()), entry.getValue());
    }
    return out.build();
  }
}

@@ -843,44 +843,154 @@
 ort 
-java.util.List;%0Aimport java.util.Map
+edu.umd.cs.findbugs.annotations.NonNull;%0Aimport java.util.List;%0Aimport java.util.Map;%0Aimport java.util.Objects;%0Aimport java.util.function.Function
 ;%0A%0Ap
@@ -1017,30 +1017,42 @@
 ifiers %7B%0A%0A  
-public
+@NonNull%0A  private
  static List
@@ -1072,16 +1072,32 @@
 r%3E wrap(
+%0A      @NonNull 
 Iterable
@@ -1103,27 +1103,226 @@
 e%3CString%3E in
-) %7B
+, @NonNull Function%3CString, CqlIdentifier%3E fn) %7B%0A%0A    Objects.requireNonNull(in, %22Input Iterable must not be null%22);%0A    Objects.requireNonNull(fn, %22CqlIdentifier conversion function must not be null%22);
 %0A    Immutab
@@ -1351,19 +1351,23 @@
 tifier%3E 
-out
+builder
  = Immut
@@ -1375,16 +1375,31 @@
 bleList.
+%3CCqlIdentifier%3E
 builder(
@@ -1440,16 +1440,180 @@
     
-out.add(
+builder.add(fn.apply(name));%0A    %7D%0A    return builder.build();%0A  %7D%0A%0A  @NonNull%0A  public static List%3CCqlIdentifier%3E wrap(@NonNull Iterable%3CString%3E in) %7B%0A    return wrap(in, 
 CqlI
@@ -1625,68 +1625,192 @@
 fier
-.
+::
 fromCql
-(name));%0A    %7D%0A    return out.build();%0A  %7D%0A%0A  public
+);%0A  %7D%0A%0A  @NonNull%0A  public static List%3CCqlIdentifier%3E wrapInternal(@NonNull Iterable%3CString%3E in) %7B%0A    return wrap(in, CqlIdentifier::fromInternal);%0A  %7D%0A%0A  @NonNull%0A  private
  sta
@@ -1848,16 +1848,32 @@
 rapKeys(
+%0A      @NonNull 
 Map%3CStri
@@ -1877,27 +1877,220 @@
 tring, V%3E in
-) %7B
+, @NonNull Function%3CString, CqlIdentifier%3E fn) %7B%0A    Objects.requireNonNull(in, %22Input Map must not be null%22);%0A    Objects.requireNonNull(fn, %22CqlIdentifier conversion function must not be null%22);
 %0A    Immutab
@@ -2121,19 +2121,23 @@
 ier, V%3E 
-out
+builder
  = Immut
@@ -2144,16 +2144,34 @@
 ableMap.
+%3CCqlIdentifier, V%3E
 builder(
@@ -2238,37 +2238,28 @@
     
-out.put(CqlIdentifier.fromCql
+builder.put(fn.apply
 (ent
@@ -2312,18 +2312,327 @@
 urn 
-out.build(
+builder.build();%0A  %7D%0A%0A  @NonNull%0A  public static %3CV%3E Map%3CCqlIdentifier, V%3E wrapKeys(@NonNull Map%3CString, V%3E in) %7B%0A    return wrapKeys(in, CqlIdentifier::fromCql);%0A  %7D%0A%0A  @NonNull%0A  public static %3CV%3E Map%3CCqlIdentifier, V%3E wrapKeysInternal(@NonNull Map%3CString, V%3E in) %7B%0A    return wrapKeys(in, CqlIdentifier::fromInternal
 );%0A 

Add new methods to wrap collections using CQL internal form in CqlIdentifiers (#1344)