<commit_before>/**
 * @license
 * Copyright 2015 Google Inc. All Rights Reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

CLASS({
  package: 'foam.util',
  name: 'JavaSource',

  requires: [
    'foam.core.types.StringEnumProperty',
    'foam.util.InlineTrait'
  ],

  documentation: function() {/* Generates Java source code from a FOAM
    model. Add a template for each model, named by CONSTANTIZED_MODEL_ID.
  */},

  methods: [
    function prepModel_(model) {
      // Java doesn't support traits, so we'll copy traits into the model directly.
      model = this.InlineTrait.create().inlineTraits(model);
      return model;
    },

    function generate(model) {
      model = this.prepModel_(model);

      var filter = function(m) {
        if ( m.labels && m.labels.indexOf('java') == -1 ) {
          return false;
        }
        return true;
      };

      model.properties = model.properties.filter(filter);
      model.methods = model.methods.filter(filter);
      model.listeners = model.listeners.filter(filter);

      return this.javaSource.call(model, null, this);
    },
  ],

  templates: [
    function javaSource(out, javaSource) {/*// Generated by FOAM, do not modify.
// Version <%= this.version %><%
  var className       = this.javaClassName;
  var parentClassName = 'AbstractFObject';
  var parentModel = '';
  if (this.extendsModel) {
    parentClassName = this.extendsModel;
    parentModel = this.extendsModel + '.MODEL(), ';
  }
  if ( GLOBAL[parentClassName] && GLOBAL[parentClassName].abstract )
    parentClassName = 'Abstract' + parentClassName;
%><% if ( this.package ) { %>
package <%= this.package %>;
<% } %>
import foam.core.*;
import foam.dao.*;
import java.util.Arrays;
import java.util.List;

public<%= this.abstract ? ' abstract' : '' %> class <%= className %>
    extends <%= parentClassName %> {
<% for ( var key in this.properties ) {
  var prop = this.properties[key];
  if ( prop.labels && prop.labels.indexOf('compiletime') != -1  )
    continue;
  javaSource.propertySource.call(this, out, prop);
}
if (this.relationships && this.relationships.length) {
  for ( var i = 0; i < this.relationships.length; i++) {
    var rel = this.relationships[i];
    javaSource.relationshipSource.call(this, out, rel);
  }
}

var allProps = this.getRuntimeProperties();
allProps = allProps.filter(function(m) {
  if ( m.labels &&
        ( m.labels.indexOf('java') == -1 ||
          m.labels.indexOf("compiletime') != -1 ) ) {
    return false;
  }
  return true;
});

 %>
final static Model model__ = new AbstractModel(<%= parentModel %>new Property[] {<% for (var i = 0; i < allProps.length; i++) { var prop = allProps[i]; %> <%= constantize(prop.name) %>,<% } %>} , new Relationship[] {<% if (this.relationships && this.relationships.length) { for (var i = 0; i < this.relationships.length; i++) { %> <%= constantize(this.relationships[i].name) %>, <% } } %> }) {
    public String getName() { return "<%= this.id %>"; }
    public String getShortName() { return "<%= this.name %>"; }
    public String getLabel() { return "<%= this.label %>"; }
    public Property getID() { return <%= this.ids.length ? constantize(this.ids[0]) : 'null' %>; }
    public FObject newInstance() { return new <%= className %>(); }
  };

  public Model model() {
    return model__;
  }
  public static Model MODEL() {
    return model__;
  }
<commit_msg>Fix another syntax error in JavaSource<commit_after>/**
 * @license
 * Copyright 2015 Google Inc. All Rights Reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

CLASS({
  package: 'foam.util',
  name: 'JavaSource',

  requires: [
    'foam.core.types.StringEnumProperty',
    'foam.util.InlineTrait'
  ],

  documentation: function() {/* Generates Java source code from a FOAM
    model. Add a template for each model, named by CONSTANTIZED_MODEL_ID.
  */},

  methods: [
    function prepModel_(model) {
      // Java doesn't support traits, so we'll copy traits into the model directly.
      model = this.InlineTrait.create().inlineTraits(model);
      return model;
    },

    function generate(model) {
      model = this.prepModel_(model);

      var filter = function(m) {
        if ( m.labels && m.labels.indexOf('java') == -1 ) {
          return false;
        }
        return true;
      };

      model.properties = model.properties.filter(filter);
      model.methods = model.methods.filter(filter);
      model.listeners = model.listeners.filter(filter);

      return this.javaSource.call(model, null, this);
    },
  ],

  templates: [
    function javaSource(out, javaSource) {/*// Generated by FOAM, do not modify.
// Version <%= this.version %><%
  var className       = this.javaClassName;
  var parentClassName = 'AbstractFObject';
  var parentModel = '';
  if (this.extendsModel) {
    parentClassName = this.extendsModel;
    parentModel = this.extendsModel + '.MODEL(), ';
  }
  if ( GLOBAL[parentClassName] && GLOBAL[parentClassName].abstract )
    parentClassName = 'Abstract' + parentClassName;
%><% if ( this.package ) { %>
package <%= this.package %>;
<% } %>
import foam.core.*;
import foam.dao.*;
import java.util.Arrays;
import java.util.List;

public<%= this.abstract ? ' abstract' : '' %> class <%= className %>
    extends <%= parentClassName %> {
<% for ( var key in this.properties ) {
  var prop = this.properties[key];
  if ( prop.labels && prop.labels.indexOf('compiletime') != -1  )
    continue;
  javaSource.propertySource.call(this, out, prop);
}
if (this.relationships && this.relationships.length) {
  for ( var i = 0; i < this.relationships.length; i++) {
    var rel = this.relationships[i];
    javaSource.relationshipSource.call(this, out, rel);
  }
}

var allProps = this.getRuntimeProperties();
allProps = allProps.filter(function(m) {
  if ( m.labels &&
        ( m.labels.indexOf('java') == -1 ||
          m.labels.indexOf("compiletime") != -1 ) ) {
    return false;
  }
  return true;
});

 %>
final static Model model__ = new AbstractModel(<%= parentModel %>new Property[] {<% for (var i = 0; i < allProps.length; i++) { var prop = allProps[i]; %> <%= constantize(prop.name) %>,<% } %>} , new Relationship[] {<% if (this.relationships && this.relationships.length) { for (var i = 0; i < this.relationships.length; i++) { %> <%= constantize(this.relationships[i].name) %>, <% } } %> }) {
    public String getName() { return "<%= this.id %>"; }
    public String getShortName() { return "<%= this.name %>"; }
    public String getLabel() { return "<%= this.label %>"; }
    public Property getID() { return <%= this.ids.length ? constantize(this.ids[0]) : 'null' %>; }
    public FObject newInstance() { return new <%= className %>(); }
  };

  public Model model() {
    return model__;
  }
  public static Model MODEL() {
    return model__;
  }

{'fraction_non_alphanumeric': 0.1498787182433295, 'fraction_numerical': 0.004085280224690412, 'mean_word_length': 3.294956140350877, 'pattern_counts': {'":': 0, '<': 51, '<?xml version=': 0, '>': 45, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '6928992', 'n_tokens_mistral': 2449, 'n_tokens_neox': 2318, 'n_words': 663}