diff options
author | Andrew John Hughes <gnu_andrew@member.fsf.org> | 2013-02-03 15:27:59 +0100 |
---|---|---|
committer | Andrew John Hughes <gnu_andrew@member.fsf.org> | 2013-02-03 15:27:59 +0100 |
commit | f45f5eea2eb5bed298a7372d6d2da827b0400e86 (patch) | |
tree | 5d86ff92623127cc51bff57e0c17dad985d67d71 | |
parent | 09109d040a207e2a28d09dcccbfd703bb6d93773 (diff) | |
download | classpath-compiler-support.tar.gz |
Add remaining Set filters to ElementFilter.compiler-support
2013-02-03 Andrew John Hughes <gnu_andrew@member.fsf.org>
* javax/lang/model/util/ElementFilter.java:
(constructorsIn(Set)): Implemented.
(fieldsIn(Set)): Likewise.
(methodsIn(Set)): Likewise.
(packagesIn(Set)): Likewise.
Signed-off-by: Andrew John Hughes <gnu_andrew@member.fsf.org>
-rw-r--r-- | ChangeLog | 8 | ||||
-rw-r--r-- | javax/lang/model/util/ElementFilter.java | 52 |
2 files changed, 60 insertions, 0 deletions
@@ -1,3 +1,11 @@ +2013-02-03 Andrew John Hughes <gnu_andrew@member.fsf.org> + + * javax/lang/model/util/ElementFilter.java: + (constructorsIn(Set)): Implemented. + (fieldsIn(Set)): Likewise. + (methodsIn(Set)): Likewise. + (packagesIn(Set)): Likewise. + 2013-02-01 Andrew John Hughes <gnu_andrew@member.fsf.org> * javax/lang/model/element/ElementKind.java: diff --git a/javax/lang/model/util/ElementFilter.java b/javax/lang/model/util/ElementFilter.java index 88d2c6bda..9ddff2c65 100644 --- a/javax/lang/model/util/ElementFilter.java +++ b/javax/lang/model/util/ElementFilter.java @@ -45,7 +45,10 @@ import java.util.Set; import javax.lang.model.element.Element; import javax.lang.model.element.ElementKind; +import javax.lang.model.element.ExecutableElement; +import javax.lang.model.element.PackageElement; import javax.lang.model.element.TypeElement; +import javax.lang.model.element.VariableElement; /** * <p>Filter for selecting elements of interest from a collection. @@ -78,6 +81,55 @@ public class ElementFilter } /** + * Returns a set containing just the constructors + * held in {@code elements}. + * + * @param elements the elements to filter. + * @return the filtered set. + */ + public static Set<ExecutableElement> constructorsIn(Set<? extends Element> elements) + { + return new FilteredSet<ExecutableElement>(elements, ElementKind.CONSTRUCTOR); + } + + /** + * Returns a set containing just the fields + * held in {@code elements}. + * + * @param elements the elements to filter. + * @return the filtered set. + */ + public static Set<VariableElement> fieldsIn(Set<? extends Element> elements) + { + return new FilteredSet<VariableElement>(elements, ElementKind.FIELD, + ElementKind.ENUM_CONSTANT); + } + + /** + * Returns a set containing just the methods + * held in {@code elements}. + * + * @param elements the elements to filter. + * @return the filtered set. + */ + public static Set<ExecutableElement> methodsIn(Set<? extends Element> elements) + { + return new FilteredSet<ExecutableElement>(elements, ElementKind.METHOD); + } + + /** + * Returns a set containing just the packages + * held in {@code elements}. + * + * @param elements the elements to filter. + * @return the filtered set. + */ + public static Set<PackageElement> packagesIn(Set<? extends Element> elements) + { + return new FilteredSet<PackageElement>(elements, ElementKind.PACKAGE); + } + + /** * Provides a filtered view of the given set, returning only * instances which are of one of the specified kinds. */ |