All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.polaris.core.map.CaseCamelMap Maven / Gradle / Ivy

There is a newer version: 3.2.1
Show newest version
package io.polaris.core.map;

import java.util.LinkedHashMap;
import java.util.Map;
import java.util.function.Function;
import java.util.function.Supplier;

import io.polaris.core.string.StringCases;

/**
 * @author Qt
 * @since 1.8
 */
@SuppressWarnings({"rawtypes", "unchecked"})
public class CaseCamelMap extends TransformMap {
	private static final Function TRANSFORMER = key -> (key instanceof CharSequence ? StringCases.underlineToCamelCase((CharSequence) key) : key);

	public CaseCamelMap(Supplier> supplier) {
		super(supplier, TRANSFORMER);
	}

	public CaseCamelMap() {
		super(new LinkedHashMap<>(), TRANSFORMER);
	}

	public CaseCamelMap(Supplier> supplier, Map raw) {
		this(supplier);
		this.addRawData(raw);
	}

	public CaseCamelMap(Map raw) {
		this();
		this.addRawData(raw);
	}

	private void addRawData(Map raw) {
		for (Entry entry : raw.entrySet()) {
			putIfAbsent(entry.getKey(), entry.getValue());
		}
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy