keycloakjar.com.github.benmanes.caffeine.cache.FW Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of camunda-platform-7-keycloak-all Show documentation
Show all versions of camunda-platform-7-keycloak-all Show documentation
Camunda 7 Keycloak Identity Provider Plugin including all transitive dependencies
// Copyright 2021 Ben Manes. All Rights Reserved.
//
// 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 com.github.benmanes.caffeine.cache;
import com.github.benmanes.caffeine.cache.References.LookupKeyReference;
import com.github.benmanes.caffeine.cache.References.WeakKeyReference;
import com.github.benmanes.caffeine.cache.References.WeakValueReference;
import java.lang.ref.Reference;
import java.lang.ref.ReferenceQueue;
/**
* WARNING: GENERATED CODE
*
* A cache entry that provides the following features:
*
*
* - WeakKeys
*
- WeakValues
*
*
* @author [email protected] (Ben Manes)
*/
@SuppressWarnings({"unchecked", "PMD.UnusedFormalParameter", "MissingOverride", "NullAway"})
class FW extends Node implements NodeFactory {
protected static final long VALUE_OFFSET =
UnsafeAccess.objectFieldOffset(
FW.class, com.github.benmanes.caffeine.cache.LocalCacheFactory.VALUE);
volatile WeakValueReference value;
FW() {}
FW(
K key,
ReferenceQueue keyReferenceQueue,
V value,
ReferenceQueue valueReferenceQueue,
int weight,
long now) {
this(new WeakKeyReference(key, keyReferenceQueue), value, valueReferenceQueue, weight, now);
}
FW(Object keyReference, V value, ReferenceQueue valueReferenceQueue, int weight, long now) {
UnsafeAccess.UNSAFE.putObject(
this, VALUE_OFFSET, new WeakValueReference(keyReference, value, valueReferenceQueue));
}
public final Object getKeyReference() {
WeakValueReference valueRef = (WeakValueReference) getValueReference();
return valueRef.getKeyReference();
}
public final K getKey() {
WeakValueReference valueRef = (WeakValueReference) getValueReference();
WeakKeyReference keyRef = (WeakKeyReference) valueRef.getKeyReference();
return keyRef.get();
}
public final V getValue() {
for (; ; ) {
Reference ref = (Reference) UnsafeAccess.UNSAFE.getObject(this, VALUE_OFFSET);
V referent = ref.get();
if ((referent != null) || (ref == value)) {
return referent;
}
}
}
public final Object getValueReference() {
return UnsafeAccess.UNSAFE.getObject(this, VALUE_OFFSET);
}
public final void setValue(V value, ReferenceQueue referenceQueue) {
Reference ref = (Reference) UnsafeAccess.UNSAFE.getObject(this, VALUE_OFFSET);
UnsafeAccess.UNSAFE.putOrderedObject(
this, VALUE_OFFSET, new WeakValueReference(getKeyReference(), value, referenceQueue));
ref.clear();
}
public final boolean containsValue(Object value) {
return getValue() == value;
}
public Node newNode(
K key,
ReferenceQueue keyReferenceQueue,
V value,
ReferenceQueue valueReferenceQueue,
int weight,
long now) {
return new FW<>(key, keyReferenceQueue, value, valueReferenceQueue, weight, now);
}
public Node newNode(
Object keyReference, V value, ReferenceQueue valueReferenceQueue, int weight, long now) {
return new FW<>(keyReference, value, valueReferenceQueue, weight, now);
}
public Object newLookupKey(Object key) {
return new LookupKeyReference<>(key);
}
public Object newReferenceKey(K key, ReferenceQueue referenceQueue) {
return new WeakKeyReference(key, referenceQueue);
}
public boolean weakValues() {
return true;
}
public final boolean isAlive() {
Object key = getKeyReference();
return (key != RETIRED_WEAK_KEY) && (key != DEAD_WEAK_KEY);
}
public final boolean isRetired() {
return (getKeyReference() == RETIRED_WEAK_KEY);
}
public final void retire() {
WeakValueReference valueRef = (WeakValueReference) getValueReference();
WeakKeyReference keyRef = (WeakKeyReference) valueRef.getKeyReference();
keyRef.clear();
valueRef.setKeyReference(RETIRED_WEAK_KEY);
valueRef.clear();
}
public final boolean isDead() {
return (getKeyReference() == DEAD_WEAK_KEY);
}
public final void die() {
WeakValueReference valueRef = (WeakValueReference) getValueReference();
WeakKeyReference keyRef = (WeakKeyReference) valueRef.getKeyReference();
keyRef.clear();
valueRef.setKeyReference(DEAD_WEAK_KEY);
valueRef.clear();
}
}