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


Java StringJoiner.add方法代码示例

本文整理汇总了Java中java.util.StringJoiner.add方法的典型用法代码示例。如果您正苦于以下问题:Java StringJoiner.add方法的具体用法?Java StringJoiner.add怎么用?Java StringJoiner.add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.util.StringJoiner的用法示例。


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

示例1: asString

import java.util.StringJoiner; //导入方法依赖的package包/类
public String asString() {
    StringJoiner resultLineJointer = new StringJoiner("\n");
    resultLineJointer.add("public static final class " + className + " {");
    resultLineJointer.add("\tprivate final " + classType + " " + nameValue + ";");
    resultLineJointer.add("\tpublic " + classType + " get() {");
    resultLineJointer.add("\t\treturn " + nameValue + ";");
    resultLineJointer.add("\t}");
    resultLineJointer.add("\tpublic " + className + "(" + classType + " " + nameValue + ") {");
    resultLineJointer.add("\t\tthis." + nameValue + " = " + nameValue + ";");
    resultLineJointer.add("\t}");
    resultLineJointer.add(createToString());
    resultLineJointer.add(createOfMethode());
    resultLineJointer.add(createEqualsAndHash());
    resultLineJointer.add("}");
    String s = resultLineJointer.toString();
    return s;
}
 
开发者ID:Ingwersaft,项目名称:ValueClassGenerator,代码行数:18,代码来源:ValueSubClass.java

示例2: getFileContents

import java.util.StringJoiner; //导入方法依赖的package包/类
/**
 * Reads a file into a single string, preserving line breaks.
 * <p>
 * All line breaks will be replaced with the newline character (\n) regardless of
 * whether or not the file uses windows convention or not (\n\r)
 * 
 * @param path
 *            Path to the file that will be read
 * @return The contents of the specified file, as a String
 */
private static String getFileContents(Path path)
{
	try
	{
		List<String> fileLines = Files.readAllLines(path);
		StringJoiner fileJoiner = new StringJoiner("\n");
		
		for (String line : fileLines)
			fileJoiner.add(line);
		
		return fileJoiner.toString();
	}
	catch (Exception e)
	{
		e.printStackTrace();
		return null;
	}
}
 
开发者ID:dhawal9035,项目名称:WebPLP,代码行数:29,代码来源:AssembleConsole.java

示例3: toString

import java.util.StringJoiner; //导入方法依赖的package包/类
public String toString() {
    StringBuilder sb = new StringBuilder();

    if (ownerType != null) {
        sb.append(ownerType.getTypeName());

        sb.append("$");

        if (ownerType instanceof ParameterizedTypeImpl) {
            // Find simple name of nested type by removing the
            // shared prefix with owner.
            sb.append(rawType.getName().replace( ((ParameterizedTypeImpl)ownerType).rawType.getName() + "$",
                                     ""));
        } else
           sb.append(rawType.getSimpleName());
    } else
        sb.append(rawType.getName());

    if (actualTypeArguments != null) {
        StringJoiner sj = new StringJoiner(", ", "<", ">");
        sj.setEmptyValue("");
        for(Type t: actualTypeArguments) {
            sj.add(t.getTypeName());
        }
        sb.append(sj.toString());
    }

    return sb.toString();
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:30,代码来源:ParameterizedTypeImpl.java

示例4: join

import java.util.StringJoiner; //导入方法依赖的package包/类
/**
 * java 8 新增方法 String join(CharSequence delimiter, Iterable<? extends CharSequence> elements)
 * @param delimiter
 * @param elements
 * @return
 */
public static String join(CharSequence delimiter,
                          Iterable<? extends CharSequence> elements) {
    Objects.requireNonNull(delimiter);
    Objects.requireNonNull(elements);
    StringJoiner joiner = new StringJoiner(delimiter);
    for (CharSequence cs: elements) {
        joiner.add(cs);
    }
    return joiner.toString();
}
 
开发者ID:laidu,项目名称:java-learn,代码行数:17,代码来源:StringPartMethod.java

示例5: toString

import java.util.StringJoiner; //导入方法依赖的package包/类
@Override
public String toString() {
    StringJoiner result = new StringJoiner(System.lineSeparator());

    result.add(Arrays.toString(columnNames));

    for (Object[] objects : tuples) {
        result.add(Arrays.stream(objects).map(String::valueOf).collect(
            Collectors.joining(", ")));
    }

    return result.toString() + getExecutionTimeString();
}
 
开发者ID:graphflow,项目名称:graphflow,代码行数:14,代码来源:Tuples.java

示例6: toShortString

import java.util.StringJoiner; //导入方法依赖的package包/类
@Override
String toShortString() {
    StringBuilder sb = new StringBuilder("method ");
    sb.append(getDeclaringClass().getTypeName()).append('.');
    sb.append(getName());
    sb.append('(');
    StringJoiner sj = new StringJoiner(",");
    for (Class<?> parameterType : getParameterTypes()) {
        sj.add(parameterType.getTypeName());
    }
    sb.append(sj);
    sb.append(')');
    return sb.toString();
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:15,代码来源:Method.java

示例7: SaslPeer

import java.util.StringJoiner; //导入方法依赖的package包/类
SaslPeer(String host, String mechanism, String authId, String... qops) {
    this.host = host;
    this.mechanism = mechanism;

    StringJoiner sj = new StringJoiner(",");
    for (String q : qops) {
        sj.add(q);
    }
    qop = sj.toString();

    callback = new TestCallbackHandler(USER_ID, PASSWD, host, authId);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:13,代码来源:ClientServerTest.java

示例8: toString

import java.util.StringJoiner; //导入方法依赖的package包/类
@Override
public String toString() {
    StringJoiner sj = new StringJoiner("\n", "policy: ", "");
    Enumeration<Permission> perms = permissions.elements();
    while (perms.hasMoreElements()) {
        sj.add(perms.nextElement().toString());
    }
    return sj.toString();

}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:11,代码来源:TestPolicy.java

示例9: getUsageTexts

import java.util.StringJoiner; //导入方法依赖的package包/类
private String getUsageTexts(DiscordBot bot, String prefix) {
    StringJoiner joiner = new StringJoiner("\n");
    HashMap<String, Command> commandList = bot.getCommands();

    for (Command command: commandList.values()) {
        joiner.add(DiscordUtils.getUsageString(prefix, command.getUsages()));
    }

    return joiner.toString();
}
 
开发者ID:Samoxive,项目名称:SafetyJim,代码行数:11,代码来源:Help.java

示例10: getFile

import java.util.StringJoiner; //导入方法依赖的package包/类
public static String getFile(Path path)
        throws IOException
{
    String line;
    StringJoiner stringJoiner = new StringJoiner("\n");
    try (BufferedReader bufferedReader = new BufferedReader(new FileReader(path.toString()))) {
        while ((line = bufferedReader.readLine()) != null) {
            stringJoiner.add(line);
        }
    }
    return stringJoiner.toString();
}
 
开发者ID:prestodb,项目名称:presto-manager,代码行数:13,代码来源:AgentFileUtils.java

示例11: toString

import java.util.StringJoiner; //导入方法依赖的package包/类
public String toString() {
    if (assertion.length == 1) {
        return assertion[0].toString();
    }

    StringJoiner sj = new StringJoiner(" + ");
    for (int i = 0; i < assertion.length; i++) {
        sj.add(assertion[i].toString());
    }
    return sj.toString();
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:12,代码来源:RDN.java

示例12: toString

import java.util.StringJoiner; //导入方法依赖的package包/类
@Override
public String toString() {
    String causeString = "Origin[";
    StringJoiner joiner = new StringJoiner(", ");
    for (int i = 0; i < this.origin.length; i++) {
        joiner.add("{Name=" + this.names[i] + ", Object={" + this.origin[i].toString() + "}}");
    }
    return causeString + joiner.toString() + "]";
}
 
开发者ID:ichorpowered,项目名称:guardianapi,代码行数:10,代码来源:Origin.java

示例13: setSelectedExchangeCurrencyPairs

import java.util.StringJoiner; //导入方法依赖的package包/类
@Transient
public void setSelectedExchangeCurrencyPairs(Set<SelectedExchangeCurrencyPair> selectedExchangeCurrencyPairs) {
    this.selectedExchangeCurrencyPairs = selectedExchangeCurrencyPairs;
    for (SelectedExchangeCurrencyPair selectedExchangeCurrencyPair : selectedExchangeCurrencyPairs) {
        StringJoiner stringJoiner = new StringJoiner(",");
        for (CurrencyPair currencyPair : selectedExchangeCurrencyPair.getCurrencyPairList()) {
            stringJoiner.add(currencyPair.toString());
        }
        if (StringUtils.isNotBlank(stringJoiner.toString())) {
            currencyPairByExchangeMap.put(selectedExchangeCurrencyPair.getExchangeName(), stringJoiner.toString());
        }
    }
}
 
开发者ID:semihunaldi,项目名称:IdeaCurrency,代码行数:14,代码来源:IdeaCurrencyConfig.java

示例14: getTraceString

import java.util.StringJoiner; //导入方法依赖的package包/类
public static String getTraceString(StackTraceElement[] stackTraceElements)
{
	final StringJoiner sj = new StringJoiner(Config.EOL);
	for (StackTraceElement stackTraceElement : stackTraceElements)
	{
		sj.add(stackTraceElement.toString());
	}
	return sj.toString();
}
 
开发者ID:rubenswagner,项目名称:L2J-Global,代码行数:10,代码来源:CommonUtil.java

示例15: toString

import java.util.StringJoiner; //导入方法依赖的package包/类
@Override
public String toString() {
    final StringJoiner sj = new StringJoiner(", ", "{ ", " }");
    sj.add("seqNo = "      + Objects.toString(getSeqNo()));
    sj.add("version = "    + Objects.toString(getVersion()));
    sj.add("type = "       + Objects.toString(getType()));
    sj.add("bookingId = "  + Objects.toString(getBookingId()));
    sj.add("userId = "     + Objects.toString(getUserId()));
    sj.add("resourceId = " + Objects.toString(getResourceId()));
    sj.add("bookFrom = "   + Objects.toString(OptionalUtil.unwrap(getBookFrom())));
    sj.add("bookTo = "     + Objects.toString(OptionalUtil.unwrap(getBookTo())));
    return "BookingEventImpl " + sj.toString();
}
 
开发者ID:speedment,项目名称:eventsourcing-examples,代码行数:14,代码来源:GeneratedBookingEventImpl.java


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