All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.eclipse.xtext.resource.impl.AbstractCompoundSelectable Maven / Gradle / Ivy

There is a newer version: 2.4.3
Show newest version
/*******************************************************************************
 * Copyright (c) 2010 itemis AG (http://www.itemis.eu) and others.
 * 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
 *******************************************************************************/
package org.eclipse.xtext.resource.impl;

import java.util.Collections;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.xtext.naming.QualifiedName;
import org.eclipse.xtext.resource.IEObjectDescription;
import org.eclipse.xtext.resource.ISelectable;

import com.google.common.base.Function;
import com.google.common.collect.Iterables;

/**
 * @author Sebastian Zarnekow - Initial contribution and API
 */
public abstract class AbstractCompoundSelectable implements ISelectable {

	public boolean isEmpty() {
		return Iterables.isEmpty(getSelectables());
	}
	
	public Iterable getExportedObjects() {
		return Iterables.concat(Iterables.transform(getSelectables(), new Function>() {
			public Iterable apply(ISelectable from) {
				if (from != null)
					return from.getExportedObjects();
				return Collections.emptyList();
			}
		}));
	}
	
	protected abstract Iterable getSelectables();

	public Iterable getExportedObjectsByType(final EClass type) {
		return Iterables.concat(Iterables.transform(getSelectables(), new Function>() {
			public Iterable apply(ISelectable from) {
				if (from != null)
					return from.getExportedObjectsByType(type);
				return Collections.emptyList();
			}
		}));
	}
	
	public Iterable getExportedObjectsByObject(final EObject object) {
		return Iterables.concat(Iterables.transform(getSelectables(), new Function>() {
			public Iterable apply(ISelectable from) {
				if (from != null)
					return from.getExportedObjectsByObject(object);
				return Collections.emptyList();
			}
		}));
	}
	
	public Iterable getExportedObjects(final EClass type, final QualifiedName qualifiedName, final boolean ignoreCase) {
		return Iterables.concat(Iterables.transform(getSelectables(), new Function>() {
			public Iterable apply(ISelectable from) {
				if (from != null)
					return from.getExportedObjects(type, qualifiedName, ignoreCase);
				return Collections.emptyList();
			}
		}));
	}

	
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy