<commit_before>// Copyright 2018, University of Colorado Boulder

/**
 * IO type for phet-core enumerations that supports serializing and deserializing values.
 *
 * @author <NAME> (PhET Interactive Simulations)
 */
define( function( require ) {
  'use strict';

  // modules
  const Enumeration = require( 'PHET_CORE/Enumeration' );
  const phetCore = require( 'PHET_CORE/phetCore' );
  const ObjectIO = require( 'TANDEM/types/ObjectIO' );
  const phetioInherit = require( 'TANDEM/phetioInherit' );
  const ArrayIO = require( 'TANDEM/types/ArrayIO' );
  const StringIO = require( 'TANDEM/types/StringIO' );

  /**
   * @param {Enumeration} enumeration
   * @module EnumerationIO
   * @constructor
   */
  function EnumerationIO( enumeration ) {
    assert && assert( enumeration, 'enumeration must be supplied' );
    assert && assert( enumeration instanceof Enumeration, 'enumeration must be supplied' );

    /**
     * @param {Object} value
     * @param {string} phetioID
     * @constructor
     */
    const EnumerationIOImpl = function EnumerationIOImpl( value, phetioID ) {
      assert && assert( false, 'This constructor is not called, because enumeration values, like primitives, are never wrapped.' );
    };

    return phetioInherit( ObjectIO, 'EnumerationIO', EnumerationIOImpl, {
      getValues: {
        returnType: ArrayIO( StringIO ),
        parameterTypes: [],
        implementation: function() {
          return enumeration.values.map( v => v.name );
        },
        documentation: 'Gets the possible values of the enumeration.'
      }
    }, {
      documentation: 'Enumeration pattern that provides a fixed set of possible values',

      // Used to generate the unique parametric typename for each EnumerationIO
      parameterTypes: [],

      events: [],

      /**
       * Encodes an Enumeration value to a string.
       * @param {Object} value from an Enumeration
       * @returns {Object} - a state object<commit_msg>Use validate instead of assertInstanceOf, see https://github.com/phetsims/axon/issues/226<commit_after>// Copyright 2018, University of Colorado Boulder

/**
 * IO type for phet-core enumerations that supports serializing and deserializing values.
 *
 * @author <NAME> (PhET Interactive Simulations)
 */
define( function( require ) {
  'use strict';

  // modules
  const Enumeration = require( 'PHET_CORE/Enumeration' );
  const phetCore = require( 'PHET_CORE/phetCore' );
  const ObjectIO = require( 'TANDEM/types/ObjectIO' );
  const phetioInherit = require( 'TANDEM/phetioInherit' );
  const ArrayIO = require( 'TANDEM/types/ArrayIO' );
  const StringIO = require( 'TANDEM/types/StringIO' );

  /**
   * @param {Enumeration} enumeration
   * @module EnumerationIO
   * @constructor
   */
  function EnumerationIO( enumeration ) {
    assert && assert( enumeration, 'enumeration must be supplied' );
    assert && assert( enumeration instanceof Enumeration, 'enumeration must be supplied' );

    /**
     * @param {Object} value
     * @param {string} phetioID
     * @constructor
     */
    const EnumerationIOImpl = function EnumerationIOImpl( value, phetioID ) {
      assert && assert( false, 'This constructor is not called, because enumeration values, like primitives, are never wrapped.' );
    };

    return phetioInherit( ObjectIO, 'EnumerationIO', EnumerationIOImpl, {
      getValues: {
        returnType: ArrayIO( StringIO ),
        parameterTypes: [],
        implementation: function() {
          return enumeration.values.map( v => v.name );
        },
        documentation: 'Gets the possible values of the enumeration.'
      }
    }, {
      validator: { valueType: Object },// TODO: https://github.com/phetsims/axon/issues/226
      documentation: 'Enumeration pattern that provides a fixed set of possible values',

      // Used to generate the unique parametric typename for each EnumerationIO
      parameterTypes: [],

      events: [],

      /**
       * Encodes an Enumeration value to a string.
       * @param {Object} value from an Enumeration
       * @returns {Object} - a state object
{'fraction_non_alphanumeric': 0.10792951541850221, 'fraction_numerical': 0.0034263338228095936, 'mean_word_length': 3.1534552845528454, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 2, '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': '2314555', 'n_tokens_mistral': 1209, 'n_tokens_neox': 1130, 'n_words': 354}