<commit_before>/*
 * JaamSim Discrete Event Simulation
 * Copyright (C) 2011 Ausenco Engineering Canada Inc.
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 */
package com.sandwell.JavaSimulation;

import java.util.ArrayList;
import java.util.HashMap;

/**
 * Class KeyListInput for storing a list of entities of class V, with an optional key of class K1
 */
public class KeyListInput<K1 extends Entity, V extends Entity> extends Input<ArrayList<V>> {

	private Class<K1> keyClass;
	private Class<V> valClass;
	private HashMap<K1,ArrayList<V>> hashMap;

	public KeyListInput(Class<K1> kClass, Class<V> vClass, String keyword, String cat, ArrayList<V> def) {
		super(keyword, cat, def);
		keyClass = kClass;
		valClass = vClass;
		hashMap = new HashMap<K1,ArrayList<V>>();
	}

	@Override
	public void parse(StringVector input)
	throws InputErrorException {

		ArrayList<K1> list;
		try {
			// Determine the key(s)
			list = Input.parseEntityList(input.subString(0, 0), keyClass, true);
		}
		catch (InputErrorException e) {
			// A key was not provided.  Set the default value
			ArrayList<V> defValue = Input.parseEntityList( input.subString(0,input.size()-1), valClass, true );
			this.setDefaultValue( defValue );
			return;
		}

		// The input is of the form: <Key> <value1 value2 value3...>
		// Determine the value
		ArrayList<V> val = Input.parseEntityList( input.subString(1,input.size()-1), valClass, true );

		// Set the value for the given keys
		for( int i = 0; i < list.size(); i++ ) {
			hashMap.put( list.get(i), val );
		}
	}
<commit_msg>JS: move the setAppendable(true) call into the KeyListInput constructor<commit_after>/*
 * JaamSim Discrete Event Simulation
 * Copyright (C) 2011 Ausenco Engineering Canada Inc.
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 */
package com.sandwell.JavaSimulation;

import java.util.ArrayList;
import java.util.HashMap;

/**
 * Class KeyListInput for storing a list of entities of class V, with an optional key of class K1
 */
public class KeyListInput<K1 extends Entity, V extends Entity> extends Input<ArrayList<V>> {

	private Class<K1> keyClass;
	private Class<V> valClass;
	private HashMap<K1,ArrayList<V>> hashMap;

	public KeyListInput(Class<K1> kClass, Class<V> vClass, String keyword, String cat, ArrayList<V> def) {
		super(keyword, cat, def);
		keyClass = kClass;
		valClass = vClass;
		hashMap = new HashMap<K1,ArrayList<V>>();
		setAppendable(true);
	}

	@Override
	public void parse(StringVector input)
	throws InputErrorException {

		ArrayList<K1> list;
		try {
			// Determine the key(s)
			list = Input.parseEntityList(input.subString(0, 0), keyClass, true);
		}
		catch (InputErrorException e) {
			// A key was not provided.  Set the default value
			ArrayList<V> defValue = Input.parseEntityList( input.subString(0,input.size()-1), valClass, true );
			this.setDefaultValue( defValue );
			return;
		}

		// The input is of the form: <Key> <value1 value2 value3...>
		// Determine the value
		ArrayList<V> val = Input.parseEntityList( input.subString(1,input.size()-1), valClass, true );

		// Set the value for the given keys
		for( int i = 0; i < list.size(); i++ ) {
			hashMap.put( list.get(i), val );
		}
	}

{'fraction_non_alphanumeric': 0.1023142509135201, 'fraction_numerical': 0.01071863580998782, 'mean_word_length': 4.019559902200489, 'pattern_counts': {'":': 0, '<': 39, '<?xml version=': 0, '>': 37, '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': '6958744', 'n_tokens_mistral': 1322, 'n_tokens_neox': 1230, 'n_words': 469}