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

io.polaris.core.map.CasePascalMap 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 CasePascalMap extends TransformMap {
	private static final Function TRANSFORMER = key -> (key instanceof CharSequence ? StringCases.underlineToPascalCase((CharSequence) key) : key);

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

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

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

	public CasePascalMap(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