<commit_before>/* DO NOT EDIT: File is auto-generated */
package <%= to_package(entity.arez.qualified_name) %>;

@javax.annotation.Generated( "Domgen" )
@edu.umd.cs.findbugs.annotations.SuppressFBWarnings({"EI_EXPOSE_REP", "EI_EXPOSE_REP2"})
@java.lang.SuppressWarnings( { "UnusedDeclaration", "JavaDoc", "PMD.IfStmtsMustUseBraces" } )
<% unless entity.abstract? -%>
@org.realityforge.arez.annotations.ArezComponent( allowEmpty = true )
<% end -%>
public <%= entity.abstract? ? 'abstract ' :'' %>class <%= entity.arez.name %>
<%= entity.extends ? "    extends #{entity.data_module.entity_by_name(entity.extends).arez.qualified_name}\n" : '' -%>
<%= (!entity.extends || entity.arez.interfaces.size > 0) ? '  implements ' : '' -%><%= ((entity.extends ? [] : %w(org.realityforge.replicant.client.Linkable org.realityforge.replicant.client.Verifiable)) + entity.arez.interfaces).join(", ") %>
{
<% entity.declared_attributes.select { |a| !a.abstract? && a.arez? && a.text? && a.has_non_max_length? }.each do |attribute| -%>
  public static final int <%= Reality::Naming.uppercase_constantize(attribute.name) -%>_MAX_SIZE = <%= attribute.length -%>;
<% end -%>
<%= entity.extends.nil? ? "  protected org.realityforge.replicant.client.EntityRepository _repository;\n" : ''
%><% entity.declared_attributes.select{ |attribute| !attribute.abstract? && attribute.arez? }.each do |attribute|
  if attribute.reference? || attribute.remote_reference? -%>
  private <%= attribute.arez.java_type %> _<%= Reality::Naming.camelize(attribute.arez.name) %>;
  private <%= "#{nullability_annotation(true)} #{attribute.arez.java_type(:transport)}" %> _<%= Reality::Naming.camelize(attribute.arez.name(:transport)) %>;
<% else -%>
  <%= annotated_type(attribute, :arez, :default, :assume_generated => true, :private => true) %> _<%= Reality::Naming.camelize(attribute.arez.name) %>;
<%
   end
   end
-%>
<% entity.arez.referencing_client_side_attributes.each do |attribute|
    if attribute.inverse.multiplicity == :many -%>
  private java.util.List<<%= attribute.entity.arez.qualified_name %>> <%= Reality::Naming.camelize(Reality::Naming.pluralize(attribute.inverse.name)) %>;
<% else # attribute.inverse.multiplicity == :one || attribute.inverse.multiplicity == :zero_or_one -%>
  private <%= attribute.entity.arez.qualified_name %> <%= Reality::Naming.camelize(attribute.inverse.name) %>;
<%
    end
  end
  -%>
<% if entity.extends.nil? -%>
  private boolean _$linking;
  private boolean _$delinking;
  private boolean _$linked;
<% end -%>

  protected <%= entity.arez.name %>( @javax.annotation.Nonnull final org.realityforge.replicant.client.EntityRepository repository, <%= entity.attributes.select{|attribute| !attribute.abstract? && attribute.arez?}.collect { |attribute| "#{annotated_type(attribute, :arez, :transport, :final => true, :assume_generated => true)} #{Reality::Naming.camelize(attribute.arez.name(:transport))}"}.join(', ') %>)
  {
<% if entity.extends.nil? -%>
    _repository = java.util.Objects.requireNonNull( repository );
<% else -%>
    super( repository, <%= entity.data_module.entity_by_name(entity.extends).attributes.select{|attribute| !attribute.abstract? && attribute.arez?}.collect {|attribute| Reality::Naming.camelize(attribute.arez.name(:transport))}.join(', ') %> );
<% end -%>
<% entity.declared_attributes.select{|attribute| !attribute.abstract? && attribute.arez?}.each do |attribute|
  nullability_prefix = (supports_nullable?(attribute.arez, :default, :assume_generated => true)) ? "java.util.Objects.requireNonNull" : ''
  value = Reality::Naming.camelize(attribute.arez.name(:transport))
  if attribute.enumeration?
    cvalue = "#{attribute.arez.java_type}.#{attribute.enumeration.textual_values? ? "valueOf( #{value} )" : "values()[#{value}]"}"
    value = attribute.nullable? ? "null == #{value} ? null : #{cvalue}" : cvalue
  end
-%>
    _<%= Reality::Naming.camelize(attribute.arez.name(:transport)) %> = <%= nullability_prefix %>( <%= value %> );
<% end -%>
  }
<% if entity.extends.nil? -%>

  @org.realityforge.arez.annotations.ComponentId
  <%= annotated_type(entity.primary_key, :arez, :default, :final => true, :public => true, :assume_generated => true) %> <%= getter_prefix(entity.primary_key) %><%= entity.primary_key.arez.name %>()
  {
    return _<%= Reality::Naming.camelize(entity.primary_key.arez.name) %>;
  }
<% end -%>

<% entity.declared_attributes.select{|attribute| attribute.abstract? && attribute.arez? }.each do |attribute|
%>  <%= annotated_type(attribute, :arez, :default, :public => true, :abstract => true) %> <%= getter_prefix(attribute) %><%= attribute.arez.name %>();
<% if attribute.attribute_type == :reference
  %>  abstract <%= attribute.arez.java_type(:transport) %> <%= getter_prefix(attribute) %><%= attribute.arez.name(:transport) %>();
<% end %>
<% unless attribute.immutable? -%>
    abstract void set<%= attribute.arez.name(:transport) %>( <%= attribute.arez.java_type(:transport) %> value );
<% end %>
<% end %>
<% entity.declared_attributes.select{|attribute| !attribute.primary_key? && !attribute.abstract? && attribute.arez?}.each do |attribute| -%>
<% if !attribute.immutable? && !attribute.reference? && !attribute.remote_reference? -%>
  @org.realityforge.arez.annotations.Observable
<% end -%>
  <%= annotated_type(attribute, :arez, :default, :public => true) %> <%= getter_prefix(attribute) %><%= attribute.arez.name %>()
  {
    check<%= attribute.reference? || attribute.remote_reference? ? 'Linked' : 'Validity' %>();
<% if attribute.arez.lazy? -%>
    link<%= attribute.arez.name %>();
<% end -%>
    return _<%= Reality::Naming.camelize(attribute.arez.name) %>;
  }
<% if attribute.attribute_type == :reference %>

  protected final <%= attribute.arez.java_type(:transport) %> <%= getter_prefix(attribute) %><%= attribute.arez.name(:transport) %>()
  {
    return _<%= Reality::Naming.camelize(attribute.referencing_link_name) %>;
  }
<% end -%>
<% if attribute.attribute_type == :remote_reference -%>

  public final <%= attribute.arez.java_type(:transport) %> <%= getter_prefix(attribute) %><%= attribute.arez.name(:transport) %>()
  {
    return _<%= Reality::Naming.camelize(attribute.referencing_link_name) %>;
  }
<% if attribute.arez.lazy? -%>

  public final boolean will<%= attribute.arez.name %>Link()
  {
    return <%= attribute.nullable? ? "null == _#{Reality::Naming.camelize(attribute.referencing_link_name)} ? true : " : '' %> null != _repository.findByID( <%= attribute.referenced_remote_entity.arez.qualified_name %>.class, _<%= Reality::Naming.camelize(attribute.referencing_link_name) %> );
  }

  public final boolean is<%= attribute.arez.name %>Linked()
  {
    return <%= attribute.nullable? ? "null == _#{Reality::Naming.camelize(attribute.referencing_link_name)} ? true : " : '' %> null != _<%= Reality::Naming.camelize(attribute.arez.name) %>;
  }
<% end -%>
<% end -%>
<% unless attribute.immutable? -%>

  void set<%= attribute.arez.name(:transport) %>( <%= annotated_type(attribute, :arez, :transport, :final => true) %> value )
  {
<% if attribute.reference? || attribute.remote_reference? -%>
    _<%= Reality::Naming.camelize(attribute.arez.name) %> = null;
    _<%= Reality::Naming.camelize(attribute.referencing_link_name) %> = value;
<% elsif attribute.date? -%>
    _<%= Reality::Naming.camelize(attribute.arez.name) %> = <%= attribute.nullable? ? 'null == value ? null : ' : '' %>org.realityforge.gwt.datatypes.client.date.RDate.parse( value );
<% elsif attribute.enumeration? -%>
<% if !attribute.arez.primitive?(:transport) -%>
    if( null != value )
    {
<% end -%>
    _<%= Reality::Naming.camelize(attribute.arez.name) %> = <%= attribute.arez.java_type %>.<%= attribute.enumeration.textual_values? ? 'valueOf( value )' : 'values()[value]' %>;
<% if !attribute.arez.primitive?(:transport) -%>
    }
    else
    {
      _<%= Reality::Naming.camelize(attribute.arez.name) %> = null;
    }
<% end %>
<% else -%>
    _<%= Reality::Naming.camelize(attribute.arez.name) %> = value;
<% end %>  }
<% end %>
<% end %>
<% entity.arez.referencing_client_side_attributes.each do |attribute|
        name = attribute.inverse.name
        type = attribute.entity.arez.qualified_name
        if attribute.inverse.multiplicity == :many
          plural_name = Reality::Naming.pluralize(name)<commit_msg>Add nullability checks around attribute assignment if required<commit_after>/* DO NOT EDIT: File is auto-generated */
package <%= to_package(entity.arez.qualified_name) %>;

@javax.annotation.Generated( "Domgen" )
@edu.umd.cs.findbugs.annotations.SuppressFBWarnings({"EI_EXPOSE_REP", "EI_EXPOSE_REP2"})
@java.lang.SuppressWarnings( { "UnusedDeclaration", "JavaDoc", "PMD.IfStmtsMustUseBraces" } )
<% unless entity.abstract? -%>
@org.realityforge.arez.annotations.ArezComponent( allowEmpty = true )
<% end -%>
public <%= entity.abstract? ? 'abstract ' :'' %>class <%= entity.arez.name %>
<%= entity.extends ? "    extends #{entity.data_module.entity_by_name(entity.extends).arez.qualified_name}\n" : '' -%>
<%= (!entity.extends || entity.arez.interfaces.size > 0) ? '  implements ' : '' -%><%= ((entity.extends ? [] : %w(org.realityforge.replicant.client.Linkable org.realityforge.replicant.client.Verifiable)) + entity.arez.interfaces).join(", ") %>
{
<% entity.declared_attributes.select { |a| !a.abstract? && a.arez? && a.text? && a.has_non_max_length? }.each do |attribute| -%>
  public static final int <%= Reality::Naming.uppercase_constantize(attribute.name) -%>_MAX_SIZE = <%= attribute.length -%>;
<% end -%>
<%= entity.extends.nil? ? "  protected org.realityforge.replicant.client.EntityRepository _repository;\n" : ''
%><% entity.declared_attributes.select{ |attribute| !attribute.abstract? && attribute.arez? }.each do |attribute|
  if attribute.reference? || attribute.remote_reference? -%>
  private <%= attribute.arez.java_type %> _<%= Reality::Naming.camelize(attribute.arez.name) %>;
  private <%= "#{nullability_annotation(true)} #{attribute.arez.java_type(:transport)}" %> _<%= Reality::Naming.camelize(attribute.arez.name(:transport)) %>;
<% else -%>
  <%= annotated_type(attribute, :arez, :default, :assume_generated => true, :private => true) %> _<%= Reality::Naming.camelize(attribute.arez.name) %>;
<%
   end
   end
-%>
<% entity.arez.referencing_client_side_attributes.each do |attribute|
    if attribute.inverse.multiplicity == :many -%>
  private java.util.List<<%= attribute.entity.arez.qualified_name %>> <%= Reality::Naming.camelize(Reality::Naming.pluralize(attribute.inverse.name)) %>;
<% else # attribute.inverse.multiplicity == :one || attribute.inverse.multiplicity == :zero_or_one -%>
  private <%= attribute.entity.arez.qualified_name %> <%= Reality::Naming.camelize(attribute.inverse.name) %>;
<%
    end
  end
  -%>
<% if entity.extends.nil? -%>
  private boolean _$linking;
  private boolean _$delinking;
  private boolean _$linked;
<% end -%>

  protected <%= entity.arez.name %>( @javax.annotation.Nonnull final org.realityforge.replicant.client.EntityRepository repository, <%= entity.attributes.select{|attribute| !attribute.abstract? && attribute.arez?}.collect { |attribute| "#{annotated_type(attribute, :arez, :transport, :final => true, :assume_generated => true)} #{Reality::Naming.camelize(attribute.arez.name(:transport))}"}.join(', ') %>)
  {
<% if entity.extends.nil? -%>
    _repository = java.util.Objects.requireNonNull( repository );
<% else -%>
    super( repository, <%= entity.data_module.entity_by_name(entity.extends).attributes.select{|attribute| !attribute.abstract? && attribute.arez?}.collect {|attribute| Reality::Naming.camelize(attribute.arez.name(:transport))}.join(', ') %> );
<% end -%>
<% entity.declared_attributes.select{|attribute| !attribute.abstract? && attribute.arez?}.each do |attribute|
  nullability_prefix = (supports_nullable?(attribute.arez, :default, :assume_generated => true)) ? "java.util.Objects.requireNonNull" : ''
  value = Reality::Naming.camelize(attribute.arez.name(:transport))
  if attribute.enumeration?
    cvalue = "#{attribute.arez.java_type}.#{attribute.enumeration.textual_values? ? "valueOf( #{value} )" : "values()[#{value}]"}"
    value = attribute.nullable? ? "null == #{value} ? null : #{cvalue}" : cvalue
  end
-%>
    _<%= Reality::Naming.camelize(attribute.arez.name(:transport)) %> = <%= nullability_prefix %>( <%= value %> );
<% end -%>
  }
<% if entity.extends.nil? -%>

  @org.realityforge.arez.annotations.ComponentId
  <%= annotated_type(entity.primary_key, :arez, :default, :final => true, :public => true, :assume_generated => true) %> <%= getter_prefix(entity.primary_key) %><%= entity.primary_key.arez.name %>()
  {
    return _<%= Reality::Naming.camelize(entity.primary_key.arez.name) %>;
  }
<% end -%>

<% entity.declared_attributes.select{|attribute| attribute.abstract? && attribute.arez? }.each do |attribute|
%>  <%= annotated_type(attribute, :arez, :default, :public => true, :abstract => true) %> <%= getter_prefix(attribute) %><%= attribute.arez.name %>();
<% if attribute.attribute_type == :reference
  %>  abstract <%= attribute.arez.java_type(:transport) %> <%= getter_prefix(attribute) %><%= attribute.arez.name(:transport) %>();
<% end %>
<% unless attribute.immutable? -%>
    abstract void set<%= attribute.arez.name(:transport) %>( <%= attribute.arez.java_type(:transport) %> value );
<% end %>
<% end %>
<% entity.declared_attributes.select{|attribute| !attribute.primary_key? && !attribute.abstract? && attribute.arez?}.each do |attribute| -%>
<% if !attribute.immutable? && !attribute.reference? && !attribute.remote_reference? -%>
  @org.realityforge.arez.annotations.Observable
<% end -%>
  <%= annotated_type(attribute, :arez, :default, :public => true) %> <%= getter_prefix(attribute) %><%= attribute.arez.name %>()
  {
    check<%= attribute.reference? || attribute.remote_reference? ? 'Linked' : 'Validity' %>();
<% if attribute.arez.lazy? -%>
    link<%= attribute.arez.name %>();
<% end -%>
    return _<%= Reality::Naming.camelize(attribute.arez.name) %>;
  }
<% if attribute.attribute_type == :reference %>

  protected final <%= attribute.arez.java_type(:transport) %> <%= getter_prefix(attribute) %><%= attribute.arez.name(:transport) %>()
  {
    return _<%= Reality::Naming.camelize(attribute.referencing_link_name) %>;
  }
<% end -%>
<% if attribute.attribute_type == :remote_reference -%>

  public final <%= attribute.arez.java_type(:transport) %> <%= getter_prefix(attribute) %><%= attribute.arez.name(:transport) %>()
  {
    return _<%= Reality::Naming.camelize(attribute.referencing_link_name) %>;
  }
<% if attribute.arez.lazy? -%>

  public final boolean will<%= attribute.arez.name %>Link()
  {
    return <%= attribute.nullable? ? "null == _#{Reality::Naming.camelize(attribute.referencing_link_name)} ? true : " : '' %> null != _repository.findByID( <%= attribute.referenced_remote_entity.arez.qualified_name %>.class, _<%= Reality::Naming.camelize(attribute.referencing_link_name) %> );
  }

  public final boolean is<%= attribute.arez.name %>Linked()
  {
    return <%= attribute.nullable? ? "null == _#{Reality::Naming.camelize(attribute.referencing_link_name)} ? true : " : '' %> null != _<%= Reality::Naming.camelize(attribute.arez.name) %>;
  }
<% end -%>
<% end -%>
<% unless attribute.immutable? -%>

  void set<%= attribute.arez.name(:transport) %>( <%= annotated_type(attribute, :arez, :transport, :final => true) %> value )
  {
<% nullability_prefix = (supports_nullable?(attribute.arez, :default, :assume_generated => true)) ? "java.util.Objects.requireNonNull" : '' -%>
<% if attribute.reference? || attribute.remote_reference? -%>
    _<%= Reality::Naming.camelize(attribute.arez.name) %> = null;
    _<%= Reality::Naming.camelize(attribute.referencing_link_name) %> = <%= nullability_prefix %>( value );
<% elsif attribute.date? -%>
    _<%= Reality::Naming.camelize(attribute.arez.name) %> = <%= attribute.nullable? ? 'null == value ? null : ' : '' %>org.realityforge.gwt.datatypes.client.date.RDate.parse( <%= nullability_prefix %>( value ) );
<% elsif attribute.enumeration? -%>
<% if !attribute.arez.primitive?(:transport) -%>
    if( null != value )
    {
<% end -%>
    _<%= Reality::Naming.camelize(attribute.arez.name) %> = <%= attribute.arez.java_type %>.<%= attribute.enumeration.textual_values? ? "valueOf( #{nullability_prefix}( value ) )" : "values()[ #{nullability_prefix}( value )]" %>;
<% if !attribute.arez.primitive?(:transport) -%>
    }
    else
    {
      _<%= Reality::Naming.camelize(attribute.arez.name) %> = null;
    }
<% end %>
<% else -%>
    _<%= Reality::Naming.camelize(attribute.arez.name) %> = <%= nullability_prefix %>( value );
<% end %>  }
<% end %>
<% end %>
<% entity.arez.referencing_client_side_attributes.each do |attribute|
        name = attribute.inverse.name
        type = attribute.entity.arez.qualified_name
        if attribute.inverse.multiplicity == :many
          plural_name = Reality::Naming.pluralize(name)
{'fraction_non_alphanumeric': 0.19862085224258855, 'fraction_numerical': 0.00023575175340366595, 'mean_word_length': 5.1545157780195865, 'pattern_counts': {'":': 0, '<': 245, '<?xml version=': 0, '>': 270, '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': '3093917', 'n_tokens_mistral': 6101, 'n_tokens_neox': 5491, 'n_words': 786}