/** * Replaces the {@link #TOP_LEVEL_PACKAGE_SYMBOL} at the beginning of the * given text with the module's top-level package * * @param moduleName * @param text * @return a well-formed Java package name (might have a trailing dot) */ private String replaceTopLevelPackageSymbol(final Pom module, final String text) { final String topLevelPackage = getTopLevelPackage(module); if (TOP_LEVEL_PACKAGE_SYMBOL.equals(text)) { return topLevelPackage; } final String textWithoutSymbol = StringUtils.removeStart(text, TOP_LEVEL_PACKAGE_SYMBOL); return topLevelPackage + "." + StringUtils.removeStart(textWithoutSymbol, "."); }
private String convertToFullyQualifiedPackageName(final Pom module, final String text) { final String normalisedText = StringUtils.removeEnd(text, ".").toLowerCase(); if (normalisedText.startsWith(TOP_LEVEL_PACKAGE_SYMBOL)) { return replaceTopLevelPackageSymbol(module, normalisedText); } return normalisedText; }
if (validateModule(projectOperations.getPomFromModuleName(targetModuleName), optionContext)) { targetModule = projectOperations.getPomFromModuleName(targetModuleName); heading = ""; if (validateModule(projectOperations.getFocusedModule(), optionContext)) { addCompletionsForOtherModuleNames(completions, targetModule, optionContext); addCompletionsForPackagesInTargetModule(completions, targetModule, heading, prefix, formattedPrefix);
@CliOptionAutocompleteIndicator(command = "jms receiver", param = "endpoint", validate = false, includeSpaceOnFinish = false, help = "--endpoint parameter parameter is the service where will be added the " + "support to send emails.") public List<String> returnApplicationPackages(ShellContext shellContext) { List<String> applicationPackages = new ArrayList<String>(); // Get only application modules StringBuffer matcher = new StringBuffer("feature["); matcher.append(ModuleFeatureName.APPLICATION).append("]"); JavaPackageConverter converter = (JavaPackageConverter) getJavaPackageConverterService().get(0); List<Completion> completions = new ArrayList<Completion>(); converter.getAllPossibleValues(completions, String.class, shellContext.getParameters().get("endpoint"), matcher.toString(), null); for (Completion completion : completions) { applicationPackages.add(completion.getValue()); } return applicationPackages; }
public JavaPackage convertFromText(String value, final Class<?> requiredType, final String optionContext) { if (StringUtils.isBlank(value)) { return null; } Pom module = projectOperations.getFocusedModule(); if (value.contains(MODULE_PATH_SEPARATOR)) { final String moduleName = value.substring(0, value.indexOf(MODULE_PATH_SEPARATOR)); module = projectOperations.getPomFromModuleName(moduleName); value = value.substring(value.indexOf(MODULE_PATH_SEPARATOR) + 1, value.length()).trim(); if (StringUtils.contains(optionContext, UPDATE)) { projectOperations.setModule(module); } } String moduleName = module == null ? null : module.getModuleName(); JavaPackage result = new JavaPackage(convertToFullyQualifiedPackageName(module, value), moduleName); if (optionContext != null && (optionContext.contains(UPDATE) || optionContext.contains(UPDATELAST))) { lastUsed.setPackage(result, module); } return result; }
private void addCompletionsForOtherModuleNames(final Collection<Completion> completions, final Pom targetModule, String optionContext) { for (final Pom pom : getValidModules(optionContext)) { if (StringUtils.isNotBlank(pom.getModuleName()) && (targetModule == null || !pom.getModuleName().equals(targetModule.getModuleName()))) { completions.add(new Completion(pom.getModuleName() + MODULE_PATH_SEPARATOR, decorate( pom.getModuleName() + MODULE_PATH_SEPARATOR, FG_CYAN), "Modules", 0)); } } }