View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one or more
3    * contributor license agreements.  See the NOTICE file distributed with
4    * this work for additional information regarding copyright ownership.
5    * The ASF licenses this file to You under the Apache License, Version 2.0
6    * (the "License"); you may not use this file except in compliance with
7    * the License.  You may obtain a copy of the License at
8    *
9    *      http://www.apache.org/licenses/LICENSE-2.0
10   *
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS,
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   * See the License for the specific language governing permissions and
15   * limitations under the License.
16   */
17  package org.apache.commons.collections4.bloomfilter;
18  
19  import java.util.function.IntPredicate;
20  import java.util.function.LongPredicate;
21  
22  /**
23   * An abstract class to assist in implementing Bloom filter decorators.
24   *
25   * @since 4.5
26   */
27  public abstract class WrappedBloomFilter implements BloomFilter {
28      final BloomFilter wrapped;
29  
30      /**
31       * Wraps a Bloom filter.  The wrapped filter is maintained as a reference
32       * not a copy.  Changes in one will be reflected in the other.
33       * @param bf The Bloom filter.
34       */
35      public WrappedBloomFilter(BloomFilter bf) {
36          this.wrapped = bf;
37      }
38  
39      @Override
40      public long[] asBitMapArray() {
41          return wrapped.asBitMapArray();
42      }
43  
44      @Override
45      public int[] asIndexArray() {
46          return wrapped.asIndexArray();
47      }
48  
49      @Override
50      public int cardinality() {
51          return wrapped.cardinality();
52      }
53  
54      @Override
55      public int characteristics() {
56          return wrapped.characteristics();
57      }
58  
59      @Override
60      public void clear() {
61          wrapped.clear();
62      }
63  
64      @Override
65      public boolean contains(BitMapProducer bitMapProducer) {
66          return wrapped.contains(bitMapProducer);
67      }
68  
69      @Override
70      public boolean contains(BloomFilter other) {
71          return wrapped.contains(other);
72      }
73  
74      @Override
75      public boolean contains(Hasher hasher) {
76          return wrapped.contains(hasher);
77      }
78  
79      @Override
80      public boolean contains(IndexProducer indexProducer) {
81          return wrapped.contains(indexProducer);
82      }
83  
84      @Override
85      public BloomFilter copy() {
86          return wrapped.copy();
87      }
88  
89      @Override
90      public int estimateIntersection(BloomFilter other) {
91          return wrapped.estimateIntersection(other);
92      }
93  
94      @Override
95      public int estimateN() {
96          return wrapped.estimateN();
97      }
98  
99      @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 }