Java Code Examples for org.eclipse.emf.ecore.EClassifier#equals()

The following examples show how to use org.eclipse.emf.ecore.EClassifier#equals() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: xtext-core   File:    License: Eclipse Public License 2.0 6 votes vote down vote up
 * @since 2.1
public static EClassifier getCompatibleType(EClassifier typeA, EClassifier typeB, EObject grammarContext) {
	if (typeA.equals(typeB))
		return typeA;
	if (typeA instanceof EDataType && typeB instanceof EDataType) {
		Class<?> instanceClassA = typeA.getInstanceClass();
		Class<?> instanceClassB = typeB.getInstanceClass();
		if (instanceClassA != null && instanceClassB != null) {
			if (instanceClassA.isAssignableFrom(instanceClassB))
				return typeA;
			if (instanceClassB.isAssignableFrom(instanceClassA))
				return typeB;
	// no common type for simple datatypes available
	if (!(typeA instanceof EClass && typeB instanceof EClass))
		return null;

	List<EClass> sortedCandidates = getSortedCommonCompatibleTypeCandidates((EClass) typeA, (EClass) typeB);
	for (EClass candidate : sortedCandidates)
		if (isCommonCompatibleType(candidate, sortedCandidates))
			return candidate;
	EClass result = GrammarUtil.findEObject(GrammarUtil.getGrammar(grammarContext));
	return result;
Example 2
public void should_all_flow_element_classifiers_supported() throws Exception {
    final EClass flowElementEClass = ProcessPackage.Literals.FLOW_ELEMENT;
    for (final EClassifier eClass : ProcessPackage.eINSTANCE.getEClassifiers()) {
        if (eClass instanceof EClass
                && flowElementEClass.isSuperTypeOf((EClass) eClass)
                && !((EClass) eClass).isAbstract()
                && !eClass.equals(flowElementEClass)
                //Should below eClasses be abstract ?
                && !eClass.equals(ProcessPackage.Literals.GATEWAY)
                && !eClass.equals(ProcessPackage.Literals.MESSAGE_EVENT)
                && !eClass.equals(ProcessPackage.Literals.THROW_MESSAGE_EVENT)
                && !eClass.equals(ProcessPackage.Literals.LINK_EVENT)) {
            assertThat(labelProvider.getProcessPaletteText((EClass) eClass)).isNotNull();
            assertThat(labelProvider.getProcessPaletteDescription((EClass) eClass)).isNotNull();