public void setUrl(String url) { if (StringUtils.isNotEmpty(url)) { this.url = url; } }
private static String getLocalMavenRepositoryPath() { String userHome = System.getProperty("user.home"); if (StringUtils.isNotEmpty(userHome)) { return userHome + File.separator + ".m2" + File.separator + "repository"; } return null; }
@Override public NewRepositoryImpl setName(@Nullable String s) { if (StringUtils.isNotEmpty(s)) { this.name = s; } return this; }
private static void appendContext(String context, StringBuilder res) { if (isNotEmpty(context)) { res.append(context); } } }
public Lifecycle(String name) { Preconditions.checkArgument(StringUtils.isNotEmpty(name), "Lifecycle name must not be null or empty"); this.name = name; handlers = new TreeMap<>(); for (Stage stage : Stage.values()) { handlers.put(stage, new CopyOnWriteArrayList<>()); } }
public boolean isLastFile(String fileName) { String needCompareName = lastDownload; if (StringUtils.isNotEmpty(needCompareName) && StringUtils.endsWith(needCompareName, "tar")) { needCompareName = needCompareName.substring(0, needCompareName.indexOf(".")); } return (needCompareName == null || fileName.equalsIgnoreCase(needCompareName)) && binlogList.isEmpty(); }
private List<String> getProfilerDumpFiles(File dir) throws IOException { List<File> filesForDir = directoryCleaner.getFilesForDir(dir); return filesForDir.stream().filter(file -> { String fileName = file.getName(); return StringUtils.isNotEmpty(fileName) && (fileName.endsWith(".txt") || fileName.endsWith(".jfr") || fileName.endsWith(".bin")); }).map(File::getName).collect(toList()); }
private void validateBranchParamsWhenPluginAbsent(List<String> validationMessages) { for (String param : Arrays.asList(BRANCH_NAME, BRANCH_TARGET)) { if (isNotEmpty(settings.get(param).orElse(null))) { validationMessages.add(format("To use the property \"%s\", the branch plugin is required but not installed. " + "See the documentation of branch support: %s.", param, BRANCHES_DOC_LINK)); } } }
private static void validateBranch(List<String> validationMessages, @Nullable String branch) { if (isNotEmpty(branch) && !ComponentKeys.isValidBranch(branch)) { validationMessages.add(format("\"%s\" is not a valid branch name. " + "Allowed characters are alphanumeric, '-', '_', '.' and '/'.", branch)); } }
/** * Effective value as {@code int}. * @return the value as {@code int}. If the property does not have value nor default value, then {@code 0} is returned. * @throws NumberFormatException if value is not empty and is not a parsable integer */ public int getInt(String key) { String value = getString(key); if (StringUtils.isNotEmpty(value)) { return Integer.parseInt(value); } return 0; }
/** * Does the opposite of {@link #toNameList(Collection)}. */ public static <T extends Item> List<T> fromNameList(ItemGroup context, @Nonnull String list, @Nonnull Class<T> type) { final Jenkins jenkins = Jenkins.getInstance(); List<T> r = new ArrayList<T>(); if (jenkins == null) { return r; } StringTokenizer tokens = new StringTokenizer(list,","); while(tokens.hasMoreTokens()) { String fullName = tokens.nextToken().trim(); if (StringUtils.isNotEmpty(fullName)) { T item = jenkins.getItem(fullName, context, type); if(item!=null) r.add(item); } } return r; }
private static Proxy parseProxyArg(String proxyUrl, String proxyUsername, String proxyPassword) throws MalformedURLException { URL url = new URL(proxyUrl); if (StringUtils.isNotEmpty(proxyUsername) && StringUtils.isNotEmpty(proxyPassword)) { AuthenticationBuilder authBuilder = new AuthenticationBuilder(); authBuilder.addUsername(proxyUsername).addPassword(proxyPassword); return new Proxy(url.getProtocol(), url.getHost(), url.getPort(), authBuilder.build()); } else { return new Proxy(url.getProtocol(), url.getHost(), url.getPort()); } }
private static void readCli(String[] args) throws Exception { Map<String, Object> cl = CLI.opt("f", "file", null, CLI.AS_STRING) .arg("key", CLI.FIRST_WINS) .parse(args); final String key = (String) cl.get("key"); final String file = (String) cl.get("f"); if (StringUtils.isNotEmpty(file)) { try (BufferedOutputStream f = new BufferedOutputStream(new FileOutputStream(file))) { BlobStoreSupport.readBlob(key, f); } } else { BlobStoreSupport.readBlob(key, System.out); } }
public static String getDbTableName(MappingConfig.DbMapping dbMapping) { String result = ""; if (StringUtils.isNotEmpty(dbMapping.getTargetDb())) { result += dbMapping.getTargetDb() + "."; } result += dbMapping.getTargetTable(); return result; } }
private static Protocol determineProtocol(AWSClientConfig clientConfig, AWSEndpointConfig endpointConfig) { final Protocol protocolFromClientConfig = parseProtocol(clientConfig.getProtocol()); final String endpointUrl = endpointConfig.getUrl(); if (StringUtils.isNotEmpty(endpointUrl)) { final URI uri = URI.create(endpointUrl); final Protocol protocol = parseProtocol(uri.getScheme()); if (protocol != null && (protocol != protocolFromClientConfig)) { log.warn("[%s] protocol will be used for endpoint [%s]", protocol, endpointUrl); } return protocol; } else { return protocolFromClientConfig; } } }
private Changeset convert(ScannerReport.Changesets.Changeset changeset, int line) { checkState(isNotEmpty(changeset.getRevision()), "Changeset on line %s must have a revision", line); checkState(changeset.getDate() != 0, "Changeset on line %s must have a date", line); return builder .setRevision(changeset.getRevision()) .setAuthor(isNotEmpty(changeset.getAuthor()) ? changeset.getAuthor() : null) .setDate(changeset.getDate()) .build(); } }
private static ClientConfiguration setProxyConfig(ClientConfiguration conf, AWSProxyConfig proxyConfig) { if (StringUtils.isNotEmpty(proxyConfig.getHost())) { conf.setProxyHost(proxyConfig.getHost()); } if (proxyConfig.getPort() != -1) { conf.setProxyPort(proxyConfig.getPort()); } if (StringUtils.isNotEmpty(proxyConfig.getUsername())) { conf.setProxyUsername(proxyConfig.getUsername()); } if (StringUtils.isNotEmpty(proxyConfig.getPassword())) { conf.setProxyPassword(proxyConfig.getPassword()); } return conf; }
private static String projectKeyFromReport(ScannerReport.Metadata reportMetadata) { String deprecatedBranch = reportMetadata.getDeprecatedBranch(); if (StringUtils.isNotEmpty(deprecatedBranch)) { return ComponentKeys.createKey(reportMetadata.getProjectKey(), deprecatedBranch); } return reportMetadata.getProjectKey(); }
protected String buildPositionForDump(Entry entry) { long time = entry.getHeader().getExecuteTime(); Date date = new Date(time); SimpleDateFormat format = new SimpleDateFormat(DATE_FORMAT); String position = entry.getHeader().getLogfileName() + ":" + entry.getHeader().getLogfileOffset() + ":" + entry.getHeader().getExecuteTime() + "(" + format.format(date) + ")"; if (StringUtils.isNotEmpty(entry.getHeader().getGtid())) { position += " gtid(" + entry.getHeader().getGtid() + ")"; } return position; }
/** * Clean up test environment. */ @After public void tearDown() { if (StringUtils.isNotEmpty(topoPath)) { try { Utils.forceDelete(topoPath); } catch (IOException e) { // ignore... } } }