anchor.diff:      }
       else <%
     end
  +  if 0 != replication_modes.size
   %>
       {
         throw new IllegalArgumentException("Unknown mode " + mode);
       }
  +<% end -%>
     }
  -<% end -%>
  -<% end -%>
  +<%
  +  end
  +end -%>
   
     public void encodeObjects( @javax.annotation.Nonnull final java.util.LinkedList<org.realityforge.replicant.server.EntityMessage> messages, @javax.annotation.Nonnull final java.util.List objects )
     {
  
positive.code:   {
      _messageGenerator = messageGenerator;
    }
  
  <% repository.data_modules.select { |data_module| data_module.imit?  }.each do |data_module| -%>
  <% data_module.entities.select { |entity| entity.imit? && !entity.abstract? }.each do |entity| %>
  <% if entity.imit.replication_root? -%>
    public void encode<%= entity.name %>( @javax.annotation.Nonnull final java.util.LinkedList<org.realityforge.replicant.server.EntityMessage> messages, @javax.annotation.Nonnull final <%= entity.jpa.qualified_name %> object )
    {
  
negative.code:   <%= entity.imit.replication_root? ? "public" : "private" %> void encode<%= entity.name %>( @javax.annotation.Nonnull final java.util.LinkedList<org.realityforge.replicant.server.EntityMessage> messages, @javax.annotation.Nonnull final <%= entity.jpa.qualified_name %> object, @javax.annotation.Nonnull final Mode mode )
    {
      encodeObject( messages, object );
  <%
    replication_modes.each do |replication_mode|
  -%>    if( Mode.<%= Domgen::Naming.uppercase_constantize(replication_mode) %> == mode )
      {
  <%
      outgoing_links.each do |a|
        if a.inverse.multiplicity == :many
  -%>
        {
          for ( final <%= a.entity.jpa.qualified_name %> o : object.get<%= Domgen::Naming.pluralize(a.inverse.name) %>() )
          {
            encode<%= a.entity.name %>( messages, o, mode );
          }
        }
  <%
        elsif a.inverse.multiplicity == :one || a.inverse.multiplicity == :zero_or_one
  -%>
        {
          final <%= a.entity.jpa.qualified_name %> o = object.get<%= a.inverse.name %>();
          <% if a.inverse.multiplicity == :zero_or_one %>if( null != o )<% end %>
          {
            encode<%= a.entity.name %>( messages, o, mode );
          }
        }
  <%
        end
      end
  