blob: 91a89fe46e5909f7efeb0e41d2ff1b9f194b2055 [file] [log] [blame]
/*******************************************************************************
* Copyright (c) 2018 Agence spatiale canadienne / Canadian Space Agency
* 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:
* Pierre Allard,
* Regent L'Archeveque,
* Olivier L. Larouche - initial API and implementation
* SPDX-License-Identifier: EPL-1.0
*
*******************************************************************************/
package org.eclipse.apogy.common.emf.impl;
import org.eclipse.apogy.common.emf.Named;
public class NamedComparatorCustomImpl<T extends Named> extends NamedComparatorImpl<T> {
@Override
public int compare(T o1, T o2) {
String name1 = o1.getName();
String name2 = o2.getName();
if (name1 == null && name2 != null) {
return -1;
} else if (name1 != null && name2 == null) {
return 1;
} else if (name1 == null && name2 == null) {
return 0;
} else {
return name1.compareTo(name2);
}
}
} // NamedComparatorImpl