当前位置: 首页>>代码示例>>Java>>正文


Java Joiner.join方法代码示例

本文整理汇总了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);
	}
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:32,代码来源:ProjectUtils.java

示例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();
}
 
开发者ID:drakeet,项目名称:rebase-server,代码行数:13,代码来源:ConstraintViolationExceptionMapper.java

示例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);
}
 
开发者ID:ajoabraham,项目名称:hue,代码行数:11,代码来源:TreePatcher.java

示例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;
}
 
开发者ID:moueimei,项目名称:flume-release-1.7.0,代码行数:34,代码来源:EncryptionTestUtils.java

示例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);
}
 
开发者ID:salesforce,项目名称:grpc-java-contrib,代码行数:18,代码来源:ProtoTypeMap.java

示例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);
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:12,代码来源:StringUtil.java

示例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));
}
 
开发者ID:YoungDigitalPlanet,项目名称:empiria.player,代码行数:6,代码来源:ContentFieldInfo.java

示例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);
}
 
开发者ID:ajoabraham,项目名称:hue,代码行数:6,代码来源:TreePatcher.java

示例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();
    }
}
 
开发者ID:mbari-media-management,项目名称:vars-annotation,代码行数:44,代码来源:ActiveAppBeacon.java

示例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;
        }

      }
    }
  }
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:62,代码来源:InfoSchemaRecordGenerator.java

示例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);
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:15,代码来源:FluentIterable.java


注:本文中的com.google.common.base.Joiner.join方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。