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

com.ibm.wala.util.collections.HashMapFactory Maven / Gradle / Ivy

The newest version!
/*
 * Copyright (c) 2002 - 2006 IBM Corporation.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     IBM Corporation - initial API and implementation
 */
package com.ibm.wala.util.collections;

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

/**
 * A debugging aid. When HashSetFactory.DEBUG is set, this class creates ParanoidHashMaps.
 * Otherwise, it returns {@link LinkedHashMap}
 */
public class HashMapFactory {

  /**
   * @return A ParanoidHashMap if DEBUG = true, a LinkedHashMap otherwise
   */
  public static  HashMap make(int size) {
    if (HashSetFactory.DEBUG) {
      return new ParanoidHashMap<>(size);
    } else {
      return new LinkedHashMap<>(size);
    }
  }

  /**
   * @return A ParanoidHashMap if DEBUG = true, a LinkedHashMap otherwise
   */
  public static  HashMap make() {
    if (HashSetFactory.DEBUG) {
      return new ParanoidHashMap<>();
    } else {
      return new LinkedHashMap<>();
    }
  }

  /**
   * @return A ParanoidHashMap if DEBUG = true, a LinkedHashMap otherwise
   */
  public static  HashMap make(Map t) {
    if (t == null) {
      throw new IllegalArgumentException("null t");
    }
    if (HashSetFactory.DEBUG) {
      return new ParanoidHashMap<>(t);
    } else {
      return new LinkedHashMap<>(t);
    }
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy