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


Java Joiner类代码示例

本文整理汇总了Java中com.google.common.base.Joiner的典型用法代码示例。如果您正苦于以下问题:Java Joiner类的具体用法?Java Joiner怎么用?Java Joiner使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Joiner类属于com.google.common.base包,在下文中一共展示了Joiner类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: findRelativePath

import com.google.common.base.Joiner; //导入依赖的package包/类
private String findRelativePath(String from, String to) {
    List<String> fromPath = splitPath(from);
    List<String> toPath = splitPath(to);
    List<String> relativePath = new ArrayList<String>();

    while (!fromPath.isEmpty() && !toPath.isEmpty() && fromPath.get(0).equals(toPath.get(0))) {
        fromPath.remove(0);
        toPath.remove(0);
    }
    for (String ignored : fromPath) {
        relativePath.add("..");
    }
    for (String entry : toPath) {
        relativePath.add(entry);
    }
    return Joiner.on(File.separatorChar).join(relativePath);
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:18,代码来源:RelativeFileNameTransformer.java

示例2: print

import com.google.common.base.Joiner; //导入依赖的package包/类
/**
 * Print a key vault.
 *
 * @param vault the key vault resource
 */
public static void print(Vault vault) {
    StringBuilder info = new StringBuilder().append("Key Vault: ").append(vault.id())
            .append("Name: ").append(vault.name())
            .append("\n\tResource group: ").append(vault.resourceGroupName())
            .append("\n\tRegion: ").append(vault.region())
            .append("\n\tSku: ").append(vault.sku().name()).append(" - ").append(vault.sku().family())
            .append("\n\tVault URI: ").append(vault.vaultUri())
            .append("\n\tAccess policies: ");
    for (AccessPolicy accessPolicy : vault.accessPolicies()) {
        info.append("\n\t\tIdentity:").append(accessPolicy.objectId())
                .append("\n\t\tKey permissions: ").append(Joiner.on(", ").join(accessPolicy.permissions().keys()))
                .append("\n\t\tSecret permissions: ").append(Joiner.on(", ").join(accessPolicy.permissions().secrets()));
    }
    System.out.println(info.toString());
}
 
开发者ID:Azure-Samples,项目名称:app-service-java-manage-functions,代码行数:21,代码来源:Utils.java

示例3: testSQLite

import com.google.common.base.Joiner; //导入依赖的package包/类
@Test
public void testSQLite() throws IOException {
  File yaml = new File("test-files/testScript/cmakeify.yml");
  yaml.getParentFile().mkdirs();
  Files.write("targets: [android]\n" +
          "buildTarget: sqlite\n" +
          "android:\n" +
          "  ndk:\n" +
          "    runtimes: [c++, gnustl, stlport]\n" +
          "    platforms: [12, 21]\n" +
          "example: |\n" +
          "   #include <sqlite3.h>\n" +
          "   void test() {\n" +
          "     sqlite3_initialize();\n" +
          "   }",
      yaml, StandardCharsets.UTF_8);
  main("-wf", yaml.getParent(),
      "--host", "Linux",
      "--group-id", "my-group-id",
      "--artifact-id", "my-artifact-id",
      "--target-version", "my-target-version");
  File scriptFile = new File(".cmakeify/build.sh");
  String script = Joiner.on("\n").join(Files.readLines(scriptFile, Charsets.UTF_8));
  assertThat(script).contains("cmake-3.7.2-Linux-x86_64.tar.gz");
}
 
开发者ID:jomof,项目名称:cmakeify,代码行数:26,代码来源:TestCmakeify.java

示例4: filterMatching

import com.google.common.base.Joiner; //导入依赖的package包/类
@Override
public Result filterMatching(List<String> lines) {
    List<String> mismatches = new ArrayList<>();
    List<String> remainingLines = new ArrayList<>(lines);
    boolean matches = remainingLines.remove(dependencyDescription + ":");
    if (!matches) {
        mismatches.add("Description " + dependencyDescription + " was missing");
    }
    for (ExpectedAccess expectedAccess : expectedAccesses) {
        if (!remainingLines.remove(expectedAccess.toString())) {
            mismatches.add("Expected Access " + expectedAccess.toString() + " was missing");
            matches = false;
        }
    }
    if (!matches) {
        return new Result(false, lines, Joiner.on(System.lineSeparator()).join(mismatches));
    }
    return new Result(true, remainingLines);
}
 
开发者ID:TNG,项目名称:ArchUnit,代码行数:20,代码来源:SliceDependencyErrorMatcher.java

示例5: loadFirst

import com.google.common.base.Joiner; //导入依赖的package包/类
/**
 * Load configuration from a list of files until the first successful load
 * @param conf  the configuration object
 * @param files the list of filenames to try
 * @return  the configuration object
 */
static MetricsConfig loadFirst(String prefix, String... fileNames) {
  for (String fname : fileNames) {
    try {
      Configuration cf = new PropertiesConfiguration(fname)
          .interpolatedConfiguration();
      LOG.info("loaded properties from "+ fname);
      LOG.debug(toString(cf));
      MetricsConfig mc = new MetricsConfig(cf, prefix);
      LOG.debug(mc);
      return mc;
    }
    catch (ConfigurationException e) {
      if (e.getMessage().startsWith("Cannot locate configuration")) {
        continue;
      }
      throw new MetricsConfigException(e);
    }
  }
  LOG.warn("Cannot locate configuration: tried "+
           Joiner.on(",").join(fileNames));
  // default to an empty configuration
  return new MetricsConfig(new PropertiesConfiguration(), prefix);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:30,代码来源:MetricsConfig.java

示例6: run

import com.google.common.base.Joiner; //导入依赖的package包/类
@Override
public int run(Configuration conf, List<String> args) throws IOException {
  String name = StringUtils.popFirstNonOption(args);
  if (name == null) {
    System.err.println("You must specify a name when deleting a " +
        "cache pool.");
    return 1;
  }
  if (!args.isEmpty()) {
    System.err.print("Can't understand arguments: " +
      Joiner.on(" ").join(args) + "\n");
    System.err.println("Usage is " + getShortUsage());
    return 1;
  }
  DistributedFileSystem dfs = AdminHelper.getDFS(conf);
  try {
    dfs.removeCachePool(name);
  } catch (IOException e) {
    System.err.println(AdminHelper.prettifyException(e));
    return 2;
  }
  System.out.println("Successfully removed cache pool " + name + ".");
  return 0;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:25,代码来源:CacheAdmin.java

示例7: checkMetadataConsistency

import com.google.common.base.Joiner; //导入依赖的package包/类
protected void checkMetadataConsistency(ModuleComponentIdentifier expectedId, MutableModuleComponentResolveMetadata metadata) throws MetaDataParseException {
    List<String> errors = new ArrayList<String>();
    if (!expectedId.getGroup().equals(metadata.getId().getGroup())) {
        errors.add("bad group: expected='" + expectedId.getGroup() + "' found='" + metadata.getId().getGroup() + "'");
    }
    if (!expectedId.getModule().equals(metadata.getId().getName())) {
        errors.add("bad module name: expected='" + expectedId.getModule() + "' found='" + metadata.getId().getName() + "'");
    }
    if (!expectedId.getVersion().equals(metadata.getId().getVersion())) {
        errors.add("bad version: expected='" + expectedId.getVersion() + "' found='" + metadata.getId().getVersion() + "'");
    }
    if (errors.size() > 0) {
        throw new MetaDataParseException(String.format("inconsistent module metadata found. Descriptor: %s Errors: %s",
            metadata.getId(), Joiner.on(SystemProperties.getInstance().getLineSeparator()).join(errors)));
    }
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:17,代码来源:ExternalResourceResolver.java

示例8: visitSimpleCaseExpression

import com.google.common.base.Joiner; //导入依赖的package包/类
@Override
protected String visitSimpleCaseExpression(SimpleCaseExpression node, Void context)
{
    ImmutableList.Builder<String> parts = ImmutableList.builder();

    parts.add("CASE").add(process(node.getOperand(), context));

    for (WhenClause whenClause : node.getWhenClauses()) {
        parts.add(process(whenClause, context));
    }
    if (node.getDefaultValue() != null) {
        parts.add("ELSE").add(process(node.getDefaultValue(), context));
    }
    parts.add("END");

    return "(" + Joiner.on(' ').join(parts.build()) + ")";
}
 
开发者ID:ajoabraham,项目名称:hue,代码行数:18,代码来源:VeroGenExpFormatter.java

示例9: isValid

import com.google.common.base.Joiner; //导入依赖的package包/类
@Override
public boolean isValid(String value, ConstraintValidatorContext context) {
    if (value == null) {
        return true;
    }
    final boolean valid = Arrays.asList(strings).contains(value);

    if (!valid) {
        HibernateConstraintValidatorContext hibernateContext = context.unwrap(HibernateConstraintValidatorContext.class);
        hibernateContext.disableDefaultConstraintViolation();

        hibernateContext.addExpressionVariable("validValues", Joiner.on(" ").join(strings))
                .buildConstraintViolationWithTemplate(hibernateContext.getDefaultConstraintMessageTemplate())
                .addConstraintViolation();
    }

    return valid;
}
 
开发者ID:DevOpsStudio,项目名称:Re-Collector,代码行数:19,代码来源:IsOneOfValidator.java

示例10: loadManifest

import com.google.common.base.Joiner; //导入依赖的package包/类
protected ProjectDescription loadManifest(URI manifest) {
	ResourceSet resourceSet = resourceSetProvider.get();
	Resource resource = resourceSet.getResource(manifest, true);
	List<EObject> contents = resource.getContents();
	if (contents.isEmpty() || !(contents.get(0) instanceof ProjectDescription)) {
		return null;
	}
	// do some error handling:
	if (!resource.getErrors().isEmpty()) {
		throw new N4JSBrokenProjectException("Reading project description from "
				+ manifest
				+ " raised the following errors: "
				+ Joiner.on('\n').join(
						resource.getErrors().stream().map(
								error -> error.getMessage() + "  at line " + error.getLine())
								.iterator()));
	}
	ProjectDescription result = (ProjectDescription) contents.get(0);
	contents.clear();
	return result;
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:22,代码来源:LazyProjectDescriptionHandle.java

示例11: testCreateFunction

import com.google.common.base.Joiner; //导入依赖的package包/类
@Test
public void testCreateFunction() throws IOException, ParseException {
  String sql = Joiner.on(";\n").join(
      "CREATE FUNCTION udf AS 'foo.udf'",
      "CREATE FUNCTION udf1 AS 'foo.udf' USING JAR 'mock://foo'",
      "CREATE FUNCTION udf2 AS 'foo.udf' USING JAR 'mock://foo', JAR 'mock://bar'"
  );
  SqlNodeList nodes = Planner.parse(sql);
  Validator validator = new Validator();
  validator.extract(nodes);
  assertEquals(ImmutableList.of(
      URI.create("mock://foo"),
      URI.create("mock://foo"),
      URI.create("mock://bar")
  ), ImmutableList.copyOf(validator.additionalResources()));
}
 
开发者ID:uber,项目名称:AthenaX,代码行数:17,代码来源:ValidatorTest.java

示例12: checkResult

import com.google.common.base.Joiner; //导入依赖的package包/类
/**
 * Check result.
 * @param question - question
 * @param answer - answer
 */
private void checkResult(String question, String answer) {
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    System.setOut(new PrintStream(out));

    Menu menu = new Menu();
    menu.show();
    menu.select(question);

    String target = Joiner.on(System.getProperty("line.separator")).join("1: Date And Time",
            "  1.1: Date",
            "    1.1.1: Day Of the Week",
            "    1.1.2: Month",
            "  1.2: Time",
            answer) + System.getProperty("line.separator");

    assertThat(out.toString(), is(target));
}
 
开发者ID:istolbov,项目名称:i_stolbov,代码行数:23,代码来源:MenuTest.java

示例13: getClassObfMap

import com.google.common.base.Joiner; //导入依赖的package包/类
private Map<String, String> getClassObfMap(GradleVariantConfiguration config) {
    Map<String, String> classMap = new HashMap<String, String>();
    boolean isMinifyEnabled = config.isMinifyEnabled();
    File proguardOut = new File(Joiner.on(File.separatorChar).join(
        String.valueOf(appVariantContext.getScope().getGlobalScope().getBuildDir()), FD_OUTPUTS, "mapping",
        appVariantContext.getScope().getVariantConfiguration().getDirName()));
    File mappingFile = new File(proguardOut, "mapping.txt");
    // Parse the mapping file to generate the new mainDexListFile
    if (isMinifyEnabled && mappingFile.exists()) {
        MappingReader mappingReader = new MappingReader(mappingFile);
        MappingReaderProcess process = new MappingReaderProcess();
        try {
            mappingReader.pump(process);
        } catch (IOException e) {
            throw new GradleException(e.getMessage(), e);
        }
        classMap = process.classMapping;
    }
    return classMap;
}
 
开发者ID:alibaba,项目名称:atlas,代码行数:21,代码来源:MainDexLister.java

示例14: explainTerms

import com.google.common.base.Joiner; //导入依赖的package包/类
@Override
public RelWriter explainTerms(RelWriter pw) {
  pw.item("table", tableMetadata.getName());
  if(projectedColumns != null){
    pw.item("columns", FluentIterable.from(projectedColumns).transform(new Function<SchemaPath, String>(){

      @Override
      public String apply(SchemaPath input) {
        return input.toString();
      }}).join(Joiner.on(", ")));
  }

  pw.item("splits", getTableMetadata().getSplitCount());

  if(observedRowcountAdjustment != 1.0d){
    pw.item("rowAdjust", observedRowcountAdjustment);
  }

  return pw;
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:21,代码来源:ScanRelBase.java

示例15: toChangeCallSql

import com.google.common.base.Joiner; //导入依赖的package包/类
public String toChangeCallSql(String dbType) {
    StringBuilder sb = new StringBuilder();
    sb.append("call ");
    sb.append(this.getName()).append("(");
    Collection<ProcedureParameter> parameters = this.getParameterMap().values();
    int j = 0;
    for (ProcedureParameter parameter : parameters) {
        Object value = parameter.getValue() != null && Types.VARCHAR == parameter.getJdbcType() ? "'" + parameter.getValue() + "'" : parameter.getValue();
        String strParameter = parameter.getValue() == null ? parameter.getName() : String.valueOf(value);
        String joinStr = j == this.getParameterMap().size() - 1 ? strParameter : strParameter + ",";
        sb.append(joinStr);
        j++;
    }
    sb.append(")");
    if (isResultSimpleValue()) {
        sb.append(";select ");
        sb.append(Joiner.on(",").join(selectColumns));
    }
    return sb.toString();
}
 
开发者ID:actiontech,项目名称:dble,代码行数:21,代码来源:Procedure.java


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