@Test(dataProvider = "bitSetData") public void testWrite(BitSet bitSet) { MockKryoOutput output = new MockKryoOutput(); BitSetSerializer serializer = new BitSetSerializer(); serializer.write(mock(Kryo.class), output, bitSet); verify(bitSet, output.len, output.values); }
@Override public void write(final Kryo kryo, final Output output, final BitSet bitSet) { final int bitLen = bitSet.length(); output.writeInt(bitLen, true); int wordNum = bitLen / Long.SIZE; if (bitLen % Long.SIZE > 0) { ++wordNum; } long[] words = new long[wordNum]; for (int i = 0; i < bitLen; ++i) { if (bitSet.get(i)) { words[i / Long.SIZE] |= 1L << (i % Long.SIZE); } } output.writeLongs(words); }
BitSetSerializer extends Serializer<BitSet> { @Override public void write(final Kryo kryo, final Output output, final BitSet bitSet) { final int bitLen = bitSet.length(); output.writeInt(bitLen, true); int wordNum = bitLen / Long.SIZE; if (bitLen % Long.SIZE > 0) { ++wordNum; } long[] words = new long[wordNum]; for (int i = 0; i < bitLen; ++i) { if (bitSet.get(i)) { words[i / Long.SIZE] |= 1L << (i % Long.SIZE); } } output.writeLongs(words); } }
BitSetSerializer extends Serializer<BitSet> { @Override public void write(final Kryo kryo, final Output output, final BitSet bitSet) { final int bitLen = bitSet.length(); output.writeInt(bitLen, true); int wordNum = bitLen / Long.SIZE; if (bitLen % Long.SIZE > 0) { ++wordNum; } long[] words = new long[wordNum]; for (int i = 0; i < bitLen; ++i) { if (bitSet.get(i)) { words[i / Long.SIZE] |= 1L << (i % Long.SIZE); } } output.writeLongs(words); }  }
BitSetSerializer extends Serializer<BitSet> { @Override public void write(final Kryo kryo, final Output output, final BitSet bitSet) { final int bitLen = bitSet.length(); output.writeInt(bitLen, true); int wordNum = bitLen / Long.SIZE; if (bitLen % Long.SIZE > 0) { ++wordNum; } long[] words = new long[wordNum]; for (int i = 0; i < bitLen; ++i) { if (bitSet.get(i)) { words[i / Long.SIZE] |= 1L << (i % Long.SIZE); } } output.writeLongs(words); }  @Override BitSet copy(final Kryo kryo, final BitSet original); @Override void write(final Kryo kryo, final Output output, final BitSet bitSet); @Override BitSet read(final Kryo kryo, final Input input, final Class<BitSet> bitSetClass); }
BitSetSerializer extends Serializer<BitSet> { @Override public void write(final Kryo kryo, final Output output, final BitSet bitSet) { final int bitLen = bitSet.length(); output.writeInt(bitLen, true); int wordNum = bitLen / Long.SIZE; if (bitLen % Long.SIZE > 0) { ++wordNum; } long[] words = new long[wordNum]; for (int i = 0; i < bitLen; ++i) { if (bitSet.get(i)) { words[i / Long.SIZE] |= 1L << (i % Long.SIZE); } } output.writeLongs(words); }  @Override BitSet copy(final Kryo kryo, final BitSet original); @Override void write(final Kryo kryo, final Output output, final BitSet bitSet); @Override BitSet read(final Kryo kryo, final Input input, final Class<BitSet> bitSetClass);  }