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

org.babyfish.jimmer.sql.cache.chain.ParameterizedLockedSimpleBinder Maven / Gradle / Ivy

There is a newer version: 0.9.19
Show newest version
package org.babyfish.jimmer.sql.cache.chain;

import org.babyfish.jimmer.meta.ImmutableProp;
import org.babyfish.jimmer.meta.ImmutableType;
import org.babyfish.jimmer.sql.cache.CacheLocker;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.time.Duration;
import java.util.Collection;
import java.util.Map;
import java.util.SortedMap;

class ParameterizedLockedSimpleBinder implements SimpleBinder.Parameterized, LockedBinder {

    private final LockableBinder.Parameterized raw;

    private final CacheLocker locker;

    private final Duration waitDuration;

    private final Duration leaseDuration;

    @SuppressWarnings("unchecked")
    ParameterizedLockedSimpleBinder(
            LockableBinder.Parameterized raw,
            CacheLocker locker,
            Duration waitDuration,
            Duration leaseDuration
    ) {
        if (raw instanceof LockedBinder) {
            raw = (LockableBinder.Parameterized)((LockedBinder) raw).unwrap();
        }
        this.raw = raw;
        this.locker = locker;
        this.waitDuration = waitDuration;
        this.leaseDuration = leaseDuration;
    }

    @Override
    public LockableBinder.Parameterized unwrap() {
        return raw;
    }

    @Override
    public CacheLocker locker() {
        return locker;
    }

    @Override
    public Duration waitDuration() {
        return waitDuration;
    }

    @Override
    public Duration leaseDuration() {
        return leaseDuration;
    }

    @Override
    public @Nullable ImmutableType type() {
        return raw.type();
    }

    @Override
    public @Nullable ImmutableProp prop() {
        return raw.prop();
    }

    @Override
    public @NotNull TrackingMode tracingMode() {
        return raw.tracingMode();
    }

    @Override
    public Map getAll(Collection keys, SortedMap parameterMap) {
        return raw.getAll(keys, parameterMap);
    }

    @Override
    public void setAll(Map map, SortedMap parameterMap) {
        raw.setAll(map, parameterMap);
    }

    @Override
    public void deleteAll(Collection keys, Object reason) {
        raw.deleteAll(keys, reason);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy