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

org.lastaflute.di.util.tiger.Maps Maven / Gradle / Ivy

There is a newer version: 2.0.0
Show newest version
/*
 * Copyright 2015-2021 the original author or authors.
 *
 * 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 org.lastaflute.di.util.tiger;

import java.util.HashMap;
import java.util.Hashtable;
import java.util.IdentityHashMap;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.TreeMap;
import java.util.WeakHashMap;
import java.util.concurrent.ConcurrentHashMap;

/**
 * 
 * Map map = map("a", 1).$("b", 2).$("c", 3).$();
 * 
* @param The type of key. * @param The type of value. * @author modified by jflute (originated in Seasar) */ public class Maps { protected Map map; public static Maps map(KEY key, VALUE value) { return linkedHashMap(key, value); } public static Maps concurrentHashMap(KEY key, VALUE value) { return new Maps(new ConcurrentHashMap()).$(key, value); } public static Maps hashMap(KEY key, VALUE value) { return new Maps(new HashMap()).$(key, value); } public static Maps hashtable(KEY key, VALUE value) { return new Maps(new Hashtable()).$(key, value); } public static Maps identityHashMap(KEY key, VALUE value) { return new Maps(new IdentityHashMap()).$(key, value); } public static Maps linkedHashMap(KEY key, VALUE value) { return new Maps(new LinkedHashMap()).$(key, value); } public static Maps treeMap(KEY key, VALUE value) { return new Maps(new TreeMap()).$(key, value); } public static Maps weakHashMap(KEY key, VALUE value) { return new Maps(new WeakHashMap()).$(key, value); } protected Maps(Map map) { this.map = map; } public Maps $(K key, V value) { map.put(key, value); return this; } public Map $() { return map; } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy