<commit_before>/*******************************************************************************
 * Copyright (c) 2015 The University of York.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 * 
 * Contributors:
 *     <NAME> - initial API and implementation
 ******************************************************************************/
package org.hawk.graph;

import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import java.util.LinkedHashSet;

/**
 * Read-only abstraction of the known metadata about a slot (an attribute or a
 * reference) in the graph populated by this updater.
 */
public class Slot {
	private final TypeNode typeNode;
	private final String propertyName, propertyType;
	private final boolean isAttribute, isReference, isMixed, isDerived;
	private final boolean isMany, isOrdered, isUnique;

	public Slot(TypeNode typeNode, String propertyName) {
		this.typeNode = typeNode;
		this.propertyName = propertyName;

		final String[] propertyMetadata = (String[]) typeNode.getNode().getProperty(propertyName);
		this.isAttribute = "a".equals(propertyMetadata[0]);
		this.isReference = "r".equals(propertyMetadata[0]);
		this.isMixed = "m".equals(propertyMetadata[0]);
		this.isDerived = "d".equals(propertyMetadata[0]);
		this.isMany = "t".equals(propertyMetadata[1]);
		this.isOrdered = "t".equals(propertyMetadata[2]);
		this.isUnique = "t".equals(propertyMetadata[3]);
		this.propertyType = propertyMetadata[4];
	}

	/**
	 * Returns the collection container that should be used for the value of
	 * this slot.
	 */
	protected Collection<Object> getCollection() {
		assert isMany : "A collection cannot be produced for an attribute with isMany = false";

		if (isOrdered && isUnique) {
			return new LinkedHashSet<Object>(); // ordered set
		} else if (isOrdered) {
			return new ArrayList<Object>(); // sequence
		} else if (isUnique) {
			return new HashSet<Object>(); // set
		} else {<commit_msg>Remove unwanted assertion in getCollection() - breaks good code<commit_after>/*******************************************************************************
 * Copyright (c) 2015 The University of York.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 * 
 * Contributors:
 *     <NAME> - initial API and implementation
 ******************************************************************************/
package org.hawk.graph;

import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import java.util.LinkedHashSet;

/**
 * Read-only abstraction of the known metadata about a slot (an attribute or a
 * reference) in the graph populated by this updater.
 */
public class Slot {
	private final TypeNode typeNode;
	private final String propertyName, propertyType;
	private final boolean isAttribute, isReference, isMixed, isDerived;
	private final boolean isMany, isOrdered, isUnique;

	public Slot(TypeNode typeNode, String propertyName) {
		this.typeNode = typeNode;
		this.propertyName = propertyName;

		final String[] propertyMetadata = (String[]) typeNode.getNode().getProperty(propertyName);
		this.isAttribute = "a".equals(propertyMetadata[0]);
		this.isReference = "r".equals(propertyMetadata[0]);
		this.isMixed = "m".equals(propertyMetadata[0]);
		this.isDerived = "d".equals(propertyMetadata[0]);
		this.isMany = "t".equals(propertyMetadata[1]);
		this.isOrdered = "t".equals(propertyMetadata[2]);
		this.isUnique = "t".equals(propertyMetadata[3]);
		this.propertyType = propertyMetadata[4];
	}

	/**
	 * Returns the collection container that should be used for the value of
	 * this slot.
	 */
	protected Collection<Object> getCollection() {
		if (isOrdered && isUnique) {
			return new LinkedHashSet<Object>(); // ordered set
		} else if (isOrdered) {
			return new ArrayList<Object>(); // sequence
		} else if (isUnique) {
			return new HashSet<Object>(); // set
		} else {
{'fraction_non_alphanumeric': 0.17797605071613054, 'fraction_numerical': 0.0075135008217891526, 'mean_word_length': 4.949720670391062, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, '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': '2362888', 'n_tokens_mistral': 1218, 'n_tokens_neox': 1123, 'n_words': 361}