JsonEncoderImpl implements JsonEncoder<ENTITY> { @Override public <FK_ENTITY> JsonEncoder<ENTITY> putStreamer( String label, Function<ENTITY, Stream<FK_ENTITY>> streamer, JsonEncoder<FK_ENTITY> fkEncoder) { requireNonNulls(label, streamer, fkEncoder); getters.put(label, e -> "\"" + label + "\":[" + streamer.apply(e).map(fkEncoder::apply).collect(joining(",")) + "]" ); return this; } JsonEncoderImpl(Project project, Manager<ENTITY> manager); @Override Manager<ENTITY> getManager(); @Override JsonEncoder<ENTITY> put(ReferenceField<ENTITY, D, V> field); @Override JsonEncoder<ENTITY> putByte(ByteField<ENTITY, D> field); @Override JsonEncoder<ENTITY> putShort(ShortField<ENTITY, D> field); @Override JsonEncoder<ENTITY> putInt(IntField<ENTITY, D> field); @Override JsonEncoder<ENTITY> putLong(LongField<ENTITY, D> field); @Override JsonEncoder<ENTITY> putFloat(FloatField<ENTITY, D> field); @Override JsonEncoder<ENTITY> putDouble(DoubleField<ENTITY, D> field); @Override JsonEncoder<ENTITY> putChar(CharField<ENTITY, D> field); @Override JsonEncoder<ENTITY> putBoolean(BooleanField<ENTITY, D> field); @Override JsonEncoder<ENTITY> put(String label, ReferenceGetter<ENTITY, T> getter); @Override JsonEncoder<ENTITY> putByte(String label, ByteGetter<ENTITY> getter); @Override JsonEncoder<ENTITY> putShort(String label, ShortGetter<ENTITY> getter); @Override JsonEncoder<ENTITY> putInt(String label, IntGetter<ENTITY> getter); @Override JsonEncoder<ENTITY> putLong(String label, LongGetter<ENTITY> getter); @Override JsonEncoder<ENTITY> putFloat(String label, FloatGetter<ENTITY> getter); @Override JsonEncoder<ENTITY> putDouble(String label, DoubleGetter<ENTITY> getter); @Override JsonEncoder<ENTITY> putChar(String label, CharGetter<ENTITY> getter); @Override JsonEncoder<ENTITY> putBoolean(String label, BooleanGetter<ENTITY> getter); @Override JsonEncoder<ENTITY> put(FIELD field, JsonEncoder<FK_ENTITY> encoder); @Override JsonEncoder<ENTITY> put(
            String label, 
            FindFrom<ENTITY, FK_ENTITY> finder, 
            JsonEncoder<FK_ENTITY> fkEncoder); @Override JsonEncoder<ENTITY> putStreamer(
            String label, 
            Function<ENTITY, Stream<FK_ENTITY>> streamer, 
            JsonEncoder<FK_ENTITY> fkEncoder); @Override JsonEncoder<ENTITY> putStreamer(
            String label, 
            Function<ENTITY, Stream<FK_ENTITY>> streamer, 
            Function<FK_ENTITY, String> fkEncoder); @Override JsonEncoder<ENTITY> remove(String label); @Override JsonEncoder<ENTITY> remove(Field<ENTITY> field); @Override String apply(ENTITY entity); @Override JsonCollector<ENTITY> collector();  }
@Test void putStreamer() { final String label = "lang"; final JsonEncoder<Language> other = new JsonEncoderImpl<>(project, languageManager); other.put(Language.NAME); instance.putStreamer(label, u -> Stream.of(language), other); instance.put(User.NAME); assertContainsWhenRendered(NAME, LANGUAGE_NAME, label); }
@Test void testPutStreamer() { final String label = "lang"; final JsonEncoder<Language> other = new JsonEncoderImpl<>(project, languageManager); other.put(Language.NAME); instance.putStreamer(label, u -> Stream.of(language), l -> "\"" + l.getName() + "\""); instance.put(User.NAME); assertContainsWhenRendered(NAME, LANGUAGE_NAME, label); }