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

org.eclipse.xtext.mwe.UrlClassLoaderClasspathEntriesProvider Maven / Gradle / Ivy

/*******************************************************************************
 * 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.mwe;

import java.net.URL;
import java.net.URLClassLoader;
import java.util.Arrays;
import java.util.List;

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

/**
 * @author svenefftinge - Initial contribution and API
 */
public class UrlClassLoaderClasspathEntriesProvider implements IClasspathEntriesProvider {

	public Iterable getAllPathes(ClassLoader classloader) {
		if (classloader instanceof URLClassLoader) {
			List urls = Arrays.asList(((URLClassLoader)classloader).getURLs());
			return Iterables.transform(urls, new Function(){
				public String apply(URL from) {
					return from.toString();
				}});
		}
		throw new IllegalArgumentException("expected an URLClassLoader but received "+classloader);
	}

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy