Refine search
@GwtIncompatible // NullPointerTester public void testNullPointers() { NullPointerTester tester = new NullPointerTester(); tester.testAllPublicStaticMethods(Joiner.class); tester.testInstanceMethods(Joiner.on(","), NullPointerTester.Visibility.PACKAGE); tester.testInstanceMethods(Joiner.on(",").skipNulls(), NullPointerTester.Visibility.PACKAGE); tester.testInstanceMethods( Joiner.on(",").useForNull("x"), NullPointerTester.Visibility.PACKAGE); tester.testInstanceMethods( Joiner.on(",").withKeyValueSeparator("="), NullPointerTester.Visibility.PACKAGE); } }
@Override public String toString() { StringBuffer buffer = new StringBuffer(); buffer.append("["); for (String[] fields : processes) { buffer.append("[" + Joiner.on("; ").skipNulls().join(fields) + "]"); } buffer.append("]"); return "TopContainerResponse{" + "titles=" + Joiner.on("; ").skipNulls().join(titles) + ", processes=" + buffer.toString() + '}'; } }
/** * Removes the instance and host from the given metric name, returning the result. * * @param metricsName the long metrics name with instance and host name * @return the metrics name without instance and host name */ public static String stripInstanceAndHost(String metricsName) { String[] pieces = metricsName.split("\\."); Preconditions.checkArgument(pieces.length > 1, "Incorrect metrics name: %s.", metricsName); // Master metrics doesn't have hostname included. if (!pieces[0].equals(MetricsSystem.InstanceType.MASTER.toString())) { pieces[1] = null; } pieces[0] = null; return Joiner.on(".").skipNulls().join(pieces); }
/** * Concatenate all predicates with "and" clause * * @param predicateList list of predicate(filter) conditions * @return predicate */ protected String concatPredicates(List<Predicate> predicateList) { List<String> conditions = new ArrayList<>(); for (Predicate predicate : predicateList) { conditions.add(predicate.getCondition()); } return Joiner.on(" and ").skipNulls().join(conditions); }
private ZooKeeperNode getNode(ZooKeeper zooKeeper, String path) throws KeeperException, InterruptedException { LOGGER.debug("retrieving node and children at {}", path); final List<String> children = zooKeeper.getChildren(path, false); return new ZooKeeperNode(path, children.stream().map(s -> { final String childPath = Joiner.on('/').skipNulls().join(path.equals("/") ? "" : path, s); try { return getNode(zooKeeper, childPath); } catch (InterruptedException | KeeperException e) { if (e instanceof InterruptedException) { Thread.currentThread().interrupt(); } throw new RuntimeException(String.format("unable to discover sub-tree from %s", childPath), e); } }).collect(Collectors.toList())); }
public String getResults() { List<String> list = new ArrayList<>(); Joiner joiner = Joiner.on("\n").skipNulls(); for (Map.Entry<RowLevelPolicyResultPair, Long> entry : this.results.entrySet()) { list.add("RowLevelPolicy " + entry.getKey().getPolicy().toString() + " processed " + entry.getValue() + " record(s) with result " + entry.getKey().getResult()); } return joiner.join(list); }
protected String getCommittedOffsetGroupPath() { if (Strings.isNullOrEmpty(mCommittedOffsetGroupPath)) { String stripped = StringUtils.strip(mConfig.getKafkaZookeeperPath(), "/"); mCommittedOffsetGroupPath = Joiner.on("/").skipNulls().join( "", stripped.equals("") ? null : stripped, "consumers", mConfig.getKafkaGroup(), "offsets" ); } return mCommittedOffsetGroupPath; }