001/* 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache License, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017package org.apache.commons.collections4.bloomfilter; 018 019import java.util.function.IntPredicate; 020import java.util.function.LongPredicate; 021 022/** 023 * An abstract class to assist in implementing Bloom filter decorators. 024 * 025 * @since 4.5 026 */ 027public abstract class WrappedBloomFilter implements BloomFilter { 028 final BloomFilter wrapped; 029 030 /** 031 * Wraps a Bloom filter. The wrapped filter is maintained as a reference 032 * not a copy. Changes in one will be reflected in the other. 033 * @param bf The Bloom filter. 034 */ 035 public WrappedBloomFilter(BloomFilter bf) { 036 this.wrapped = bf; 037 } 038 039 @Override 040 public long[] asBitMapArray() { 041 return wrapped.asBitMapArray(); 042 } 043 044 @Override 045 public int[] asIndexArray() { 046 return wrapped.asIndexArray(); 047 } 048 049 @Override 050 public int cardinality() { 051 return wrapped.cardinality(); 052 } 053 054 @Override 055 public int characteristics() { 056 return wrapped.characteristics(); 057 } 058 059 @Override 060 public void clear() { 061 wrapped.clear(); 062 } 063 064 @Override 065 public boolean contains(BitMapProducer bitMapProducer) { 066 return wrapped.contains(bitMapProducer); 067 } 068 069 @Override 070 public boolean contains(BloomFilter other) { 071 return wrapped.contains(other); 072 } 073 074 @Override 075 public boolean contains(Hasher hasher) { 076 return wrapped.contains(hasher); 077 } 078 079 @Override 080 public boolean contains(IndexProducer indexProducer) { 081 return wrapped.contains(indexProducer); 082 } 083 084 @Override 085 public BloomFilter copy() { 086 return wrapped.copy(); 087 } 088 089 @Override 090 public int estimateIntersection(BloomFilter other) { 091 return wrapped.estimateIntersection(other); 092 } 093 094 @Override 095 public int estimateN() { 096 return wrapped.estimateN(); 097 } 098 099 @Override 100 public int estimateUnion(BloomFilter other) { 101 return wrapped.estimateUnion(other); 102 } 103 104 @Override 105 public boolean forEachBitMap(LongPredicate predicate) { 106 return wrapped.forEachBitMap(predicate); 107 } 108 109 @Override 110 public boolean forEachBitMapPair(BitMapProducer other, LongBiPredicate func) { 111 return wrapped.forEachBitMapPair(other, func); 112 } 113 114 @Override 115 public boolean forEachIndex(IntPredicate predicate) { 116 return wrapped.forEachIndex(predicate); 117 } 118 119 @Override 120 public Shape getShape() { 121 return wrapped.getShape(); 122 } 123 124 @Override 125 public boolean isFull() { 126 return wrapped.isFull(); 127 } 128 129 @Override 130 public boolean merge(BitMapProducer bitMapProducer) { 131 return wrapped.merge(bitMapProducer); 132 } 133 134 @Override 135 public boolean merge(BloomFilter other) { 136 return wrapped.merge(other); 137 } 138 139 @Override 140 public boolean merge(Hasher hasher) { 141 return wrapped.merge(hasher); 142 } 143 144 @Override 145 public boolean merge(IndexProducer indexProducer) { 146 return wrapped.merge(indexProducer); 147 } 148}