<commit_before>package org.aikodi.chameleon.util.association;

import java.util.function.BiConsumer;
import java.util.function.Function;

import org.aikodi.chameleon.core.element.Element;
import org.aikodi.chameleon.core.validation.BasicProblem;
import org.aikodi.chameleon.core.validation.Valid;
import org.aikodi.chameleon.core.validation.Verification;
import org.aikodi.rejuse.association.Association;
import org.aikodi.rejuse.association.SingleAssociation;

public class Single<T extends Element> extends SingleAssociation<Element, T> implements ChameleonAssociation<T> {

	public Single(Element element) {
		super(element);
	}

	public Single(Element element, Class<T> type) {
		super(element);
		_type = type;
	}
	
	private Class<T> _type;

	@Override
	protected boolean isValidElement(Association<? extends T, ? super Element> relation) {
		boolean result = super.isValidElement(relation) && ((_type == null || relation == null || _type.isInstance(relation.getObject())));
//		Util.debug(! result);
		return result;
	}
	
	public Single(Element element, String role) {
		super(element);
		setRole(role);
	}

	public Single(Element element, Association<? extends T, ? super Element> other) {
		super(element, other);
	}
	
	public Single(Element element, boolean mandatory) {
		this(element);
		_mandatory = mandatory;
	}

	public Single(Element element, boolean mandatory, String role) {<commit_msg>Removed debug code.<commit_after>package org.aikodi.chameleon.util.association;

import java.util.function.BiConsumer;
import java.util.function.Function;

import org.aikodi.chameleon.core.element.Element;
import org.aikodi.chameleon.core.validation.BasicProblem;
import org.aikodi.chameleon.core.validation.Valid;
import org.aikodi.chameleon.core.validation.Verification;
import org.aikodi.rejuse.association.Association;
import org.aikodi.rejuse.association.SingleAssociation;

public class Single<T extends Element> extends SingleAssociation<Element, T> implements ChameleonAssociation<T> {

	public Single(Element element) {
		super(element);
	}

	public Single(Element element, Class<T> type) {
		super(element);
		_type = type;
	}
	
	private Class<T> _type;

	@Override
	protected boolean isValidElement(Association<? extends T, ? super Element> relation) {
		boolean result = super.isValidElement(relation) && 
				((_type == null || relation == null || _type.isInstance(relation.getObject())));
		return result;
	}
	
	public Single(Element element, String role) {
		super(element);
		setRole(role);
	}

	public Single(Element element, Association<? extends T, ? super Element> other) {
		super(element, other);
	}
	
	public Single(Element element, boolean mandatory) {
		this(element);
		_mandatory = mandatory;
	}

	public Single(Element element, boolean mandatory, String role) {
{'fraction_non_alphanumeric': 0.11457214464733262, 'fraction_numerical': 0.0, 'mean_word_length': 5.467592592592593, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, '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': '3950966', 'n_tokens_mistral': 910, 'n_tokens_neox': 854, 'n_words': 194}