Code example for ConcurrentHashMap

Methods: putIfAbsent

     * @return 
     *      If the value was null, return the {@code instance} value. 
     *      Otherwise return the current value, which is non-null. 
    public <T> T setIfNull(Class<T> type, T instance) {
        Object o = data.putIfAbsent(type, instance);
        if (o!=null)    return type.cast(o);
        return instance;
Stop searching for code, let great code find you!  Add Codota to your java IDE