<commit_before>/* DO NOT EDIT: File is auto-generated */
package <%= service.data_module.gwt_rpc.client_service_package %>;

@SuppressWarnings( { "UnusedDeclaration", "JavaDoc", "unchecked", "Convert2Diamond" } )
public class <%= service.gwt_rpc.proxy_name %>
  implements <%= service.gwt_rpc.facade_service_name %>
{
  @javax.inject.Inject
  private <%= service.gwt_rpc.qualified_async_rpc_service_name %> _service;
  @javax.inject.Named("GLOBAL")
  @javax.inject.Inject
  private com.google.gwt.user.client.rpc.AsyncCallback _callback;

<% if service.gwt_rpc.use_autobean_structs? %>
  @javax.inject.Inject
  private <%= service.data_module.repository.auto_bean.qualified_factory_name %> _factory;
<% end %>

<% service.methods.select{|method| method.gwt_rpc?}.each do |method|
   method_name = Domgen::Naming.camelize(method.name)
   parameters = method.parameters.select{|parameter| !parameter.gwt_rpc.environmental?}
%>
  public void <%= method_name %>(<%= parameters.collect{|p| "final #{annotated_type(p, :gwt_rpc, :boundary)} #{p.name}" }.join(', ') %>)
  {
    <%= method_name %>(<%= (parameters.collect{|p| p.name } + ["null"]).join(', ') %>);
  }
  public void <%= method_name %>(<%= (parameters.collect{|p| "final #{annotated_type(p, :gwt_rpc, :boundary)} #{p.name}" } + ["final @javax.annotation.Nullable #{service.data_module.repository.gwt_rpc.qualified_async_callback_name}<#{method.return_value.gwt_rpc.non_primitive_java_type(:boundary)}> callback"]).join(', ') %>)
  {
    <%= method_name %>(<%= (parameters.collect{|p| p.name } + ["callback","null"]).join(', ') %>);
  }

  public void <%= method_name %>(<%= (method.parameters.select{|parameter| !parameter.gwt_rpc.environmental?}.collect{|p| "final #{annotated_type(p, :gwt_rpc, :boundary)} #{p.name}" } + ["final @javax.annotation.Nullable #{service.data_module.repository.gwt_rpc.qualified_async_callback_name}<#{method.return_value.gwt_rpc.non_primitive_java_type(:boundary)}> callback","final @javax.annotation.Nullable #{service.data_module.repository.gwt_rpc.qualified_async_error_callback_name} errorCallback"]).join(', ') %>)
  {
  <% method.parameters.select{|parameter| (parameter.enumeration? || parameter.struct?) && parameter.collection?}.each do |parameter| %>
    final <%= annotated_type(parameter, :gwt_rpc, :transport) %> $<%= parameter.name %> = <%= parameter.nullable? ? "null == #{parameter.name} ? null : " : '' %>new java.util.<%=  parameter.collection_type == :set ? "HashSet" : "ArrayList" %><<%= parameter.gwt_rpc.java_component_type(:transport) %>>();
    <% if parameter.nullable? %>if( null != <%= parameter.name %> ) {<% end %>
    for( final <%= parameter.gwt_rpc.java_component_type %> entity: <%= parameter.name %> )
    {
    <%
       param_value =
       if parameter.enumeration?
         "entity.#{parameter.enumeration.numeric_values? ? "ordinal()" : "name()"}"
       else
         if parameter.method.service.gwt_rpc.use_autobean_structs?
         "com.google.web.bindery.autobean.shared.AutoBeanCodex.encode( com.google.web.bindery.autobean.shared.AutoBeanUtils.getAutoBean( entity ) ).getPayload()"
         else
         "#{parameter.referenced_struct.gwt.qualified_factory_name}.asJson( entity )"
         end
       end
    %>
    $<%= parameter.name %>.add( <%= param_value %> );
    }
    <% if parameter.nullable? %>}<% end %>
  <% end %>
<% if method.imit? %>
  final org.realityforge.replicant.client.transport.ClientSession session = org.realityforge.replicant.client.transport.SessionContext.getSession();
  final org.realityforge.replicant.client.transport.RequestEntry request;
  if( null != session )
  {
    request = session.getRequestManager().newRequestRegistration( <%= method.imit.bulk_load? %> );
    org.realityforge.replicant.client.transport.SessionContext.setRequest( request );
  }
  else
  {
    request = null;
  }
<% end %>
  _service.<%= method.gwt_rpc.name %>(<%= method.parameters.select{|parameter| !parameter.gwt_rpc.environmental?}.collect do |parameter|
  param_value = parameter.name
  if parameter.collection? && (parameter.enumeration? || parameter.struct?)
    param_value = "$#{parameter.name}"
  elsif parameter.enumeration? && parameter.enumeration.numeric_values?
    param_value = "#{parameter.name}.ordinal()"
  elsif parameter.enumeration? && parameter.enumeration.textual_values?
    param_value = "#{parameter.name}.name()"
  elsif parameter.struct?
    if parameter.method.service.gwt_rpc.use_autobean_structs?
    param_value = "com.google.web.bindery.autobean.shared.AutoBeanCodex.encode( com.google.web.bindery.autobean.shared.AutoBeanUtils.getAutoBean( #{parameter.name} ) ).getPayload()"
    else
    param_value = "#{parameter.referenced_struct.gwt.qualified_factory_name}.asJson( #{parameter.name} )"
    end
  end
  if parameter.nullable? && !parameter.collection?
    param_value = "null == #{parameter.name} ? null : #{param_value}"
  end
  param_value
end.join(', ') %><%= method.parameters.select{|parameter| !parameter.gwt_rpc.environmental?}.empty? ? '' : ', ' %>new com.google.gwt.user.client.rpc.AsyncCallback<<%= method.return_value.gwt_rpc.non_primitive_java_type(:transport) %>>()
    {
    public void onFailure( final Throwable caught )
    {
      final Runnable runnable = new Runnable()
      {
        @Override
        public void run()
        {
          if ( null != errorCallback )
          {
            errorCallback.onFailure( caught );
          }
          _callback.onFailure( caught );
        }
      };
<% if method.imit? %>
      if( null != request && request.isExpectingResults() && !request.haveResultsArrived() )
      {
        request.setNonNormalCompletionAction( runnable );
      }
      else
<% end %>
      {
        runnable.run();
<% if method.imit? %>
        if ( null != session )
        {
          session.getRequestManager().removeRequest( request.getRequestID() );
        }
<% end %>
      }
    }

    public void onSuccess( final <%= method.return_value.gwt_rpc.non_primitive_java_type(:transport) %> result )
    {
<%
   if !method.return_value.collection?
     result_string = "result"
     if method.return_value.enumeration? && method.return_value.enumeration.numeric_values?
       result_string = "#{method.return_value.gwt_rpc.java_type}.values()[ result ]"
     elsif method.return_value.enumeration? && method.return_value.enumeration.textual_values?
       result_string = "#{method.return_value.gwt_rpc.java_type}.valueOf( result )"
     elsif method.return_value.struct?
       if method.service.gwt_rpc.use_autobean_structs?
       result_string = "com.google.web.bindery.autobean.shared.AutoBeanCodex.decode( _factory, #{method.return_value.referenced_struct.auto_bean.qualified_name}.class, result ).as()"
       else
       result_string = "#{method.return_value.referenced_struct.gwt.qualified_factory_name}.as#{method.return_value.referenced_struct.name}( result )"
       end
     end
     if method.return_value.nullable?
       result_string = "null == result ? null : #{result_string}"
     end
   elsif method.return_value.enumeration? || method.return_value.struct?
     result_string = "$result"
   else
     result_string = "result"
   end
%>
  <% if method.return_value.collection? && (method.return_value.enumeration? || method.return_value.struct?) %>
    final <%= annotated_type(method.return_value, :gwt_rpc, :boundary) %> $result = <% if method.return_value.nullable? %>result == null ? null : <% end %>new java.util.<%=  method.return_value.collection_type == :set ? "HashSet" : "ArrayList" %><<%= method.return_value.gwt_rpc.java_component_type %>>();
    if ( null != result )
    {
      for( final <%= method.return_value.gwt_rpc.java_component_type(:transport) %> id: result )
      {
      <%
         param_value =
         if method.return_value.enumeration?
           method.return_value.enumeration.textual_values? ?
             "#{method.return_value.gwt_rpc.java_component_type}.valueOf( id )" :
             "#{method.return_value.gwt_rpc.java_component_type}.values()[ id ]"
         else
           if method.service.gwt_rpc.use_autobean_structs?
           "com.google.web.bindery.autobean.shared.AutoBeanCodex.decode( _factory, #{method.return_value.referenced_struct.auto_bean.qualified_name}.class, id ).as()"
           else
           "#{method.return_value.referenced_struct.gwt.qualified_factory_name}.as#{method.return_value.referenced_struct.name}( id )"
           end
         end
      %>
      $result.add( <%= param_value %> );
      }
    }
  <% end %>
      final Runnable runnable = new Runnable()
      {
        @Override
        public void run()
        {
          if ( null != callback )
          {
            callback.onSuccess( result );
          }
          _callback.onSuccess( result );
        }
      };
<% if method.imit? %>
      if ( null != request && request.isExpectingResults() && !request.haveResultsArrived() )
      {
        request.setNormalCompletionAction( runnable );
      }
      else
<% end %>
      {
        runnable.run();
<% if method.imit? %>
        if ( null != session )
        {
          session.getRequestManager().removeRequest( request.getRequestID() );
        }
<% end %><commit_msg>Pass the correct return type for structures<commit_after>/* DO NOT EDIT: File is auto-generated */
package <%= service.data_module.gwt_rpc.client_service_package %>;

@SuppressWarnings( { "UnusedDeclaration", "JavaDoc", "unchecked", "Convert2Diamond" } )
public class <%= service.gwt_rpc.proxy_name %>
  implements <%= service.gwt_rpc.facade_service_name %>
{
  @javax.inject.Inject
  private <%= service.gwt_rpc.qualified_async_rpc_service_name %> _service;
  @javax.inject.Named("GLOBAL")
  @javax.inject.Inject
  private com.google.gwt.user.client.rpc.AsyncCallback _callback;

<% if service.gwt_rpc.use_autobean_structs? %>
  @javax.inject.Inject
  private <%= service.data_module.repository.auto_bean.qualified_factory_name %> _factory;
<% end %>

<% service.methods.select{|method| method.gwt_rpc?}.each do |method|
   method_name = Domgen::Naming.camelize(method.name)
   parameters = method.parameters.select{|parameter| !parameter.gwt_rpc.environmental?}
%>
  public void <%= method_name %>(<%= parameters.collect{|p| "final #{annotated_type(p, :gwt_rpc, :boundary)} #{p.name}" }.join(', ') %>)
  {
    <%= method_name %>(<%= (parameters.collect{|p| p.name } + ["null"]).join(', ') %>);
  }
  public void <%= method_name %>(<%= (parameters.collect{|p| "final #{annotated_type(p, :gwt_rpc, :boundary)} #{p.name}" } + ["final @javax.annotation.Nullable #{service.data_module.repository.gwt_rpc.qualified_async_callback_name}<#{method.return_value.gwt_rpc.non_primitive_java_type(:boundary)}> callback"]).join(', ') %>)
  {
    <%= method_name %>(<%= (parameters.collect{|p| p.name } + ["callback","null"]).join(', ') %>);
  }

  public void <%= method_name %>(<%= (method.parameters.select{|parameter| !parameter.gwt_rpc.environmental?}.collect{|p| "final #{annotated_type(p, :gwt_rpc, :boundary)} #{p.name}" } + ["final @javax.annotation.Nullable #{service.data_module.repository.gwt_rpc.qualified_async_callback_name}<#{method.return_value.gwt_rpc.non_primitive_java_type(:boundary)}> callback","final @javax.annotation.Nullable #{service.data_module.repository.gwt_rpc.qualified_async_error_callback_name} errorCallback"]).join(', ') %>)
  {
  <% method.parameters.select{|parameter| (parameter.enumeration? || parameter.struct?) && parameter.collection?}.each do |parameter| %>
    final <%= annotated_type(parameter, :gwt_rpc, :transport) %> $<%= parameter.name %> = <%= parameter.nullable? ? "null == #{parameter.name} ? null : " : '' %>new java.util.<%=  parameter.collection_type == :set ? "HashSet" : "ArrayList" %><<%= parameter.gwt_rpc.java_component_type(:transport) %>>();
    <% if parameter.nullable? %>if( null != <%= parameter.name %> ) {<% end %>
    for( final <%= parameter.gwt_rpc.java_component_type %> entity: <%= parameter.name %> )
    {
    <%
       param_value =
       if parameter.enumeration?
         "entity.#{parameter.enumeration.numeric_values? ? "ordinal()" : "name()"}"
       else
         if parameter.method.service.gwt_rpc.use_autobean_structs?
         "com.google.web.bindery.autobean.shared.AutoBeanCodex.encode( com.google.web.bindery.autobean.shared.AutoBeanUtils.getAutoBean( entity ) ).getPayload()"
         else
         "#{parameter.referenced_struct.gwt.qualified_factory_name}.asJson( entity )"
         end
       end
    %>
    $<%= parameter.name %>.add( <%= param_value %> );
    }
    <% if parameter.nullable? %>}<% end %>
  <% end %>
<% if method.imit? %>
  final org.realityforge.replicant.client.transport.ClientSession session = org.realityforge.replicant.client.transport.SessionContext.getSession();
  final org.realityforge.replicant.client.transport.RequestEntry request;
  if( null != session )
  {
    request = session.getRequestManager().newRequestRegistration( <%= method.imit.bulk_load? %> );
    org.realityforge.replicant.client.transport.SessionContext.setRequest( request );
  }
  else
  {
    request = null;
  }
<% end %>
  _service.<%= method.gwt_rpc.name %>(<%= method.parameters.select{|parameter| !parameter.gwt_rpc.environmental?}.collect do |parameter|
  param_value = parameter.name
  if parameter.collection? && (parameter.enumeration? || parameter.struct?)
    param_value = "$#{parameter.name}"
  elsif parameter.enumeration? && parameter.enumeration.numeric_values?
    param_value = "#{parameter.name}.ordinal()"
  elsif parameter.enumeration? && parameter.enumeration.textual_values?
    param_value = "#{parameter.name}.name()"
  elsif parameter.struct?
    if parameter.method.service.gwt_rpc.use_autobean_structs?
    param_value = "com.google.web.bindery.autobean.shared.AutoBeanCodex.encode( com.google.web.bindery.autobean.shared.AutoBeanUtils.getAutoBean( #{parameter.name} ) ).getPayload()"
    else
    param_value = "#{parameter.referenced_struct.gwt.qualified_factory_name}.asJson( #{parameter.name} )"
    end
  end
  if parameter.nullable? && !parameter.collection?
    param_value = "null == #{parameter.name} ? null : #{param_value}"
  end
  param_value
end.join(', ') %><%= method.parameters.select{|parameter| !parameter.gwt_rpc.environmental?}.empty? ? '' : ', ' %>new com.google.gwt.user.client.rpc.AsyncCallback<<%= method.return_value.gwt_rpc.non_primitive_java_type(:transport) %>>()
    {
    public void onFailure( final Throwable caught )
    {
      final Runnable runnable = new Runnable()
      {
        @Override
        public void run()
        {
          if ( null != errorCallback )
          {
            errorCallback.onFailure( caught );
          }
          _callback.onFailure( caught );
        }
      };
<% if method.imit? %>
      if( null != request && request.isExpectingResults() && !request.haveResultsArrived() )
      {
        request.setNonNormalCompletionAction( runnable );
      }
      else
<% end %>
      {
        runnable.run();
<% if method.imit? %>
        if ( null != session )
        {
          session.getRequestManager().removeRequest( request.getRequestID() );
        }
<% end %>
      }
    }

    public void onSuccess( final <%= method.return_value.gwt_rpc.non_primitive_java_type(:transport) %> result )
    {
<%
   if !method.return_value.collection?
     result_string = "result"
     if method.return_value.enumeration? && method.return_value.enumeration.numeric_values?
       result_string = "#{method.return_value.gwt_rpc.java_type}.values()[ result ]"
     elsif method.return_value.enumeration? && method.return_value.enumeration.textual_values?
       result_string = "#{method.return_value.gwt_rpc.java_type}.valueOf( result )"
     elsif method.return_value.struct?
       if method.service.gwt_rpc.use_autobean_structs?
       result_string = "com.google.web.bindery.autobean.shared.AutoBeanCodex.decode( _factory, #{method.return_value.referenced_struct.auto_bean.qualified_name}.class, result ).as()"
       else
       result_string = "#{method.return_value.referenced_struct.gwt.qualified_factory_name}.as#{method.return_value.referenced_struct.name}( result )"
       end
     end
     if method.return_value.nullable?
       result_string = "null == result ? null : #{result_string}"
     end
   elsif method.return_value.enumeration? || method.return_value.struct?
     result_string = "$result"
   else
     result_string = "result"
   end
%>
  <% if method.return_value.collection? && (method.return_value.enumeration? || method.return_value.struct?) %>
    final <%= annotated_type(method.return_value, :gwt_rpc, :boundary) %> $result = <% if method.return_value.nullable? %>result == null ? null : <% end %>new java.util.<%=  method.return_value.collection_type == :set ? "HashSet" : "ArrayList" %><<%= method.return_value.gwt_rpc.java_component_type %>>();
    if ( null != result )
    {
      for( final <%= method.return_value.gwt_rpc.java_component_type(:transport) %> id: result )
      {
      <%
         param_value =
         if method.return_value.enumeration?
           method.return_value.enumeration.textual_values? ?
             "#{method.return_value.gwt_rpc.java_component_type}.valueOf( id )" :
             "#{method.return_value.gwt_rpc.java_component_type}.values()[ id ]"
         else
           if method.service.gwt_rpc.use_autobean_structs?
           "com.google.web.bindery.autobean.shared.AutoBeanCodex.decode( _factory, #{method.return_value.referenced_struct.auto_bean.qualified_name}.class, id ).as()"
           else
           "#{method.return_value.referenced_struct.gwt.qualified_factory_name}.as#{method.return_value.referenced_struct.name}( id )"
           end
         end
      %>
      $result.add( <%= param_value %> );
      }
    }
  <% end %>
      final Runnable runnable = new Runnable()
      {
        @Override
        public void run()
        {
          if ( null != callback )
          {
            callback.onSuccess( <%= result_string %> );
          }
          _callback.onSuccess( result );
        }
      };
<% if method.imit? %>
      if ( null != request && request.isExpectingResults() && !request.haveResultsArrived() )
      {
        request.setNormalCompletionAction( runnable );
      }
      else
<% end %>
      {
        runnable.run();
<% if method.imit? %>
        if ( null != session )
        {
          session.getRequestManager().removeRequest( request.getRequestID() );
        }
<% end %>
{'fraction_non_alphanumeric': 0.15481465470658165, 'fraction_numerical': 0.00010807305738679347, 'mean_word_length': 3.5888916439375156, 'pattern_counts': {'":': 0, '<': 138, '<?xml version=': 0, '>': 138, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4430304', 'n_tokens_mistral': 6119, 'n_tokens_neox': 5790, 'n_words': 832}