172 Set<? extends ModuleElement> modules = getAllModuleElements(); 173 if (modules.isEmpty()) { 174 TypeElement typeElt = getTypeElement(name); 175 return (typeElt != null) ? 176 Collections.singleton(typeElt): 177 Collections.emptySet(); 178 } else { 179 Set<TypeElement> result = new LinkedHashSet<>(1); // Usually expect at most 1 result 180 for (ModuleElement module: modules) { 181 TypeElement typeElt = getTypeElement(module, name); 182 if (typeElt != null) 183 result.add(typeElt); 184 } 185 return Collections.unmodifiableSet(result); 186 } 187 } 188 189 /** 190 * Returns a module element given its fully qualified name. 191 * 192 * If the named module cannot be found, {@code null} is 193 * returned. One situation where a module cannot be found is if 194 * the environment does not include modules, such as an annotation 195 * processing environment configured for a {@linkplain 196 * javax.annotation.processing.ProcessingEnvironment#getSourceVersion 197 * source version} without modules. 198 * 199 * @implSpec The default implementation of this method returns 200 * {@code null}. 201 * 202 * @param name the name 203 * @return the named module element, or {@code null} if it cannot be found 204 * @see #getAllModuleElements 205 * @since 9 206 * @spec JPMS 207 */ 208 default ModuleElement getModuleElement(CharSequence name) { 209 return null; 210 } 211 212 /** 213 * Returns all module elements in the current environment. 214 * 215 * If no modules are present, an empty set is returned. One 216 * situation where no modules are present occurs when the 217 * environment does not include modules, such as an annotation 218 * processing environment configured for a {@linkplain 219 * javax.annotation.processing.ProcessingEnvironment#getSourceVersion 220 * source version} without modules. 221 * 222 * @implSpec The default implementation of this method returns | 172 Set<? extends ModuleElement> modules = getAllModuleElements(); 173 if (modules.isEmpty()) { 174 TypeElement typeElt = getTypeElement(name); 175 return (typeElt != null) ? 176 Collections.singleton(typeElt): 177 Collections.emptySet(); 178 } else { 179 Set<TypeElement> result = new LinkedHashSet<>(1); // Usually expect at most 1 result 180 for (ModuleElement module: modules) { 181 TypeElement typeElt = getTypeElement(module, name); 182 if (typeElt != null) 183 result.add(typeElt); 184 } 185 return Collections.unmodifiableSet(result); 186 } 187 } 188 189 /** 190 * Returns a module element given its fully qualified name. 191 * 192 * If the requested module cannot be found, {@code null} is 193 * returned. One situation where a module cannot be found is if 194 * the environment does not include modules, such as an annotation 195 * processing environment configured for a {@linkplain 196 * javax.annotation.processing.ProcessingEnvironment#getSourceVersion 197 * source version} without modules. 198 * 199 * @implSpec The default implementation of this method returns 200 * {@code null}. 201 * 202 * @param name the name, or an empty string for an unnamed module 203 * @return the named module element, or {@code null} if it cannot be found 204 * @see #getAllModuleElements 205 * @since 9 206 * @spec JPMS 207 */ 208 default ModuleElement getModuleElement(CharSequence name) { 209 return null; 210 } 211 212 /** 213 * Returns all module elements in the current environment. 214 * 215 * If no modules are present, an empty set is returned. One 216 * situation where no modules are present occurs when the 217 * environment does not include modules, such as an annotation 218 * processing environment configured for a {@linkplain 219 * javax.annotation.processing.ProcessingEnvironment#getSourceVersion 220 * source version} without modules. 221 * 222 * @implSpec The default implementation of this method returns |