List of usage examples for org.apache.commons.lang StringUtils join
public static String join(Collection<?> collection, String separator)
Joins the elements of the provided Collection
into a single String containing the provided elements.
From source file:gov.nih.nci.cabig.caaers.domain.Notification.java
public void setRecipientRoles(List<String> recipientRoles) { roles = StringUtils.join(recipientRoles.toArray(), ','); }
From source file:com.titankingdoms.dev.titanchat.command.defaults.DebugCommand.java
@Override public void execute(CommandSender sender, String[] args) { if (args[0].equalsIgnoreCase("start")) { List<String> ids = Arrays.asList(Arrays.copyOfRange(args, 1, args.length)); for (String id : new ArrayList<String>(ids)) try { Debugger.startDebug(Integer.valueOf(id)); } catch (Exception e) { ids.remove(id);/*w ww .j av a 2s . c om*/ } Collections.sort(ids); sendMessage(sender, "&6Started debugging: " + StringUtils.join(ids, ", ")); } else if (args[0].equalsIgnoreCase("stop")) { List<String> ids = Arrays.asList(Arrays.copyOfRange(args, 1, args.length)); for (String id : new ArrayList<String>(ids)) try { Debugger.stopDebug(Integer.valueOf(id)); } catch (Exception e) { ids.remove(id); } Collections.sort(ids); sendMessage(sender, "&6Stopped debugging: " + StringUtils.join(ids, ", ")); } else { sendMessage(sender, "&4Incorrect usage: /titanchat debug " + getUsage()); } }
From source file:io.github.chrisbotcom.reminder.commands.Update.java
public static boolean execute(Reminder plugin, CommandSender sender, ReminderRecord reminder) throws Exception { if ((reminder.getId() == null) && (reminder.getPlayer() == null) && (reminder.getTag() == null)) { throw new ReminderException("Must supply either id or player and/or tag."); }//from w w w . j a v a 2 s. co m if ((reminder.getId() != null) && ((reminder.getPlayer() != null) && (reminder.getTag() != null))) { throw new ReminderException("Must supply either id or player and/or tag."); } List<String> setClauses = new ArrayList<>(); // "rate", "echo", // TODO Consider making <player> and <tag> updatable. if (reminder.getId() != null) { if (reminder.getPlayer() != null) { setClauses.add(String.format("player = '%s'", reminder.getPlayer())); } if (reminder.getTag() != null) { setClauses.add(String.format("tag = '%s'", reminder.getTag())); } } if (reminder.getStart() != null) { setClauses.add(String.format("start = %s", reminder.getStart())); } if (reminder.getMessage() != null) { setClauses.add(String.format("message = '%s'", reminder.getMessage())); } if (reminder.getDelay() != null) { setClauses.add(String.format("delay = %s", reminder.getDelay())); } if (reminder.getRate() != null) { setClauses.add(String.format("rate = %s", reminder.getRate())); } if (reminder.getEcho() != null) { setClauses.add(String.format("echo = %s", reminder.getEcho())); } String sql = String.format( "UPDATE reminders SET %s WHERE (? IN(id, 0)) AND (? IN(player, 'EMPTY')) AND (? IN(tag, 'EMPTY'))", StringUtils.join(setClauses, ", ")); PreparedStatement preparedStatement = plugin.db.prepareStatement(sql); preparedStatement.setLong(1, reminder.getId() == null ? 0 : reminder.getId()); preparedStatement.setString(2, reminder.getId() != null || reminder.getPlayer() == null ? "EMPTY" : reminder.getPlayer()); preparedStatement.setString(3, reminder.getId() != null || reminder.getTag() == null ? "EMPTY" : reminder.getTag()); int rows = preparedStatement.executeUpdate(); //sender.sendMessage(ChatColor.BLUE + String.format("%s", preparedStatement)); sender.sendMessage(ChatColor.GREEN + String.format("%s record(s) updated.", rows)); return true; }
From source file:info.archinnov.achilles.query.slice.SliceQueryValidator.java
public <T> void validateComponentsForSliceQuery(SliceQuery<T> sliceQuery) { final List<Object> clusteringsFrom = sliceQuery.getClusteringsFrom(); final List<Object> clusteringsTo = sliceQuery.getClusteringsTo(); final OrderingMode validationOrdering = sliceQuery.getOrdering(); final int partitionComponentsSize = sliceQuery.partitionComponentsSize(); final String startDescription = StringUtils .join(clusteringsFrom.subList(partitionComponentsSize, clusteringsFrom.size()), ","); final String endDescription = StringUtils .join(clusteringsTo.subList(partitionComponentsSize, clusteringsTo.size()), ","); log.trace("Check components for slice query {} / {}", startDescription, endDescription); final int startIndex = getLastNonNullIndex(clusteringsFrom); final int endIndex = getLastNonNullIndex(clusteringsTo); // No more than 1 non-null component difference between clustering keys Validator.validateTrue(Math.abs(endIndex - startIndex) <= 1, "There should be no more than 1 component difference between clustering keys: [[%s]," + "[%s]", startDescription, endDescription); for (int i = partitionComponentsSize; i <= Math.max(startIndex, endIndex) - 1; i++) { Object startComp = clusteringsFrom.get(i); Object endComp = clusteringsTo.get(i); int comparisonResult = comparator.compare(startComp, endComp); Validator.validateTrue(comparisonResult == 0, (i + 1 - partitionComponentsSize) + "th component for clustering keys should be equal: [[%s],[%s]", startDescription, endDescription); }/* w w w. ja v a 2s . c o m*/ if (startIndex > 0 && startIndex == endIndex) { Object startComp = clusteringsFrom.get(startIndex); Object endComp = clusteringsTo.get(endIndex); if (ASCENDING.equals(validationOrdering)) { Validator.validateTrue(comparator.compare(startComp, endComp) <= 0, "For slice query with ascending order, start clustering last component should be " + "'lesser or equal' to end clustering last component: [[%s],[%s]", startDescription, endDescription); } else { Validator.validateTrue(comparator.compare(startComp, endComp) >= 0, "For slice query with descending order, start clustering last component should be " + "'greater or equal' to end clustering last component: [[%s],[%s]", startDescription, endDescription); } } }
From source file:info.magnolia.test.mock.jcr.SessionTestUtil.java
static String asLineFeedSeparatedString(String... s) { return StringUtils.join(Arrays.asList(s), "\n"); }
From source file:com.netflix.spinnaker.kork.astyanax.EurekaHostSupplier.java
static Host buildHost(InstanceInfo info) { String[] parts = StringUtils.split(StringUtils.split(info.getHostName(), ".")[0], '-'); Host host = new Host(info.getHostName(), info.getPort()) .addAlternateIpAddress(// w w w .j a v a2s .co m StringUtils.join(new String[] { parts[1], parts[2], parts[3], parts[4] }, ".")) .addAlternateIpAddress(info.getIPAddr()).setId(info.getId()); try { if (info.getDataCenterInfo() instanceof AmazonInfo) { AmazonInfo amazonInfo = (AmazonInfo) info.getDataCenterInfo(); host.setRack(amazonInfo.get(AmazonInfo.MetaDataKey.availabilityZone)); } } catch (Throwable t) { logger.error("Error getting rack for host " + host.getName(), t); } return host; }
From source file:com.shigengyu.hyperion.server.controllers.HyperionRuntimeEnvironmentController.java
@GET @Path("/workflow/list/") public String getWorkflowDefinitions() { List<String> workflowDefinitionNames = Lists.transform( hyperionRuntime.getWorkflowDefinitionCache().getAll(), new Function<WorkflowDefinition, String>() { @Override/*from www . jav a 2 s . c o m*/ public String apply(final WorkflowDefinition input) { return input.getName(); } }); if (workflowDefinitionNames.size() == 0) { return "No workflow definition found"; } return StringUtils.join(workflowDefinitionNames, "<br />"); }
From source file:eu.annocultor.triple.Triple.java
/** * Creates a triple.//from ww w . j a va 2 s. c o m * * @param subject * subject uri * @param property * property uri * @param value * either uri or a literal * @param rule * the rule that created this triple * @param comment * text human-oriented comment, optional */ public Triple(String subject, Property property, Value value, Rule rule, String... comment) throws URISyntaxException, MalformedURLException { this.subject = new CodeURI(subject).toString(); this.property = property; this.value = value; this.rule = rule; this.comment = StringUtils.join(comment, ";"); }
From source file:com.dianping.cache.entity.CacheConfiguration.java
public void setServerList(List<String> serverList) { String servers = null;/*from w w w . j a v a 2 s .c o m*/ if (serverList != null && !serverList.isEmpty()) { servers = StringUtils.join(serverList, LIST_SEPARATOR); } setServers(servers); }
From source file:guru.nidi.raml.doc.st.ParamRenderer.java
@Override public String toString(Object o, String formatString, Locale locale) { final AbstractParam param = (AbstractParam) o; String s = ""; switch (formatString) { case "intLimit": if (param.getMinimum() != null) { s += param.getMinimum() + "<="; }//from w ww .j av a2 s . c o m if (param.getMinimum() != null || param.getMaximum() != null) { s += "x"; } if (param.getMaximum() != null) { s += "<=" + param.getMaximum(); } return s; case "strLimit": if (param.getMinLength() != null) { s += param.getMinLength() + "<="; } if (param.getMinLength() != null || param.getMaxLength() != null) { s += "length"; } if (param.getMaxLength() != null) { s += "<=" + param.getMaxLength(); } return s; case "type": return (param.getType() == null ? "string" : param.getType().toString().toLowerCase()) + (param.isRequired() ? param.isRepeat() ? "+" : "" : param.isRepeat() ? "*" : "?"); case "enum": return StringUtils.join(param.getEnumeration(), ", "); default: throw new IllegalArgumentException("unknown format '" + formatString + "'"); } }