private static <K, V> List<KeyValue<K, List<V>>> multimapToList(
      Marshaller<K> keyMarshaller, ListMultimap<Bytes, V> in) {
    List<Bytes> keys = Ordering.natural().sortedCopy(in.keySet());
    ImmutableList.Builder<KeyValue<K, List<V>>> out = ImmutableList.builder();
    for (Bytes keyBytes : keys) {
      K key = keyMarshaller.fromBytes(ByteBuffer.wrap(keyBytes.bytes));
      out.add(KeyValue.of(key, in.get(keyBytes)));
    }
    return out.build();
  }
private static < K , V > List < KeyValue < K , List < V > > > multimapToList ( Marshaller < K > keyMarshaller , ListMultimap < Bytes , V > in ) { List < Bytes > keys = Ordering . natural ( ) . sortedCopy ( in . keySet ( ) ) ; ImmutableList . Builder < KeyValue < K , List < V > > > out = ImmutableList . builder ( ) ; for ( Bytes keyBytes : keys ) { K key = keyMarshaller . fromBytes ( ByteBuffer . wrap ( keyBytes . bytes ) ) ; out . add ( KeyValue . of ( key , in . get ( keyBytes ) ) ) ; } return out . build ( ) ; }
Also turns the keys back from Bytes into K.