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

de.mirkosertic.bytecoder.classlib.java.util.TWeakHashMap Maven / Gradle / Ivy

/*
 * Copyright 2019 Mirko Sertic
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package de.mirkosertic.bytecoder.classlib.java.util;

import de.mirkosertic.bytecoder.api.SubstitutesInClass;

import java.util.AbstractMap;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import java.util.function.BiConsumer;
import java.util.function.BiFunction;
import java.util.function.Function;

@SubstitutesInClass(completeReplace = true)
public class TWeakHashMap 
        extends AbstractMap
        implements Map {

    private final Map delegate;

    public TWeakHashMap() {
        delegate = new HashMap<>();
    }

    public TWeakHashMap(final int capacity) {
        delegate = new HashMap<>(capacity);
    }

    @Override
    public Set> entrySet() {
        return delegate.entrySet();
    }

    @Override
    public V getOrDefault(final Object key, final V defaultValue) {
        return delegate.getOrDefault(key, defaultValue);
    }

    @Override
    public void forEach(final BiConsumer action) {
        delegate.forEach(action);
    }

    @Override
    public void replaceAll(final BiFunction function) {
        delegate.replaceAll(function);
    }

    @Override
    public V putIfAbsent(final K key, final V value) {
        return delegate.putIfAbsent(key, value);
    }

    @Override
    public boolean remove(final Object key, final Object value) {
        return delegate.remove(key, value);
    }

    @Override
    public boolean replace(final K key, final V oldValue, final V newValue) {
        return delegate.replace(key, oldValue, newValue);
    }

    @Override
    public V replace(final K key, final V value) {
        return delegate.replace(key, value);
    }

    @Override
    public V computeIfAbsent(final K key, final Function mappingFunction) {
        return delegate.computeIfAbsent(key, mappingFunction);
    }

    @Override
    public V computeIfPresent(final K key, final BiFunction remappingFunction) {
        return delegate.computeIfPresent(key, remappingFunction);
    }

    @Override
    public V compute(final K key, final BiFunction remappingFunction) {
        return delegate.compute(key, remappingFunction);
    }

    @Override
    public V merge(final K key, final V value, final BiFunction remappingFunction) {
        return delegate.merge(key, value, remappingFunction);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy