BloomFilter { public byte[] serialize() { return bits.toByteArray(); } private  BloomFilter(byte[] bytes, int size, int hashFunctionSize); private  BloomFilter(int size, int hashFunctionSize); static BloomFilter getEmptyBloomFilter(double errorPercent, int numOfString); static BloomFilter buildBloomFilter(byte[] bytes, int size, int hashFunctionSize); int getHashFunctionSize(); int getSize(); void setSize(int size); void add(String value); boolean contains(String value); int getBitCount(); byte[] serialize();  }
@Test public void testSerialize() { String value1 = "device1.s1"; String value2 = "device1.s2"; String value3 = "device1.s3"; BloomFilter filter = BloomFilter.getEmptyBloomFilter(0.05, 3); filter.add(value1); filter.add(value2); filter.add(value3); BloomFilter filter1 = BloomFilter.buildBloomFilter(filter.serialize(), filter.getSize(), filter.getHashFunctionSize()); assertTrue(filter1.contains(value1)); assertTrue(filter1.contains(value2)); assertTrue(filter1.contains(value3)); }