@SuppressWarnings("unchecked") @Override public boolean containsAll(Collection<?> c, ElementMatcher<? super Entry<K, V>> matcher) { this.requiredEnabled(); RootData<K, V> rootData = this.getRootData(); if (matcher == null) { UnifiedComparator<? super V> valueUnifiedComparator = rootData.valueUnifiedComparator(); for (Object o : c) { if (!(o instanceof Entry<?, ?>)) { return false; } Entry<K, V> e = (Entry<K, V>) o; Ref<V> ref = rootData.visionallyRead(e.getKey(), null); if (ref == null) { rootData.load(); return this.getBase().containsAll(c, matcher); } if (ref.get() == null) { return false; } if (!valueUnifiedComparator.equals(ref.get(), e.getValue())) { return false; } } return true; } rootData.load(); return this.getBase().containsAll(c, matcher); }
@Override public boolean isEmpty() { this.requiredEnabled(); RootData<K, V> rootData = this.getRootData(); if (0 == rootData.visionallyReadSize()) { return true; } rootData.load(); return this.getBase().isEmpty(); }
@SuppressWarnings("unchecked") @Override public V get(Object key) { this.requiredEnabled(); RootData<K, V> rootData = this.<RootData<K, V>>getRootData(); Ref<V> ref = rootData.visionallyRead((K) key, null); if (ref != null) { return ref.get(); } rootData.load(); return this.getBase().get(key); }
@Override public int size() { this.requiredEnabled(); RootData<K, V> rootData = this.getRootData(); if (this.<AbstractLazyXMap<K, V>>getParentMap().getParent() == null) { int size = rootData.visionallyReadSize(); if (size != -1) { return size; } } rootData.load(); return this.getBase().size(); }
@SuppressWarnings("unchecked") @Override public boolean contains(Object o, ElementMatcher<? super K> matcher) { this.requiredEnabled(); RootData<K, V> rootData = this.<RootData<K, V>>getRootData(); if (matcher == null) { Ref<V> ref = rootData.visionallyRead((K) o, null); if (ref != null) { return ref.get() != null; } } rootData.load(); return this.getBase().contains(o, matcher); }
@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") @Override public boolean containsAll(Collection<?> c, ElementMatcher<? super K> matcher) { this.requiredEnabled(); RootData<K, V> rootData = this.<RootData<K, V>>getRootData(); if (matcher == null) { for (Object o : c) { Ref<V> ref = rootData.visionallyRead((K) o, null); if (ref == null) { rootData.load(); return this.getBase().containsAll(c, matcher); } if (ref.get() == null) { return false; } } return true; } rootData.load(); return this.getBase().containsAll(c, matcher); }
@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; }