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

@SuppressWarnings( { "UnusedDeclaration", "JavaDoc", "unchecked" } )
public class <%= service.imit.proxy_name %>
  implements <%= service.imit.name %>
{
  @javax.inject.Inject
  private <%= service.gwt.qualified_async_service_name %> _service;
  @javax.inject.Inject
  private org.realityforge.replicant.client.EntityRepository _repository;
  @javax.inject.Named("GLOBAL")
  @javax.inject.Inject
  private com.google.gwt.user.client.rpc.AsyncCallback _callback;

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

  public void <%= method_name %>(<%= (method.parameters.select{|parameter| !parameter.imit.environmental?}.collect{|p| "final #{annotated_type(p, :imit)} #{p.name}" } + ["final @javax.annotation.Nullable org.realityforge.replicant.client.AsyncCallback<#{method.return_value.imit.non_primitive_java_type}> callback","final @javax.annotation.Nullable org.realityforge.replicant.client.AsyncErrorCallback errorCallback"]).join(', ') %>)
  {
  <% method.parameters.select{|parameter| (parameter.reference? || parameter.enumeration? || parameter.struct?) && parameter.collection?}.each do |parameter| %>
    final <%= annotated_type(parameter, :gwt, :transport) %> $<%= parameter.name %> = <%= parameter.nullable? ? "null == #{parameter.name} ? null : " : '' %>new java.util.<%=  parameter.collection_type == :set ? "HashSet" : "ArrayList" %><<%= parameter.gwt.java_component_type(:transport) %>>();
    <% if parameter.nullable? %>if( null != <%= parameter.name %> ) {<% end %>
    for( final <%= parameter.imit.java_component_type %> entity: <%= parameter.name %> )
    {
    <%
       param_value =
       if parameter.reference?
         "entity.get#{parameter.referenced_entity.primary_key.imit.name}()"
       elsif parameter.enumeration?
         "entity.#{parameter.enumeration.numeric_values? ? "ordinal()" : "name()"}"
       else
         "#{parameter.struct.imit.qualified_factory_name}.asJson( #{parameter.name} )"
       end
    %>
    $<%= parameter.name %>.add( <%= param_value %> );
    }
    <% if parameter.nullable? %>}<% end %>
  <% end %>
  _service.<%= method.gwt.name %>(<%= method.parameters.select{|parameter| !parameter.imit.environmental?}.collect do |parameter|
  param_value = parameter.name
  if parameter.collection? && (parameter.enumeration? || parameter.reference? || 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?
    param_value = "#{parameter.struct.imit.qualified_factory_name}.asJson( #{parameter.name} )"
  elsif parameter.reference?
    param_value = "#{parameter.name}.get#{parameter.referenced_entity.primary_key.imit.name}()"
  end
  if parameter.nullable? && !parameter.collection?
    param_value = "null == #{parameter.name} ? null : #{param_value}"
  end
  param_value
end.join(', ') %><%= method.parameters.select{|parameter| !parameter.imit.environmental?}.empty? ? '' : ', ' %>new com.google.gwt.user.client.rpc.AsyncCallback<<%= method.return_value.imit.non_primitive_java_type(:transport) %>>()
    {
    public void onFailure( final Throwable caught )
    {
      if( null != errorCallback ) errorCallback.onFailure( caught );
      _callback.onFailure( caught );
    }

    public void onSuccess( final <%= method.return_value.imit.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.imit.java_type}.values()[ result ]"
     elsif method.return_value.enumeration? && method.return_value.enumeration.textual_values?
       result_string = "#{method.return_value.imit.java_type}.valueOf( result )"
     elsif method.return_value.reference?
       result_string = "_repository.getByID( #{method.return_value.referenced_entity.imit.qualified_name}.class, result )"
     elsif method.return_value.struct?
       result_string = "#{method.return_value.struct.imit.qualified_factory_name}.as#{method.return_value.struct.imit.name}( result )"
     end
     if method.return_value.nullable?
       result_string = "null == result ? null : #{result_string}"
     end
   elsif method.return_value.enumeration? || method.return_value.reference? || 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? || method.return_value.reference?) %>
    final <%= annotated_type(method.return_value, :imit) %> $result = new java.util.<%=  method.return_value.collection_type == :set ? "HashSet" : "ArrayList" %><<%= method.return_value.imit.java_component_type %>>();
    for( final <%= method.return_value.gwt.java_component_type(:transport) %> id: result )
    {
    <%
       param_value =
       if method.return_value.reference?
         "_repository.getByID( #{method.return_value.referenced_entity.imit.qualified_name}.class, id )"
       elsif method.return_value.enumeration?
         method.return_value.enumeration.textual_values? ?
           "#{method.return_value.imit.java_component_type}.valueOf( id )" :
           "#{method.return_value.imit.java_component_type}.values()[ id ]"
       else
         "#{method.return_value.struct.imit.qualified_factory_name}.as#{method.return_value.struct.imit.name}( id )"
       end
    %>
    $result.add( <%= param_value %> );
    }
  <% end %>
      if( null != callback ) callback.onSuccess( <%= result_string %> );
      _callback.onSuccess( result );
    }
  });
  }

<% end %>}
<commit_msg>Fix the way collection structs are deserialized<commit_after>/* DO NOT EDIT: File is auto-generated */
package <%= service.data_module.imit.service_package %>;

@SuppressWarnings( { "UnusedDeclaration", "JavaDoc", "unchecked" } )
public class <%= service.imit.proxy_name %>
  implements <%= service.imit.name %>
{
  @javax.inject.Inject
  private <%= service.gwt.qualified_async_service_name %> _service;
  @javax.inject.Inject
  private org.realityforge.replicant.client.EntityRepository _repository;
  @javax.inject.Named("GLOBAL")
  @javax.inject.Inject
  private com.google.gwt.user.client.rpc.AsyncCallback _callback;

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

  public void <%= method_name %>(<%= (method.parameters.select{|parameter| !parameter.imit.environmental?}.collect{|p| "final #{annotated_type(p, :imit)} #{p.name}" } + ["final @javax.annotation.Nullable org.realityforge.replicant.client.AsyncCallback<#{method.return_value.imit.non_primitive_java_type}> callback","final @javax.annotation.Nullable org.realityforge.replicant.client.AsyncErrorCallback errorCallback"]).join(', ') %>)
  {
  <% method.parameters.select{|parameter| (parameter.reference? || parameter.enumeration? || parameter.struct?) && parameter.collection?}.each do |parameter| %>
    final <%= annotated_type(parameter, :gwt, :transport) %> $<%= parameter.name %> = <%= parameter.nullable? ? "null == #{parameter.name} ? null : " : '' %>new java.util.<%=  parameter.collection_type == :set ? "HashSet" : "ArrayList" %><<%= parameter.gwt.java_component_type(:transport) %>>();
    <% if parameter.nullable? %>if( null != <%= parameter.name %> ) {<% end %>
    for( final <%= parameter.imit.java_component_type %> entity: <%= parameter.name %> )
    {
    <%
       param_value =
       if parameter.reference?
         "entity.get#{parameter.referenced_entity.primary_key.imit.name}()"
       elsif parameter.enumeration?
         "entity.#{parameter.enumeration.numeric_values? ? "ordinal()" : "name()"}"
       else
         "#{parameter.struct.imit.qualified_factory_name}.asJson( entity )"
       end
    %>
    $<%= parameter.name %>.add( <%= param_value %> );
    }
    <% if parameter.nullable? %>}<% end %>
  <% end %>
  _service.<%= method.gwt.name %>(<%= method.parameters.select{|parameter| !parameter.imit.environmental?}.collect do |parameter|
  param_value = parameter.name
  if parameter.collection? && (parameter.enumeration? || parameter.reference? || 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?
    param_value = "#{parameter.struct.imit.qualified_factory_name}.asJson( #{parameter.name} )"
  elsif parameter.reference?
    param_value = "#{parameter.name}.get#{parameter.referenced_entity.primary_key.imit.name}()"
  end
  if parameter.nullable? && !parameter.collection?
    param_value = "null == #{parameter.name} ? null : #{param_value}"
  end
  param_value
end.join(', ') %><%= method.parameters.select{|parameter| !parameter.imit.environmental?}.empty? ? '' : ', ' %>new com.google.gwt.user.client.rpc.AsyncCallback<<%= method.return_value.imit.non_primitive_java_type(:transport) %>>()
    {
    public void onFailure( final Throwable caught )
    {
      if( null != errorCallback ) errorCallback.onFailure( caught );
      _callback.onFailure( caught );
    }

    public void onSuccess( final <%= method.return_value.imit.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.imit.java_type}.values()[ result ]"
     elsif method.return_value.enumeration? && method.return_value.enumeration.textual_values?
       result_string = "#{method.return_value.imit.java_type}.valueOf( result )"
     elsif method.return_value.reference?
       result_string = "_repository.getByID( #{method.return_value.referenced_entity.imit.qualified_name}.class, result )"
     elsif method.return_value.struct?
       result_string = "#{method.return_value.struct.imit.qualified_factory_name}.as#{method.return_value.struct.imit.name}( result )"
     end
     if method.return_value.nullable?
       result_string = "null == result ? null : #{result_string}"
     end
   elsif method.return_value.enumeration? || method.return_value.reference? || 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? || method.return_value.reference?) %>
    final <%= annotated_type(method.return_value, :imit) %> $result = new java.util.<%=  method.return_value.collection_type == :set ? "HashSet" : "ArrayList" %><<%= method.return_value.imit.java_component_type %>>();
    for( final <%= method.return_value.gwt.java_component_type(:transport) %> id: result )
    {
    <%
       param_value =
       if method.return_value.reference?
         "_repository.getByID( #{method.return_value.referenced_entity.imit.qualified_name}.class, id )"
       elsif method.return_value.enumeration?
         method.return_value.enumeration.textual_values? ?
           "#{method.return_value.imit.java_component_type}.valueOf( id )" :
           "#{method.return_value.imit.java_component_type}.values()[ id ]"
       else
         "#{method.return_value.struct.imit.qualified_factory_name}.as#{method.return_value.struct.imit.name}( id )"
       end
    %>
    $result.add( <%= param_value %> );
    }
  <% end %>
      if( null != callback ) callback.onSuccess( <%= result_string %> );
      _callback.onSuccess( result );
    }
  });
  }

<% end %>}

{'fraction_non_alphanumeric': 0.1690580625975764, 'fraction_numerical': 0.0, 'mean_word_length': 4.333862014274385, 'pattern_counts': {'":': 0, '<': 109, '<?xml version=': 0, '>': 109, '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': '3728385', 'n_tokens_mistral': 4392, 'n_tokens_neox': 4147, 'n_words': 614}