use of java.util.StringJoiner in project che by eclipse.
the class MavenArtifact method getDisplayString.
public String getDisplayString() {
StringJoiner joiner = new StringJoiner(":");
joiner.setEmptyValue("<unknown>");
joiner.add(groupId).add(artifactId).add(version);
return joiner.toString();
}
use of java.util.StringJoiner in project java-design-patterns by iluwatar.
the class App method prettyPrint.
private static <E> void prettyPrint(String delimiter, String prefix, Iterable<E> iterable) {
StringJoiner joiner = new StringJoiner(delimiter, prefix, ".");
Iterator<E> iterator = iterable.iterator();
while (iterator.hasNext()) {
joiner.add(iterator.next().toString());
}
LOGGER.info(joiner.toString());
}
use of java.util.StringJoiner in project jersey by jersey.
the class CombinedFeedControllerTest method testCreate.
@Test
public void testCreate() {
Form form = new Form();
form.param("title", params[0]);
form.param("description", params[1]);
form.param("urls", new StringJoiner(",").add(params[2]).add(params[3]).toString());
form.param("refreshPeriod", params[4]);
Response response = target().request().post(Entity.entity(form, MediaType.APPLICATION_FORM_URLENCODED_TYPE));
assertEquals(Status.OK.getStatusCode(), response.getStatus());
String html = response.readEntity(String.class);
// HTML page contains all information about the created entity
assertTrue(html.contains(params[0]) && html.contains(params[1]) && html.contains(params[2]) && html.contains(params[3]) && html.contains(params[4]));
}
use of java.util.StringJoiner in project presto by prestodb.
the class ShardPredicate method createShardPredicate.
private static String createShardPredicate(ImmutableList.Builder<JDBCType> types, ImmutableList.Builder<Object> values, Domain domain, JDBCType jdbcType) {
List<Range> ranges = domain.getValues().getRanges().getOrderedRanges();
// only apply predicates if all ranges are single values
if (ranges.isEmpty() || !ranges.stream().allMatch(Range::isSingleValue)) {
return "true";
}
ImmutableList.Builder<Object> valuesBuilder = ImmutableList.builder();
ImmutableList.Builder<JDBCType> typesBuilder = ImmutableList.builder();
StringJoiner rangePredicate = new StringJoiner(" OR ");
for (Range range : ranges) {
Slice uuidText = (Slice) range.getSingleValue();
try {
Slice uuidBytes = uuidStringToBytes(uuidText);
typesBuilder.add(jdbcType);
valuesBuilder.add(uuidBytes);
} catch (IllegalArgumentException e) {
return "true";
}
rangePredicate.add("shard_uuid = ?");
}
types.addAll(typesBuilder.build());
values.addAll(valuesBuilder.build());
return rangePredicate.toString();
}
use of java.util.StringJoiner in project presto by prestodb.
the class TestRaptorIntegrationSmokeTest method testShardingByTemporalTimestampColumn.
@Test
public void testShardingByTemporalTimestampColumn() throws Exception {
// Make sure we have at least 2 different orderdate.
assertEquals(computeActual("SELECT count(DISTINCT orderdate) >= 2 FROM orders WHERE orderdate < date '1992-02-08'").getOnlyValue(), true);
assertUpdate("CREATE TABLE test_shard_temporal_timestamp(col1 BIGINT, col2 TIMESTAMP) WITH (temporal_column = 'col2')");
int rows = 20;
StringJoiner joiner = new StringJoiner(", ", "INSERT INTO test_shard_temporal_timestamp VALUES ", "");
for (int i = 0; i < rows; i++) {
joiner.add(format("(%s, TIMESTAMP '2016-08-08 01:00' + interval '%s' hour)", i, i * 4));
}
assertUpdate(joiner.toString(), format("VALUES(%s)", rows));
MaterializedResult results = computeActual("SELECT format_datetime(col2, 'yyyyMMdd'), \"$shard_uuid\" FROM test_shard_temporal_timestamp");
assertEquals(results.getRowCount(), rows);
// Each shard will only contain data of one date.
SetMultimap<String, String> shardDateMap = HashMultimap.create();
for (MaterializedRow row : results.getMaterializedRows()) {
shardDateMap.put((String) row.getField(1), (String) row.getField(0));
}
for (Collection<String> dates : shardDateMap.asMap().values()) {
assertEquals(dates.size(), 1);
}
// Ensure one shard can contain different timestamps from the same day
assertLessThan(shardDateMap.size(), rows);
}
Aggregations