<commit_before>/**
 * @license
 * Copyright 2017,2018 The FOAM Authors. All Rights Reserved.
 * http://www.apache.org/licenses/LICENSE-2.0
 */

foam.CLASS({
  refines: 'foam.core.Argument',
  properties: [
    {
      class: 'String',
      name: 'javaType',
      factory: function() { return this.of; }
    }
  ]
});


foam.CLASS({
  refines: 'foam.core.Property',
  properties: [
    {
      class: 'Boolean',
      name: 'generateJava',
      value: true
    },
    {
      class: 'String',
      name: 'javaType',
      value: 'Object'
    },
    {
      class: 'String',
      name: 'javaJSONParser',
      value: 'foam.lib.json.AnyParser.instance()'
    },
    {
      class: 'String',
      name: 'javaQueryParser',
      expression: function(javaJSONParser) {
        return javaJSONParser;
      }
    },
    {
      class: 'String',
      name: 'javaCSVParser'
    },
    {
      class: 'String',
      name: 'javaInfoType'
    },
    {
      class: 'String',
      name: 'javaFactory'
    },
    {
      class: 'String',
      name: 'javaGetter'
    },
    {
      class: 'String',
      name: 'shortName'
    },
    {
      class: 'StringArray',
      name: 'aliases'
    },
    {
      class: 'String',
      name: 'javaSetter'
    },
    {
      class: 'String',
      name: 'javaCloneProperty',
      value: null
    },
    {
      class: 'String',
      name: 'javaDiffProperty',
      value: null
    },
    {
      class: 'String',
      name: 'javaAssertValue'
    },
    {
      class: 'String',
      name: 'javaValue',
      expression: function(value) {
        // TODO: Escape string value reliably.
        return foam.typeOf(value) === foam.String ? '"' + value + '"' :
          foam.typeOf(value) === foam.Undefined ? 'null' :
          value;
      }
    },
    {
      class: 'Boolean',
      name: 'includeInDigest',
      value: true
    },
    {
      class: 'Boolean',
      name: 'includeInSignature',
      value: true
    }
  ],

  methods: [
    function createJavaPropertyInfo_(cls) {
      return foam.java.PropertyInfo.create({
        sourceCls:          cls,
        propName:           this.name,
        propShortName:      this.shortName,
        propAliases:        this.aliases,
        propType:           this.javaType,
        propValue:          this.javaValue,
        propRequired:       this.required,
        cloneProperty:      this.javaCloneProperty,
        diffProperty:       this.javaDiffProperty,
        jsonParser:         this.javaJSONParser,
        queryParser:        this.javaQueryParser,
        csvParser:          this.javaCSVParser,
        extends:            this.javaInfoType,
        networkTransient:   this.networkTransient,
        storageTransient:   this.storageTransient,
        xmlAttribute:       this.xmlAttribute,
        xmlTextNode:        this.xmlTextNode,
        sqlType:            this.sqlType,
        includeInDigest:    this.includeInDigest,
        includeInSignature: this.includeInSignature
      });
    },

    function generateSetter_() {
      return this.javaSetter ? this.javaSetter : `
        // The next line will eventually be promoted to production
        // if ( this.__frozen__ ) throw new UnsupportedOperationException("Object is frozen.");

        // But until then, this line helps to detect code which needs to be fixed before then.
        if ( this.__frozen__ ) {
          System.err.println("!!!!!!!!!!!!!!!!!!!!!!! INVALID MUTATION OF FROZEN OBJECT, fclone() REQUIRED !!!!!!!!!!!!!!!!!!!!!!!");
          Thread.dumpStack();
        }
        assert${foam.String.capitalize(this.name)}(val);
        ${this.name}_ = val;
        ${this.name}IsSet_ = true;
      `;
    },

    function buildJavaClass(cls) {
      if ( ! this.generateJava ) return;

      // Use javaInfoType as an indicator that this property should be<commit_msg>Throw exception when trying to modify frozen object<commit_after>/**
 * @license
 * Copyright 2017,2018 The FOAM Authors. All Rights Reserved.
 * http://www.apache.org/licenses/LICENSE-2.0
 */

foam.CLASS({
  refines: 'foam.core.Argument',
  properties: [
    {
      class: 'String',
      name: 'javaType',
      factory: function() { return this.of; }
    }
  ]
});


foam.CLASS({
  refines: 'foam.core.Property',
  properties: [
    {
      class: 'Boolean',
      name: 'generateJava',
      value: true
    },
    {
      class: 'String',
      name: 'javaType',
      value: 'Object'
    },
    {
      class: 'String',
      name: 'javaJSONParser',
      value: 'foam.lib.json.AnyParser.instance()'
    },
    {
      class: 'String',
      name: 'javaQueryParser',
      expression: function(javaJSONParser) {
        return javaJSONParser;
      }
    },
    {
      class: 'String',
      name: 'javaCSVParser'
    },
    {
      class: 'String',
      name: 'javaInfoType'
    },
    {
      class: 'String',
      name: 'javaFactory'
    },
    {
      class: 'String',
      name: 'javaGetter'
    },
    {
      class: 'String',
      name: 'shortName'
    },
    {
      class: 'StringArray',
      name: 'aliases'
    },
    {
      class: 'String',
      name: 'javaSetter'
    },
    {
      class: 'String',
      name: 'javaCloneProperty',
      value: null
    },
    {
      class: 'String',
      name: 'javaDiffProperty',
      value: null
    },
    {
      class: 'String',
      name: 'javaAssertValue'
    },
    {
      class: 'String',
      name: 'javaValue',
      expression: function(value) {
        // TODO: Escape string value reliably.
        return foam.typeOf(value) === foam.String ? '"' + value + '"' :
          foam.typeOf(value) === foam.Undefined ? 'null' :
          value;
      }
    },
    {
      class: 'Boolean',
      name: 'includeInDigest',
      value: true
    },
    {
      class: 'Boolean',
      name: 'includeInSignature',
      value: true
    }
  ],

  methods: [
    function createJavaPropertyInfo_(cls) {
      return foam.java.PropertyInfo.create({
        sourceCls:          cls,
        propName:           this.name,
        propShortName:      this.shortName,
        propAliases:        this.aliases,
        propType:           this.javaType,
        propValue:          this.javaValue,
        propRequired:       this.required,
        cloneProperty:      this.javaCloneProperty,
        diffProperty:       this.javaDiffProperty,
        jsonParser:         this.javaJSONParser,
        queryParser:        this.javaQueryParser,
        csvParser:          this.javaCSVParser,
        extends:            this.javaInfoType,
        networkTransient:   this.networkTransient,
        storageTransient:   this.storageTransient,
        xmlAttribute:       this.xmlAttribute,
        xmlTextNode:        this.xmlTextNode,
        sqlType:            this.sqlType,
        includeInDigest:    this.includeInDigest,
        includeInSignature: this.includeInSignature
      });
    },

    function generateSetter_() {
      return this.javaSetter ? this.javaSetter : `
        if ( this.__frozen__ ) throw new UnsupportedOperationException("Object is frozen.");
        assert${foam.String.capitalize(this.name)}(val);
        ${this.name}_ = val;
        ${this.name}IsSet_ = true;
      `;
    },

    function buildJavaClass(cls) {
      if ( ! this.generateJava ) return;

      // Use javaInfoType as an indicator that this property should be
{'fraction_non_alphanumeric': 0.1277258566978193, 'fraction_numerical': 0.0027089259108763375, 'mean_word_length': 1.8642358417377811, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 8}, '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': '898545', 'n_tokens_mistral': 2235, 'n_tokens_neox': 2197, 'n_words': 452}