@SuppressWarnings("unchecked") Boolean visionallRemoveImpl(Object o) { if (!(o instanceof Entry<?, ?>)) { return false; } RootData<K, V> rootData = this.<RootData<K, V>>getRootData(); if (rootData.isLoaded()) { return null; } if (!rootData.isVisionallyReadable(QueuedOperationType.DETACH)) { return null; } if (rootData.isLoading()) { throw new IllegalStateException( LAZY_COMMON_RESOURCE.get().visionOperationWhenDataIsBeingLoaded()); } Entry<K, V> e = (Entry<K, V>) o; Ref<V> ref = rootData.visionallyRead(e.getKey(), null); if (ref != null) { if (ref.get() == null) { return false; } if (!rootData.valueUnifiedComparator().equals(ref.get(), e.getValue())) { return false; } rootData.visinallyRemove(e.getKey(), ref.get()); return true; } return null; }
@SuppressWarnings("unchecked") Boolean visionallyRemoveAllImpl(Collection<?> c) { RootData<K, V> rootData = this.<RootData<K, V>>getRootData(); if (rootData.isLoaded()) { return null; } if (!rootData.isVisionallyReadable(QueuedOperationType.DETACH)) { return null; } if (rootData.isLoading()) { throw new IllegalStateException( LAZY_COMMON_RESOURCE.get().visionOperationWhenDataIsBeingLoaded()); } int len = 0; Object[] arr = new Object[c.size() << 1]; for (Object o : c) { Ref<V> ref = rootData.visionallyRead((K) o, QueuedOperationType.DETACH); if (ref == null) { return null; } if (ref.get() == null) { continue; } arr[len++] = o; arr[len++] = ref.get(); } for (int i = 0; i < len; i += 2) { rootData.visinallyRemove((K) arr[i], (V) arr[i + 1]); } return len != 0; }
@SuppressWarnings("unchecked") Ref<V> visionallyRemoveImpl(Object key) { RootData<K, V> rootData = this.getRootData(); if (rootData.isLoaded()) { return null; } if (!rootData.isVisionallyReadable(QueuedOperationType.DETACH)) { return null; } if (!rootData.getLazyBehaviorProcessor().preVisionallyRead(1)) { return null; } if (rootData.isLoading()) { throw new IllegalStateException( LAZY_COMMON_RESOURCE.get().visionOperationWhenDataIsBeingLoaded()); } Ref<V> ref = rootData.visionallyRead((K) key, QueuedOperationType.DETACH); if (ref != null) { rootData.visinallyRemove((K) key, ref.get()); } return ref; }
@SuppressWarnings("unchecked") Boolean visionallyRemoveAllImpl(Collection<?> c) { RootData<K, V> rootData = this.<RootData<K, V>>getRootData(); if (rootData.isLoaded()) { return null; } if (!rootData.isVisionallyReadable(QueuedOperationType.DETACH)) { return null; } if (rootData.isLoading()) { throw new IllegalStateException( LAZY_COMMON_RESOURCE.get().visionOperationWhenDataIsBeingLoaded()); } int len = 0; Object[] arr = new Object[c.size() << 1]; UnifiedComparator<? super V> valueUnifiedComparator = rootData.valueUnifiedComparator(); for (Object o : c) { if (o instanceof Entry<?, ?>) { Entry<K, V> e = (Entry<K, V>) o; Ref<V> ref = rootData.visionallyRead(e.getKey(), QueuedOperationType.DETACH); if (ref == null) { return null; } if (ref.get() == null) { continue; } if (!valueUnifiedComparator.equals(ref.get(), e.getValue())) { continue; } arr[len++] = e.getKey(); arr[len++] = ref.get(); } } for (int i = 0; i < len; i += 2) { rootData.visinallyRemove((K) arr[i], (V) arr[i + 1]); } return len != 0; }
@SuppressWarnings("unchecked") Boolean visionallyRemoveImpl(Object o) { RootData<K, V> rootData = this.<RootData<K, V>>getRootData(); if (rootData.isLoaded()) { return null; } if (!rootData.isVisionallyReadable(QueuedOperationType.DETACH)) { return null; } if (rootData.isLoading()) { throw new IllegalStateException( LAZY_COMMON_RESOURCE.get().visionOperationWhenDataIsBeingLoaded()); } Ref<V> ref = rootData.visionallyRead((K) o, QueuedOperationType.DETACH); if (ref != null) { if (ref.get() == null) { return false; } rootData.visinallyRemove((K) o, ref.get()); return true; } return null; }