org.babyfish.jimmer.sql.cache.chain.LockedSimpleBinder Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jimmer-sql Show documentation
Show all versions of jimmer-sql Show documentation
A revolutionary ORM framework for both java and kotlin
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;
class LockedSimpleBinder implements SimpleBinder, LockedBinder {
private final LockableBinder raw;
private final CacheLocker locker;
private final Duration waitDuration;
private final Duration leaseDuration;
@SuppressWarnings("unchecked")
LockedSimpleBinder(
LockableBinder raw,
CacheLocker locker,
Duration waitDuration,
Duration leaseDuration
) {
if (raw instanceof LockedBinder) {
raw = (LockableBinder)((LockedBinder) raw).unwrap();
}
if (raw instanceof SimpleBinder.Parameterized, ?>) {
throw new IllegalArgumentException(
"The raw binder cannot be \"" + SimpleBinder.Parameterized.class.getName() + "\""
);
}
this.raw = raw;
this.locker = locker;
this.waitDuration = waitDuration;
this.leaseDuration = leaseDuration;
}
@Override
public LockableBinder 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) {
return raw.getAll(keys);
}
@Override
public void setAll(Map map) {
raw.setAll(map);
}
@Override
public void deleteAll(Collection keys, Object reason) {
raw.deleteAll(keys, reason);
}
}