IntIndexToIndexMultiMap implements IndexToIndexMultiMap { @Override public void writeTo( @NotNull final OutputStream os) throws IOException { os.write( Ints.toByteArray( V1DatabaseFormat.MultiMapType.LIST_BASED.getCode())); os.write(Ints.toByteArray(map.size())); long offset = 0L; for (Collection<Integer> value : map) { os.write(Longs.toByteArray(offset)); offset += 4L + 4L * value.size(); } for (Collection<Integer> value : map) { os.write(Ints.toByteArray(value.size())); for (Integer v : value) { assert v >= 0; os.write(Ints.toByteArray(v)); } } } IntIndexToIndexMultiMap(
            @NotNull
            final Collection<? extends Collection<Integer>> map); @Override long getSizeInBytes(); @Override void writeTo(
            @NotNull
            final OutputStream os); @Override String toString();  }
@Test(expected = AssertionError.class) public void negativeValue() throws IOException { new IntIndexToIndexMultiMap( singletonList(singletonList(-1))) .writeTo(new ByteArrayOutputStream()); }