本文整理汇总了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;
}
示例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;
}
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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);
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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() + "]";
}
示例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());
}
}
}
示例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();
}
示例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();
}