FileDocCategorySizeDatePackage
ElementFilter.javaAPI DocJava SE 6 API6608Tue Jun 10 00:26:12 BST 2008javax.lang.model.util

ElementFilter

public class ElementFilter extends Object
Filters for selecting just the elements of interest from a collection of elements. The returned sets and lists are new collections and do use the argument as a backing store. The methods in this class do not make any attempts to guard against concurrent modifications of the arguments. The returned sets and lists are mutable but unsafe for concurrent access. A returned set has the same iteration order as the argument set to a method.

If iterables and sets containing {@code null} are passed as arguments to methods in this class, a {@code NullPointerException} will be thrown.

Note that a static import statement can make the text of calls to the methods in this class more concise; for example:

import static javax.lang.model.util.ElementFilter.*;
...
{@code List} fs = fieldsIn(someClass.getEnclosedElements());
author
Joseph D. Darcy
author
Scott Seligman
author
Peter von der Ahé
author
Martin Buchholz
version
1.6 06/08/02
since
1.6

Fields Summary
private static Set
CONSTRUCTOR_KIND
private static Set
FIELD_KINDS
private static Set
METHOD_KIND
private static Set
PACKAGE_KIND
private static Set
TYPE_KINDS
Constructors Summary
private ElementFilter()

Methods Summary
public static java.util.ListconstructorsIn(java.lang.Iterable elements)
Returns a list of constructors in {@code elements}.

return
a list of constructors in {@code elements}
param
elements the elements to filter

	return listFilter(elements, CONSTRUCTOR_KIND, ExecutableElement.class);
    
public static java.util.SetconstructorsIn(java.util.Set elements)
Returns a set of constructors in {@code elements}.

return
a set of constructors in {@code elements}
param
elements the elements to filter

	return setFilter(elements, CONSTRUCTOR_KIND, ExecutableElement.class);
    
public static java.util.ListfieldsIn(java.lang.Iterable elements)
Returns a list of fields in {@code elements}.

return
a list of fields in {@code elements}
param
elements the elements to filter

                               
      
	        
	return listFilter(elements, FIELD_KINDS, VariableElement.class);
    
public static java.util.SetfieldsIn(java.util.Set elements)
Returns a set of fields in {@code elements}.

return
a set of fields in {@code elements}
param
elements the elements to filter

	return setFilter(elements, FIELD_KINDS, VariableElement.class);
    
private static java.util.ListlistFilter(java.lang.Iterable elements, java.util.Set targetKinds, java.lang.Class clazz)

	List<E> list = new ArrayList<E>();
	for (Element e : elements) {
	    if (targetKinds.contains(e.getKind()))
		list.add(clazz.cast(e));
	}
	return list;
    
public static java.util.ListmethodsIn(java.lang.Iterable elements)
Returns a list of methods in {@code elements}.

return
a list of methods in {@code elements}
param
elements the elements to filter

	return listFilter(elements, METHOD_KIND, ExecutableElement.class);
    
public static java.util.SetmethodsIn(java.util.Set elements)
Returns a set of methods in {@code elements}.

return
a set of methods in {@code elements}
param
elements the elements to filter

	return setFilter(elements, METHOD_KIND, ExecutableElement.class);
    
public static java.util.ListpackagesIn(java.lang.Iterable elements)
Returns a list of packages in {@code elements}.

return
a list of packages in {@code elements}
param
elements the elements to filter

	return listFilter(elements, PACKAGE_KIND, PackageElement.class);
    
public static java.util.SetpackagesIn(java.util.Set elements)
Returns a set of packages in {@code elements}.

return
a set of packages in {@code elements}
param
elements the elements to filter

	return setFilter(elements, PACKAGE_KIND, PackageElement.class);
    
private static java.util.SetsetFilter(java.util.Set elements, java.util.Set targetKinds, java.lang.Class clazz)

	// Return set preserving iteration order of input set.
	Set<E> set = new LinkedHashSet<E>();
	for (Element e : elements) {
	    if (targetKinds.contains(e.getKind()))
		set.add(clazz.cast(e));
	}
	return set;
    
public static java.util.ListtypesIn(java.lang.Iterable elements)
Returns a list of types in {@code elements}.

return
a list of types in {@code elements}
param
elements the elements to filter

	return listFilter(elements, TYPE_KINDS, TypeElement.class);
    
public static java.util.SettypesIn(java.util.Set elements)
Returns a set of types in {@code elements}.

return
a set of types in {@code elements}
param
elements the elements to filter

	return setFilter(elements, TYPE_KINDS, TypeElement.class);