< prev index next >

src/java.compiler/share/classes/javax/lang/model/util/ElementFilter.java

Print this page




  66 
  67     private static final Set<ElementKind> CONSTRUCTOR_KIND =
  68         Collections.unmodifiableSet(EnumSet.of(ElementKind.CONSTRUCTOR));
  69 
  70     private static final Set<ElementKind> FIELD_KINDS =
  71         Collections.unmodifiableSet(EnumSet.of(ElementKind.FIELD,
  72                                                ElementKind.ENUM_CONSTANT));
  73     private static final Set<ElementKind> METHOD_KIND =
  74         Collections.unmodifiableSet(EnumSet.of(ElementKind.METHOD));
  75 
  76     private static final Set<ElementKind> PACKAGE_KIND =
  77         Collections.unmodifiableSet(EnumSet.of(ElementKind.PACKAGE));
  78 
  79     private static final Set<ElementKind> MODULE_KIND =
  80         Collections.unmodifiableSet(EnumSet.of(ElementKind.MODULE));
  81 
  82     private static final Set<ElementKind> TYPE_KINDS =
  83         Collections.unmodifiableSet(EnumSet.of(ElementKind.CLASS,
  84                                                ElementKind.ENUM,
  85                                                ElementKind.INTERFACE,

  86                                                ElementKind.ANNOTATION_TYPE));




  87     /**
  88      * Returns a list of fields in {@code elements}.
  89      * @return a list of fields in {@code elements}
  90      * @param elements the elements to filter
  91      */
  92     public static List<VariableElement>
  93             fieldsIn(Iterable<? extends Element> elements) {
  94         return listFilter(elements, FIELD_KINDS, VariableElement.class);
  95     }
  96 
  97     /**
  98      * Returns a set of fields in {@code elements}.
  99      * @return a set of fields in {@code elements}
 100      * @param elements the elements to filter
 101      */
 102     public static Set<VariableElement>
 103             fieldsIn(Set<? extends Element> elements) {
 104         return setFilter(elements, FIELD_KINDS, VariableElement.class);











 105     }
 106 
 107     /**
 108      * Returns a list of constructors in {@code elements}.
 109      * @return a list of constructors in {@code elements}
 110      * @param elements the elements to filter
 111      */
 112     public static List<ExecutableElement>
 113             constructorsIn(Iterable<? extends Element> elements) {
 114         return listFilter(elements, CONSTRUCTOR_KIND, ExecutableElement.class);
 115     }
 116 
 117     /**
 118      * Returns a set of constructors in {@code elements}.
 119      * @return a set of constructors in {@code elements}
 120      * @param elements the elements to filter
 121      */
 122     public static Set<ExecutableElement>
 123             constructorsIn(Set<? extends Element> elements) {
 124         return setFilter(elements, CONSTRUCTOR_KIND, ExecutableElement.class);




  66 
  67     private static final Set<ElementKind> CONSTRUCTOR_KIND =
  68         Collections.unmodifiableSet(EnumSet.of(ElementKind.CONSTRUCTOR));
  69 
  70     private static final Set<ElementKind> FIELD_KINDS =
  71         Collections.unmodifiableSet(EnumSet.of(ElementKind.FIELD,
  72                                                ElementKind.ENUM_CONSTANT));
  73     private static final Set<ElementKind> METHOD_KIND =
  74         Collections.unmodifiableSet(EnumSet.of(ElementKind.METHOD));
  75 
  76     private static final Set<ElementKind> PACKAGE_KIND =
  77         Collections.unmodifiableSet(EnumSet.of(ElementKind.PACKAGE));
  78 
  79     private static final Set<ElementKind> MODULE_KIND =
  80         Collections.unmodifiableSet(EnumSet.of(ElementKind.MODULE));
  81 
  82     private static final Set<ElementKind> TYPE_KINDS =
  83         Collections.unmodifiableSet(EnumSet.of(ElementKind.CLASS,
  84                                                ElementKind.ENUM,
  85                                                ElementKind.INTERFACE,
  86                                                ElementKind.RECORD,
  87                                                ElementKind.ANNOTATION_TYPE));
  88 
  89     private static final Set<ElementKind> STATE_COMPONENT_KIND =
  90         Set.of(ElementKind.STATE_COMPONENT);
  91 
  92     /**
  93      * Returns a list of fields in {@code elements}.
  94      * @return a list of fields in {@code elements}
  95      * @param elements the elements to filter
  96      */
  97     public static List<VariableElement>
  98             fieldsIn(Iterable<? extends Element> elements) {
  99         return listFilter(elements, FIELD_KINDS, VariableElement.class);
 100     }
 101 
 102     /**
 103      * Returns a set of fields in {@code elements}.
 104      * @return a set of fields in {@code elements}
 105      * @param elements the elements to filter
 106      */
 107     public static Set<VariableElement>
 108             fieldsIn(Set<? extends Element> elements) {
 109         return setFilter(elements, FIELD_KINDS, VariableElement.class);
 110     }
 111 
 112     // Method below may only be temporary
 113     /**
 114      * Returns a list of state descriptions in {@code elements}.
 115      * @return a list of state descriptions in {@code elements}
 116      * @param elements the elements to filter
 117      */
 118     public static List<VariableElement>
 119         stateComponentsIn(List<? extends Element> elements) {
 120         return listFilter(elements, STATE_COMPONENT_KIND, VariableElement.class);
 121     }
 122 
 123     /**
 124      * Returns a list of constructors in {@code elements}.
 125      * @return a list of constructors in {@code elements}
 126      * @param elements the elements to filter
 127      */
 128     public static List<ExecutableElement>
 129             constructorsIn(Iterable<? extends Element> elements) {
 130         return listFilter(elements, CONSTRUCTOR_KIND, ExecutableElement.class);
 131     }
 132 
 133     /**
 134      * Returns a set of constructors in {@code elements}.
 135      * @return a set of constructors in {@code elements}
 136      * @param elements the elements to filter
 137      */
 138     public static Set<ExecutableElement>
 139             constructorsIn(Set<? extends Element> elements) {
 140         return setFilter(elements, CONSTRUCTOR_KIND, ExecutableElement.class);


< prev index next >