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

xapi.collect.impl.StringToAbstract Maven / Gradle / Ivy

There is a newer version: 0.5
Show newest version
package xapi.collect.impl;

import java.util.HashMap;
import java.util.concurrent.ConcurrentHashMap;

import xapi.annotation.inject.InstanceDefault;
import xapi.collect.api.StringTo;
import xapi.platform.GwtDevPlatform;
import xapi.platform.JrePlatform;
import xapi.util.X_Runtime;

@JrePlatform
@GwtDevPlatform
@InstanceDefault(implFor=StringTo.class)
public class StringToAbstract  implements StringTo{

  private final java.util.Map map;

  public StringToAbstract() {
    if (X_Runtime.isMultithreaded()) {
      map = new ConcurrentHashMap();
    } else {
      map = new HashMap();

    }
  }

  @Override
  public boolean isEmpty() {
    return map.isEmpty();
  }

  @Override
  public void clear() {
    map.clear();
  }

  @Override
  public boolean containsKey(Object key) {
    return map.containsKey(key);
  }

  @Override
  public boolean containsValue(Object key) {
    return map.containsValue(key);
  }

  @Override
  @SuppressWarnings({"unchecked","rawtypes"})
  public void putAll(Iterable> items) {
    if (items instanceof java.util.Map) {
      map.putAll((java.util.Map)items);
    } else {
      for (java.util.Map.Entry item : items)
        map.put(item.getKey(), item.getValue());
    }
  }

  @Override
  public void removeAll(Iterable items) {
    for (String item : items)
      map.remove(item);
  }

  @Override
  public Iterable keys() {
    return map.keySet();
  }

  @Override
  public String[] keyArray() {
    return map.keySet().toArray(new String[0]);
  }

  @Override
  public Iterable values() {
    return map.values();
  }

  @Override
  public Iterable> entries() {
    return map.entrySet();
  }

  @Override
  public V get(String key) {
    return map.get(key);
  }

  @Override
  public V put(String key, V value) {
    return map.put(key, value);
  }

  @Override
  public V remove(String key) {
    return map.remove(key);
  }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy