StringsBag extends AbstractCollection<StringIdentifier> implements Comparable<StringsBag> { public byte[] getBytes() { ByteBuffer buffer = ByteBuffer.allocate(4 * 2 * terms.length); for (int i = 0; i < terms.length; i++) { buffer.putInt(terms[i]); buffer.putInt(counts[i]); } return buffer.array(); } StringsBag(int[] terms, int[] counts);  StringsBag(byte[] bytes); static Builder builder(); List<StringIdentifier> toTerms(); boolean contains(StringIdentifier stringIdentifier); int countOf(StringIdentifier stringIdentifier); int uniqueTerms(); @Override boolean equals(@Nullable Object o); @Override int hashCode(); byte[] getBytes(); @Override Iterator<StringIdentifier> iterator(); @Override int size(); @Override int compareTo(@Nonnull StringsBag o);  }
@Test public void testGetBytes() { Builder builder = new Builder(); builder.addTerm(new StringIdentifier(5)); builder.addTerm(new StringIdentifier(5)); builder.addTerm(new StringIdentifier(6)); builder.addTerm(new StringIdentifier(10)); StringsBag bag = builder.build(); byte[] bytes = bag.getBytes(); StringsBag bag2 = new StringsBag(bytes); assertEquals(bag2.uniqueTerms(), 3); assertEquals(bag2.size(), 4); assertEquals(bag2.countOf(new StringIdentifier(5)), 2); assertEquals(bag2.countOf(new StringIdentifier(6)), 1); assertEquals(bag2.countOf(new StringIdentifier(10)), 1); }