Source:
public void write(@Nonnull Channel entity, @Nonnull FieldWriter format, @Nonnull OutputContext ctxt) throws IOException { format.writeField("title", entity.getTitle()); format.writeField("id", idCode.encode(entity.getId().toBigInteger())); format.writeField("uri", entity.getCanonicalUri()); format.writeList(IMAGE_WRITER, entity.getImages(), ctxt); format.writeList(AVAILABLE_FROM_WRITER, entity.getAvailableFrom(), ctxt); format.writeObject(AVAILABLE_FROM_WRITER, entity.getSource(), ctxt); format.writeField("media_type", entity.getMediaType()); format.writeObject(BROADCASTER_WRITER, entity.getBroadcaster(), ctxt); format.writeList(ALIAS_WRITER, entity.getAliases(), ctxt); format.writeList("genres", "genres", entity.getGenres(), ctxt); format.writeField("high_definition", entity.getHighDefinition()); format.writeField("regional", entity.getRegional()); format.writeList(RELATED_LINKS_WRITER, entity.getRelatedLinks(), ctxt); format.writeField("start_date", entity.getStartDate()); if(!Strings.isNullOrEmpty(ctxt.getRequest().getParameter("annotations")) && Splitter.on(',') .splitToList( ctxt.getRequest().getParameter("annotations") ).contains(Annotation.CHANNEL_GROUPS_SUMMARY.toKey()) ) { ImmutableList<Id> channelGroupIds = entity.getChannelGroups() .stream() .map(cg -> cg.getChannelGroup().getId()) .collect(ImmutableCollectors.toList()); List<ChannelGroupSummary> channelGroupSummaries = StreamSupport.stream( Futures.get( channelGroupResolver.resolveIds(channelGroupIds), 1, TimeUnit.MINUTES, IOException.class ).getResources().spliterator(), false ) .map(ChannelGroup::toSummary) .collect(ImmutableCollectors.toList()); format.writeList(channelGroupSummaryWriter, channelGroupSummaries, ctxt); } }

Target:
public void write(@Nonnull Channel entity, @Nonnull FieldWriter format, @Nonnull OutputContext ctxt) throws IOException { format.writeField("title", entity.getTitle()); format.writeField("id", idCode.encode(entity.getId().toBigInteger())); format.writeField("uri", entity.getCanonicalUri()); format.writeList(IMAGE_WRITER, entity.getImages(), ctxt); format.writeList(AVAILABLE_FROM_WRITER, entity.getAvailableFrom(), ctxt); format.writeObject(AVAILABLE_FROM_WRITER, entity.getSource(), ctxt); format.writeField("media_type", entity.getMediaType()); format.writeObject(BROADCASTER_WRITER, entity.getBroadcaster(), ctxt); format.writeList(ALIAS_WRITER, entity.getAliases(), ctxt); format.writeList("genres", "genres", entity.getGenres(), ctxt); format.writeField("high_definition", entity.getHighDefinition()); format.writeField("regional", entity.getRegional()); format.writeList(RELATED_LINKS_WRITER, entity.getRelatedLinks(), ctxt); format.writeField("start_date", entity.getStartDate()); if(hasChannelGroupSummaryAnnotation(ctxt)) { ImmutableList<Id> channelGroupIds = entity.getChannelGroups() .stream() .map(cg -> cg.getChannelGroup().getId()) .collect(ImmutableCollectors.toList()); List<ChannelGroupSummary> channelGroupSummaries = StreamSupport.stream( Futures.get( channelGroupResolver.resolveIds(channelGroupIds), 1, TimeUnit.MINUTES, IOException.class ).getResources().spliterator(), false ) .map(ChannelGroup::toSummary) .collect(ImmutableCollectors.toList()); format.writeList(channelGroupSummaryWriter, channelGroupSummaries, ctxt); } }