Java Code Examples for com.google.common.base.Joiner#join()
The following examples show how to use
com.google.common.base.Joiner#join() .
These examples are extracted from open source projects.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: rya File: VisibilityStatementMerger.java License: Apache License 2.0 | 6 votes |
@Override public Optional<RyaStatement> merge(final Optional<RyaStatement> parent, final Optional<RyaStatement> child) throws MergerException { if(parent.isPresent()) { final RyaStatement parentStatement = parent.get(); if(child.isPresent()) { final RyaStatement childStatement = child.get(); final String pVis = new String(parentStatement.getColumnVisibility(), StandardCharsets.UTF_8); final String cVis = new String(childStatement.getColumnVisibility(), StandardCharsets.UTF_8); String visibility = ""; final Joiner join = Joiner.on(")&("); if(pVis.isEmpty() || cVis.isEmpty()) { visibility = (pVis + cVis).trim(); } else { visibility = "(" + join.join(pVis, cVis) + ")"; } parentStatement.setColumnVisibility(visibility.getBytes(StandardCharsets.UTF_8)); return Optional.of(parentStatement); } return parent; } else if(child.isPresent()) { return child; } return Optional.absent(); }
Example 2
Source Project: PoseidonX File: DateUtil.java License: Apache License 2.0 | 6 votes |
/** * seconds to string like '30m 40s' and '1d 20h 30m 40s' * * @param secs * @return */ public static String prettyUptime(int secs) { String[][] PRETTYSECDIVIDERS = { new String[] { "s", "60" }, new String[] { "m", "60" }, new String[] { "h", "24" }, new String[] { "d", null } }; int diversize = PRETTYSECDIVIDERS.length; LinkedList<String> tmp = new LinkedList<String>(); int div = secs; for (int i = 0; i < diversize; i++) { if (PRETTYSECDIVIDERS[i][1] != null) { Integer d = Integer.parseInt(PRETTYSECDIVIDERS[i][1]); tmp.addFirst(div % d + PRETTYSECDIVIDERS[i][0]); div = div / d; } else { tmp.addFirst(div + PRETTYSECDIVIDERS[i][0]); } if (div <= 0 ) break; } Joiner joiner = Joiner.on(" "); return joiner.join(tmp); }
Example 3
Source Project: phoenix File: PhoenixTestBuilder.java License: Apache License 2.0 | 6 votes |
private static List<String> getFQColumnsAsList(List<String> columns, List<String> families, List<String> types) { assert (columns.size() == families.size()); Joiner familyJoiner = Joiner.on("."); Joiner typeJoiner = Joiner.on(" "); List<String> columnDefinitions = Lists.newArrayList(); int colIndex = 0; for (String family : families) { String column = columns.get(colIndex); String datatype = types.get(colIndex); colIndex++; if ((column != null) && (!column.isEmpty())) { String columnWithType = typeJoiner.join(column, datatype); columnDefinitions.add(((family != null) && (!family.isEmpty())) ? familyJoiner.join(family, columnWithType) : columnWithType); } } return columnDefinitions; }
Example 4
Source Project: buck File: MoreAsserts.java License: Apache License 2.0 | 6 votes |
/** * Asserts that every {@link com.facebook.buck.step.Step} in the observed list is a {@link * com.facebook.buck.shell.ShellStep} whose shell command arguments match those of the * corresponding entry in the expected list. */ public static void assertShellCommands( String userMessage, List<String> expected, List<Step> observed, ExecutionContext context) { Iterator<String> expectedIter = expected.iterator(); Iterator<Step> observedIter = observed.iterator(); Joiner joiner = Joiner.on(" "); while (expectedIter.hasNext() && observedIter.hasNext()) { String expectedShellCommand = expectedIter.next(); Step observedStep = observedIter.next(); if (!(observedStep instanceof ShellStep)) { failWith(userMessage, "Observed command must be a shell command: " + observedStep); } ShellStep shellCommand = (ShellStep) observedStep; String observedShellCommand = joiner.join(shellCommand.getShellCommand(context)); assertEquals(userMessage, expectedShellCommand, observedShellCommand); } if (expectedIter.hasNext()) { failWith(userMessage, "Extra expected command: " + expectedIter.next()); } if (observedIter.hasNext()) { failWith(userMessage, "Extra observed command: " + observedIter.next()); } }
Example 5
Source Project: jstorm File: ErrorTag.java License: Apache License 2.0 | 6 votes |
private String getErrorContent() { List<String> ret = new ArrayList<>(); for (ErrorEntity er : e) { long ts = ((long) er.getErrorTime()) * 1000; int index = er.getError().lastIndexOf(","); if (index == -1) { int idx = er.getError().indexOf("\n"); int length = er.getError().length(); if (idx != -1) { String first_line = er.getError().substring(0, idx); String rest_lines = er.getError().substring(idx + 1, length - 2); ret.add(first_line + " , at " + UIUtils.parseDateTime(ts)); ret.add(rest_lines); }else{ ret.add(er.getError() + " , at " + UIUtils.parseDateTime(ts)); } } else { ret.add(er.getError() + ", at " + UIUtils.parseDateTime(ts)); } } Joiner joiner = Joiner.on("\n"); return "<pre>" + joiner.join(ret) + "</pre>"; }
Example 6
Source Project: mt-flume File: EncryptionTestUtils.java License: Apache License 2.0 | 5 votes |
public static Map<String,String> configureForKeyStore(File keyStoreFile, File keyStorePasswordFile, Map<String, File> keyAliasPassword) throws Exception { Map<String, String> context = Maps.newHashMap(); List<String> keys = Lists.newArrayList(); Joiner joiner = Joiner.on("."); for(String alias : keyAliasPassword.keySet()) { File passwordFile = keyAliasPassword.get(alias); if(passwordFile == null) { keys.add(alias); } else { String propertyName = joiner.join(EncryptionConfiguration.KEY_PROVIDER, EncryptionConfiguration.JCE_FILE_KEYS, alias, EncryptionConfiguration.JCE_FILE_KEY_PASSWORD_FILE); keys.add(alias); context.put(propertyName, passwordFile.getAbsolutePath()); } } context.put(joiner.join(EncryptionConfiguration.KEY_PROVIDER, EncryptionConfiguration.JCE_FILE_KEY_STORE_FILE), keyStoreFile.getAbsolutePath()); if(keyStorePasswordFile != null) { context.put(joiner.join(EncryptionConfiguration.KEY_PROVIDER, EncryptionConfiguration.JCE_FILE_KEY_STORE_PASSWORD_FILE), keyStorePasswordFile.getAbsolutePath()); } context.put(joiner.join(EncryptionConfiguration.KEY_PROVIDER, EncryptionConfiguration.JCE_FILE_KEYS), Joiner.on(" ").join(keys)); return context; }
Example 7
Source Project: beam-client-java File: IncomingMessageData.java License: MIT License | 5 votes |
public String asString() { Joiner j = Joiner.on(""); Iterable<MessageTextComponent> components = Collections2.filter(this.message.message, Predicates.notNull()); return j.join(Iterables.transform(components, new Function<MessageTextComponent, String>() { @Override public String apply(MessageTextComponent component) { switch (component.type) { case EMOTICON: return component.text; case LINK: return component.url; case TEXT: default: return component.data; } } })); }
Example 8
Source Project: q File: DetailReport.java License: Apache License 2.0 | 5 votes |
private String getTitles(Set<String> ids, Map<String, String> titleIdToName) { String returnValue = ""; Joiner joiner = Joiner.on(SEPARATOR); if (ids != null && titleIdToName != null && titleIdToName.keySet() != null) { Set<String> intersection = Sets.intersection(ids, titleIdToName.keySet()); Map<String, String> copy = new LinkedHashMap<String, String>(titleIdToName); copy.keySet().retainAll(intersection); returnValue = joiner.join(copy.values()); } return returnValue; }
Example 9
Source Project: tac-kbp-eal File: RecallAnalysis.java License: MIT License | 5 votes |
public static String header(final ImmutableList<String> systemOrdering) { final Joiner tab = Joiner.on("\t"); final ImmutableList.Builder<String> h = ImmutableList.builder(); h.add("DOCID"); h.add("CASGroup"); h.addAll(systemOrdering); h.add("type/role"); h.add("Annotated Realis"); h.add("many CASes"); return tab.join(h.build()); }
Example 10
Source Project: incubator-gobblin File: RowLevelPolicyCheckResults.java License: Apache License 2.0 | 5 votes |
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); }
Example 11
Source Project: incubator-gobblin File: JobContextTest.java License: Apache License 2.0 | 5 votes |
@Test public void testCleanUpOldJobData() throws Exception { String rootPath = Files.createTempDir().getAbsolutePath(); final String JOB_PREFIX = Id.Job.PREFIX; final String JOB_NAME1 = "GobblinKafka"; final String JOB_NAME2 = "GobblinBrooklin"; final long timestamp1 = 1505774129247L; final long timestamp2 = 1505774129248L; final Joiner JOINER = Joiner.on(Id.SEPARATOR).skipNulls(); Object[] oldJob1 = new Object[]{JOB_PREFIX, JOB_NAME1, timestamp1}; Object[] oldJob2 = new Object[]{JOB_PREFIX, JOB_NAME2, timestamp1}; Object[] currentJob = new Object[]{JOB_PREFIX, JOB_NAME1, timestamp2}; Path currentJobPath = new Path(JobContext.getJobDir(rootPath, JOB_NAME1), JOINER.join(currentJob)); Path oldJobPath1 = new Path(JobContext.getJobDir(rootPath, JOB_NAME1), JOINER.join(oldJob1)); Path oldJobPath2 = new Path(JobContext.getJobDir(rootPath, JOB_NAME2), JOINER.join(oldJob2)); Path stagingPath = new Path(currentJobPath, "task-staging"); Path outputPath = new Path(currentJobPath, "task-output"); FileSystem fs = FileSystem.getLocal(new Configuration()); fs.mkdirs(currentJobPath); fs.mkdirs(oldJobPath1); fs.mkdirs(oldJobPath2); log.info("Created : {} {} {}", currentJobPath, oldJobPath1, oldJobPath2); gobblin.runtime.JobState jobState = new gobblin.runtime.JobState(); jobState.setProp(ConfigurationKeys.WRITER_STAGING_DIR, stagingPath.toString()); jobState.setProp(ConfigurationKeys.WRITER_OUTPUT_DIR, outputPath.toString()); JobContext jobContext = mock(JobContext.class); when(jobContext.getStagingDirProvided()).thenReturn(false); when(jobContext.getOutputDirProvided()).thenReturn(false); when(jobContext.getJobId()).thenReturn(currentJobPath.getName().toString()); JobLauncherUtils.cleanUpOldJobData(jobState, log, jobContext.getStagingDirProvided(), jobContext.getOutputDirProvided()); Assert.assertFalse(fs.exists(oldJobPath1)); Assert.assertTrue(fs.exists(oldJobPath2)); Assert.assertFalse(fs.exists(currentJobPath)); }
Example 12
Source Project: datacollector File: OracleCDCSource.java License: Apache License 2.0 | 5 votes |
private String formatTableList(List<String> tables) { List<String> quoted = new ArrayList<>(); for (String table : tables) { quoted.add(String.format("'%s'", table)); } Joiner joiner = Joiner.on(","); return joiner.join(quoted); }
Example 13
Source Project: nifi File: OrcFlowFileWriter.java License: Apache License 2.0 | 5 votes |
private String getColumnNamesFromInspector(ObjectInspector inspector) { List<String> fieldNames = Lists.newArrayList(); Joiner joiner = Joiner.on(","); if (inspector instanceof StructObjectInspector) { StructObjectInspector soi = (StructObjectInspector) inspector; List<? extends StructField> fields = soi.getAllStructFieldRefs(); fieldNames.addAll(fields.stream().map((Function<StructField, String>) StructField::getFieldName).collect(Collectors.toList())); } return joiner.join(fieldNames); }
Example 14
Source Project: phoenix File: PhoenixTestBuilder.java License: Apache License 2.0 | 4 votes |
/** * @return a formatted string with CFs * for e.g "A.COL1, B.COL2, C.COl3" */ private static String getFQColumnsAsString(List<String> columns, List<String> families) { Joiner columnJoiner = Joiner.on(","); return columnJoiner.join(getFQColumnsAsList(columns, families)); }
Example 15
Source Project: q File: ReportItem.java License: Apache License 2.0 | 4 votes |
@Override public String toString() { Joiner joiner = Joiner.on(Properties.inputDelimiter.get()); return joiner.join(namedValues.values()); }
Example 16
Source Project: incubator-gobblin File: RestApiCommand.java License: Apache License 2.0 | 4 votes |
@Override public String toString() { Joiner joiner = Joiner.on(":").skipNulls(); return this.cmd.toString() + ":" + joiner.join(this.params); }
Example 17
Source Project: openwebnet-android File: AutomationModelMatcher.java License: MIT License | 4 votes |
private String automationModelValue(AutomationModel automation) { Joiner joiner = Joiner.on("; ").skipNulls(); return joiner.join(automation.getName(), automation.getWhere(), automation.getEnvironmentId(), automation.getGatewayUuid(), automation.isFavourite()); }
Example 18
Source Project: divolte-collector File: BrowserLists.java License: Apache License 2.0 | 4 votes |
public static String browserNameList(final Iterable<Object[]> list) { Joiner joiner = Joiner.on('\n'); return joiner.join(StreamSupport.stream(list.spliterator(), false).map((param) -> param[1]).toArray()); }
Example 19
Source Project: trainbenchmark File: IngraphMatch.java License: Eclipse Public License 1.0 | 4 votes |
@Override public String toString() { final Joiner joiner = Joiner.on(", "); return "<" + joiner.join(toArray()) + ">"; }
Example 20
Source Project: codebuff File: FluentIterable.java License: BSD 2-Clause "Simplified" License | 2 votes |
/** * Returns a {@link String} containing all of the elements of this fluent iterable joined with * {@code joiner}. * * <p><b>{@code Stream} equivalent:</b> {@code joiner.join(stream.iterator())}, or, if you are not * using any optional {@code Joiner} features, * {@code stream.collect(Collectors.joining(delimiter)}. * * @since 18.0 */ @Beta public final String join(Joiner joiner) { return joiner.join(this); }