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

us.codecraft.webmagic.utils.MultiKeyMapBase Maven / Gradle / Ivy

The newest version!
package us.codecraft.webmagic.utils;

/**
 * @author [email protected]
 */

import java.util.HashMap;
import java.util.Map;

/**
 * multi-key map, some basic objects *
 *
 * @author yihua.huang
 */
public abstract class MultiKeyMapBase {

    protected static final Class DEFAULT_CLAZZ = HashMap.class;
    @SuppressWarnings("rawtypes")
    private Class protoMapClass = DEFAULT_CLAZZ;

    public MultiKeyMapBase() {
    }

    @SuppressWarnings("rawtypes")
    public MultiKeyMapBase(Class protoMapClass) {
        this.protoMapClass = protoMapClass;
    }

    @SuppressWarnings("unchecked")
    protected  Map newMap() {
        try {
            return (Map) protoMapClass.newInstance();
        } catch (InstantiationException e) {
            throw new IllegalArgumentException("wrong proto type map "
                    + protoMapClass);
        } catch (IllegalAccessException e) {
            throw new IllegalArgumentException("wrong proto type map "
                    + protoMapClass);
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy