本文整理汇总了Java中com.google.common.base.Joiner.join方法的典型用法代码示例。如果您正苦于以下问题:Java Joiner.join方法的具体用法?Java Joiner.join怎么用?Java Joiner.join使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.common.base.Joiner
的用法示例。
在下文中一共展示了Joiner.join方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: assertIssues
import com.google.common.base.Joiner; //导入方法依赖的package包/类
/**
* Asserts that the given resource (usually an N4JS file) contains issues with the given messages and no other
* issues. Each message given should be prefixed with the line numer where the issues occurs, e.g.:
*
* <pre>
* line 5: Couldn't resolve reference to identifiable element 'unknown'.
* </pre>
*
* Column information is not provided, so this method is not intended for several issues within a single line.
*/
public static void assertIssues(final IResource resource, String... expectedMessages) throws CoreException {
final IMarker[] markers = resource.findMarkers(MarkerTypes.ANY_VALIDATION, true, IResource.DEPTH_INFINITE);
final String[] actualMessages = new String[markers.length];
for (int i = 0; i < markers.length; i++) {
final IMarker m = markers[i];
actualMessages[i] = "line " + MarkerUtilities.getLineNumber(m) + ": " + m.getAttribute(IMarker.MESSAGE);
}
if (!Objects.equals(
new HashSet<>(Arrays.asList(actualMessages)),
new HashSet<>(Arrays.asList(expectedMessages)))) {
final Joiner joiner = Joiner.on("\n ");
final String msg = "expected these issues:\n"
+ " " + joiner.join(expectedMessages) + "\n"
+ "but got these:\n"
+ " " + joiner.join(actualMessages);
System.out.println("*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*");
System.out.println(msg);
System.out.println("*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*");
Assert.fail(msg);
}
}
示例2: toResponse
import com.google.common.base.Joiner; //导入方法依赖的package包/类
@Override
public Response toResponse(final ConstraintViolationException exception) {
List<String> violations = new ArrayList<>();
exception.getConstraintViolations()
.stream()
.forEach(input -> violations.add(format(input)));
Joiner joiner = Joiner.on("; ").skipNulls();
String detail = joiner.join(violations);
return Response.status(BAD_REQUEST)
.entity(new Failure(detail))
.build();
}
示例3: combineNames
import com.google.common.base.Joiner; //导入方法依赖的package包/类
private static String combineNames(CommonTree node) {
List<Tree> children = node.getChildren();
List<String> names = new ArrayList<String>();
for (Tree child : children) {
names.add(child.getText());
}
Joiner joiner = Joiner.on(".").skipNulls();
return joiner.join(names);
}
示例4: configureForKeyStore
import com.google.common.base.Joiner; //导入方法依赖的package包/类
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;
}
示例5: toJavaTypeName
import com.google.common.base.Joiner; //导入方法依赖的package包/类
/**
* Returns the full Java type name based on the given protobuf type parameters.
*
* @param className the protobuf type name
* @param enclosingClassName the optional enclosing class for the given type
* @param javaPackage the proto file's configured java package name
*/
public static String toJavaTypeName(
@Nonnull String className,
@Nullable String enclosingClassName,
@Nullable String javaPackage) {
Preconditions.checkNotNull(className, "className");
Joiner dotJoiner = Joiner.on('.').skipNulls();
return dotJoiner.join(javaPackage, enclosingClassName, className);
}
示例6: prefixAndJoin
import com.google.common.base.Joiner; //导入方法依赖的package包/类
/**
* @param list of strings to be joined by ','
* @param prefix e.g. 'extends' or 'implements'
*/
public static String prefixAndJoin(final List<FullyQualifiedName> list, final String prefix) {
if (list.isEmpty()) {
return "";
}
Joiner joiner = Joiner.on(",");
return " " + prefix + " " + joiner.join(list);
}
示例7: format
import com.google.common.base.Joiner; //导入方法依赖的package包/类
private String format(String pattern, String value) {
Splitter splitter = Splitter.on("%1$s");
Joiner joiner = Joiner.on(value);
return joiner.join(splitter.split(pattern));
}
示例8: combineCoalesceSets
import com.google.common.base.Joiner; //导入方法依赖的package包/类
private static String combineCoalesceSets(Set<String> coalesceSets) {
Joiner joiner = Joiner.on(", ").skipNulls();
return joiner.join(coalesceSets);
}
示例9: ActiveAppBeacon
import com.google.common.base.Joiner; //导入方法依赖的package包/类
public ActiveAppBeacon(Collection<Integer> ports, final String pingMessage) {
this.pingMessage = pingMessage;
for (Integer p : ports) {
// Check that port is unused and use first available port
if (available(p)) {
try {
serverSocket = new ServerSocket(p);
break;
}
catch (IOException e) {
log.info("Unable to open port {}", p);
}
}
}
if (serverSocket == null) {
ok = false;
Joiner joiner = Joiner.on(", ").skipNulls();
String portMsg = joiner.join(ports);
beaconThread = null;
log.warn("Failed to activate a ServerSocket for ActiveAppBeacon on any of the following ports: " + portMsg);
}
else {
final ServerSocket s = serverSocket;
beaconThread = new Thread(() -> {
while (ok) {
try {
Socket socket = s.accept();
Writer writer = new OutputStreamWriter(socket.getOutputStream());
writer.write(pingMessage + "\n");
writer.flush();
socket.close();
}
catch (IOException e) {
// do nothing
}
}
});
beaconThread.setDaemon(true);
beaconThread.start();
}
}
示例10: scanSchema
import com.google.common.base.Joiner; //导入方法依赖的package包/类
/**
* Scan the schame tree, invoking the visitor as appropriate.
* @param rootSchema the given schema
*/
public void scanSchema(SchemaPlus rootSchema) {
if (!shouldVisitCatalog() || !visitCatalog()) {
return;
}
// Visit this schema and if requested ...
for (String subSchemaName: rootSchema.getSubSchemaNames()) {
final SchemaPlus firstLevelSchema = rootSchema.getSubSchema(subSchemaName);
if (shouldVisitSchema(subSchemaName, firstLevelSchema) && visitSchema(subSchemaName, firstLevelSchema)) {
final AbstractSchema schemaInstance;
try{
schemaInstance = (AbstractSchema) firstLevelSchema.unwrap(AbstractSchema.class).getDefaultSchema();
}catch(Exception ex){
logger.warn("Failure reading schema {}. Skipping inclusion in INFORMATION_SCHEMA.", subSchemaName, ex);
continue;
}
// ... do for each of the schema's tables.
for (String tableName : firstLevelSchema.getTableNames()) {
try {
final TableInfo tableInfo = schemaInstance.getTableInfo(tableName);
if (tableInfo == null) {
// Schema may return NULL for table if the query user doesn't have permissions to load the table. Ignore such
// tables as INFO SCHEMA is about showing tables which the user has access to query.
continue;
}
final Table table;
if (tableInfo.getTable() == null) {
table = schemaInstance.getTable(tableName);
} else {
table = tableInfo.getTable();
}
final TableType tableType = table.getJdbcTableType();
// Visit the table, and if requested ...
if (shouldVisitTable(subSchemaName, tableName, tableType) && visitTable(subSchemaName, tableName, tableInfo)) {
// ... do for each of the table's fields.
RelDataType tableRow = table.getRowType(new JavaTypeFactoryImpl());
for (RelDataTypeField field : tableRow.getFieldList()) {
if (shouldVisitColumn(subSchemaName, tableName, field.getName())) {
visitField(subSchemaName, tableName, field);
}
}
}
} catch (Exception e) {
Joiner joiner = Joiner.on('.');
String path = joiner.join(joiner.join(firstLevelSchema.getTableNames()), tableName);
logger.warn("Failure while trying to read schema for table {}. Skipping inclusion in INFORMATION_SCHEMA.", path, e);;
continue;
}
}
}
}
}
示例11: join
import com.google.common.base.Joiner; //导入方法依赖的package包/类
/**
* 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);
}