content: /*
   ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
   ~                                                                               ~
   ~ The MIT License (MIT)                                                         ~
   ~                                                                               ~
   ~ Copyright (c) 2015-2025 miaixz.org and other contributors.                    ~
   ~                                                                               ~
   ~ Permission is hereby granted, free of charge, to any person obtaining a copy  ~
   ~ of this software and associated documentation files (the "Software"), to deal ~
   ~ in the Software without restriction, including without limitation the rights  ~
   ~ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell     ~
   ~ copies of the Software, and to permit persons to whom the Software is         ~
   ~ furnished to do so, subject to the following conditions:                      ~
   ~                                                                               ~
   ~ The above copyright notice and this permission notice shall be included in    ~
   ~ all copies or substantial portions of the Software.                           ~
   ~                                                                               ~
   ~ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR    ~
   ~ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,      ~
   ~ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE   ~
   ~ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER        ~
   ~ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, ~
   ~ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN     ~
   ~ THE SOFTWARE.                                                                 ~
   ~                                                                               ~
   ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
  */
  package org.miaixz.bus.core.center.map;
  
  import java.io.Serial;
  import java.io.Serializable;
  import java.util.HashMap;
  import java.util.Map;
  import java.util.function.Function;
  
  import org.miaixz.bus.core.lang.Normal;
  import org.miaixz.bus.core.xyz.StringKit;
  
  /**
   * 驼峰Key风格的Map 对KEY转换为驼峰，get("int_value")和get("intValue")获得的值相同，put进入的值也会被覆盖
   *
   * @param <K> 键类型
   * @param <V> 值类型
   * @author Kimi Liu
   * @since Java 17+
   */
  public class CamelCaseMap<K, V> extends FunctionKeyMap<K, V> {
  
      @Serial
      private static final long serialVersionUID = 2852268690056L;
  
      /**
       * 构造
       */
      public CamelCaseMap() {
          this(Normal._16);
      }
  
      /**
       * 构造
       *
       * @param initialCapacity 初始大小
       */
      public CamelCaseMap(final int initialCapacity) {
          this(initialCapacity, Normal.DEFAULT_LOAD_FACTOR);
      }
  
      /**
       * 构造
       *
       * @param m Map
       */
      public CamelCaseMap(final Map<? extends K, ? extends V> m) {
          this(Normal.DEFAULT_LOAD_FACTOR, m);
      }
  
      /**
       * 构造
       *
       * @param loadFactor 加载因子
       * @param m          初始Map，数据会被默认拷贝到一个新的HashMap中
       */
      public CamelCaseMap(final float loadFactor, final Map<? extends K, ? extends V> m) {
          this(m.size(), loadFactor);
          this.putAll(m);
      }
  
      /**
       * 构造
       *
       * @param initialCapacity 初始大小
       * @param loadFactor      加载因子
       */
      public CamelCaseMap(final int initialCapacity, final float loadFactor) {
          this(MapBuilder.of(new HashMap<>(initialCapacity, loadFactor)));
      }
  
      /**
       * 构造 注意此构造将传入的Map作为被包装的Map，针对任何修改，传入的Map都会被同样修改。
       *
       * @param emptyMapBuilder Map构造器，必须构造空的Map
       */
      CamelCaseMap(final MapBuilder<K, V> emptyMapBuilder) {
          // 使Function可以被序列化
          super(emptyMapBuilder.build(), (Function<Object, K> & Serializable) (key) -> {
              if (key instanceof CharSequence) {
                  key = StringKit.toCamelCase(key.toString());
              }
              return (K) key;
          });
      }
  
  }
  