<commit_before>/*******************************************************************************
 * Copyright (c) 2006, 2009 <NAME>.
 * 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> (XMLmodeling.com) - initial API and implementation
 *     
 * $Id$
 *******************************************************************************/
package org.openhealthtools.mdht.uml.common.util;

import java.util.Comparator;

import org.eclipse.uml2.uml.NamedElement;

/**
 * Compare two NamedElement objects, for sorting collections by name.
 * 
 * @version $Id: $
 */
public class NamedElementComparator implements Comparator {

	/* (non-Javadoc)
	 * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
	 */
	public int compare(Object o1, Object o2) {
		if (NamedElement.class.isInstance(o1) && NamedElement.class.isInstance(o2)) {
            String name1 = ((NamedElement) o1).getName();
            String name2 = ((NamedElement) o2).getName();
			if (name1 != null && name2 != null)
				return name1.compareToIgnoreCase(name2);
			else
				return 0;
		}
		else {
			return 0;
		}
	}

}
<commit_msg>parameterize Comparator superclass type<commit_after>/*******************************************************************************
 * Copyright (c) 2006, 2010 <NAME>.
 * 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> (XMLmodeling.com) - initial API and implementation
 *     
 * $Id$
 *******************************************************************************/
package org.openhealthtools.mdht.uml.common.util;

import java.util.Comparator;

import org.eclipse.uml2.uml.NamedElement;

/**
 * Compare two NamedElement objects, for sorting collections by name.
 * 
 * @version $Id: $
 */
public class NamedElementComparator implements Comparator<NamedElement> {

	/* (non-Javadoc)
	 * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
	 */
	public int compare(NamedElement o1, NamedElement o2) {
        String name1 = ((NamedElement) o1).getName();
        String name2 = ((NamedElement) o2).getName();
		if (name1 != null && name2 != null)
			return name1.compareToIgnoreCase(name2);
		else
			return 0;
	}

}

{'fraction_non_alphanumeric': 0.21904053551506136, 'fraction_numerical': 0.01896615842320565, 'mean_word_length': 3.629948364888124, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 8, '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': '3116390', 'n_tokens_mistral': 821, 'n_tokens_neox': 732, 'n_words': 197}