ConcurrentHashMap containsKey - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for ConcurrentHashMap containsKey method.

This code example shows how to use the following methods:containsKey, get, put
    private static ConcurrentHashMap<String, Object> services = new ConcurrentHashMap<String, Object>();
 
    @SuppressWarnings("unchecked") 
    public T get(final Class<T> cls){
        String key = cls.getName();
        if (services.containsKey(key)) {
            return (T) services.get(key);
 
        } else { 
            T service = createClient(cls, targetIP, targetPort, connectTimeout,clientNums);
            services.put(key, service);
            return (T) services.get(key);
        } 
    } 
 
    protected T createClient(Class<T> cls, String targetIP, int targetPort, int connectTimeout,int clientNums){
        ReferenceConfig<T> referenceConfig = new ReferenceConfig<T>();
        referenceConfig.setInterface(cls);
        StringBuilder url = new StringBuilder();
        url.append("dubbo://");
7
CodeRank
This code example shows how to use the following methods:containsKey, get, put
                ProcessJobContext processCtx = (ProcessJobContext) ctx;
                jobname = processCtx.getSessionId() + "-" + processCtx.getProcessInstanceId() + "-" + processCtx.getTimer().getId();
                if (processCtx instanceof StartProcessJobContext) {
                    jobname = "StartProcess-"+((StartProcessJobContext) processCtx).getProcessId()+ "-" + processCtx.getTimer().getId();
                } 
                if (activeTimer.containsKey(jobname)) {
                    return activeTimer.get(jobname);
                } 
             
            } 
            GlobalJDKJobHandle jobHandle = new GlobalJDKJobHandle( idCounter.getAndIncrement() );
             
            TimerJobInstance jobInstance = ((AcceptsTimerJobFactoryManager) globalTimerService).
                                 getTimerJobFactoryManager().createTimerJobInstance( job,
                                                                                     ctx,
                                                                                     trigger,
                                                                                     jobHandle,
                                                                                     (InternalSchedulerService) globalTimerService );
            jobHandle.setTimerJobInstance( (TimerJobInstance) jobInstance );
            interceptor.internalSchedule( (TimerJobInstance) jobInstance );

6
CodeRank
This code example shows how to use the following methods:containsKey, get
This code example shows how to use the following methods:containsKey, get, putIfAbsent
  public DaemonThreadPoolFactory(Class<?> parentClass) {
    this.name = "Hector." + parentClass.getName();
  } 
 
  private int getNextThreadNumber() { 
    if(!counters.containsKey(name)) {
      counters.putIfAbsent(name, new AtomicInteger());
    } 
    return counters.get(name).incrementAndGet();
  } 
   
  @Override 
  public Thread newThread(Runnable r) {
      Thread t = new Thread(r);
      t.setDaemon(true);
      t.setName(name + "-" + getNextThreadNumber());
      return t;
  } 
     
} 
7
CodeRank
This code example shows how to use the following methods:containsKey
		Object value = this.properties.get(name);
		return (value instanceof String) ? (String) value : null;
	} 
 
	public boolean propertyExists(String name) throws JMSException {
		return this.properties.containsKey(name);
	} 
 
	public void setBooleanProperty(String name, boolean value) throws JMSException {
		this.properties.put(name, value);
	} 
 
	public void setByteProperty(String name, byte value) throws JMSException {
		this.properties.put(name, value);
	} 
 
	public void setDoubleProperty(String name, double value) throws JMSException {
		this.properties.put(name, value);
	} 
 
6
CodeRank
This code example shows how to use the following methods:containsKey, get
		this.marhsalContexts.remove(ownerId); 
	} 
 
	 
	public ContentMarshallerContext getMarshallerContext(Task task) { 
		if (task.getTaskData().getDeploymentId() != null && this.marhsalContexts.containsKey(task.getTaskData().getDeploymentId())) { 
            return this.marhsalContexts.get(task.getTaskData().getDeploymentId()); 
        } 
         
        return new ContentMarshallerContext(); 
	} 
	 
	public ContentMarshallerContext getMarshallerContext(String deploymentId) { 
		if (deploymentId != null && this.marhsalContexts.containsKey(deploymentId)) { 
            return this.marhsalContexts.get(deploymentId); 
        } 
         
        return new ContentMarshallerContext(); 
	} 
} 
6
CodeRank
This code example shows how to use the following methods:containsKey, get, remove
	} 
 
	static Vector commit(int id) 
	{ 
		Vector aVector = null;
		if(map.containsKey(id))
		{ 
			aVector = map.get(id);
		} 
		MwHashTable.commit(id);
		map.remove(id);
		return aVector;
	} 
 
	static Vector abort(int id) 
	{ 
		Vector aVector = null;
		if(map.containsKey(id))
		{ 
			aVector = map.get(id);
6
CodeRank
This code example shows how to use the following methods:containsKey, put
			return retValue; 
		} 
		else 
		{ 
 
			if (cache.containsKey(locator))
			{ 
				return cache.get(locator);
			} 
			if (!Modifier.isFinal(type.getModifiers()))
			{ 
				Object proxy = LazyInitProxyFactory.createProxy(type, locator);
				cache.put(locator, proxy);
				return proxy; 
			} 
			else 
			{ 
				Object value = locator.locateProxyTarget();
				cache.put(locator, value);
				return value; 

6
CodeRank
This code example shows how to use the following methods:containsKey
    } 
 
 
    @Override 
    public boolean containsKey(final BytesKey key) { 
        return this.map.containsKey(key); 
    } 
 
 
    @Override 
    public OpItem get(final BytesKey key) { 
        return this.map.get(key); 
    } 
 
 
    @Override 
    public Iterator<BytesKey> keyIterator() { 
        return this.map.keySet().iterator(); 
    } 
 
5
CodeRank
This code example shows how to use the following methods:sleep, containsKey, get
	private final String tag = "BatteryMonitor, thread"+this.hashCode()+":: ";
	private ConcurrentHashMap<String, Object> ioMap;
	@Override 
	public void run() { 
		int seconds = 0;
		if(ioMap.containsKey("time_in_seconds")){
			/* 
			 * Input Section 
			 */ 
			seconds = (Integer)(ioMap.get("time_in_seconds"));
//			System.out.println(tag+"Received input name = "+name); 
                        form.setArea(tag+"Battery will run out in "+seconds+" seconds");
			try { 
				Thread.sleep(seconds*1000);
                                form.lowBattery(); 
				ioMap.clear();
				ioMap.put("home", "Rm282");
				ioMap.put("lowBattery", true);
			} catch (InterruptedException e) {
				//Assassinate silently 
5
CodeRank
containsKey Method Overview
Tests if the specified object is a key in this table.
See Code Examples for other Java 8 ConcurrentHashMap Methods: