本文整理汇总了Java中com.google.common.base.Strings.padEnd方法的典型用法代码示例。如果您正苦于以下问题:Java Strings.padEnd方法的具体用法?Java Strings.padEnd怎么用?Java Strings.padEnd使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.common.base.Strings
的用法示例。
在下文中一共展示了Strings.padEnd方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createWordsPermutation
import com.google.common.base.Strings; //导入方法依赖的package包/类
private LinkedList<String> createWordsPermutation(List<String> words, int i, Ending ending) {
LinkedList<String> currPermutation = Lists.newLinkedList(words);
for (int k = 0; k < i; k++) {
if (ending == Ending.HEAD || ending == Ending.BOTH) {
String currHeadPwd = Strings.padEnd(HEAD_ELEMENT, i - k, HEAD_ELEMENT.charAt(0));
currPermutation.push(currHeadPwd);
}
if (ending == Ending.TAIL || ending == Ending.BOTH) {
String currTailPwd = Strings.padEnd(TAIL_ELEMENT, k, TAIL_ELEMENT.charAt(0));
currPermutation.add(currTailPwd);
}
}
return currPermutation;
}
示例2: testNicknameUI
import com.google.common.base.Strings; //导入方法依赖的package包/类
@Test
public void testNicknameUI() {
Assert.assertNotNull(setupActivity);
String longNick =
Strings.padEnd("*", AuthorConstants.MAX_AUTHOR_NAME_LENGTH + 1,
'*');
nicknameEntry.setText(longNick);
// Nickname should be too long
assertEquals(nicknameEntryWrapper.getError(),
setupActivity.getString(R.string.name_too_long));
}
示例3: attributeLabel
import com.google.common.base.Strings; //导入方法依赖的package包/类
private String attributeLabel(String label) {
return Strings.padEnd(label, LABEL_LENGTH, ' ');
}
示例4: toString
import com.google.common.base.Strings; //导入方法依赖的package包/类
@Override
public String toString() {
return ucteCountryCode.getUcteCode() + Strings.padEnd(geographicalSpot, 5, ' ') + voltageLevelCode.ordinal() + (busbar != null ? busbar : ' ');
}
示例5: sendModuleSummary
import com.google.common.base.Strings; //导入方法依赖的package包/类
/**
* Sends a module summary (similar to the Maven Reactor Summary)
*/
public void sendModuleSummary() {
if(logger == null) return;
List<String> summaryMessages = new ArrayList<>();
summaryMessages.add(Strings.repeat("-", 75));
summaryMessages.add("Module Summary: ");
summaryMessages.add(" ");
// for averages
double successCount = 0;
double totalTime = 0;
for(Module m : getModules()) {
String name = Strings.padEnd(m.getName() + " ", 25, '.');
String state = (m.isEnabled() ? ConsoleColor.GREEN + "SUCCESS" : ConsoleColor.RED + "FAILURE") + ConsoleColor.RESET;
double time = (double) m.getEnableTime() / 1000;
// averages
if(m.isEnabled()) successCount++;
totalTime += time;
String timeString = "[ " + Strings.padStart(StringUtil.applyDecimalLength(time, 3), 6, ' ') + " s]";
String error = m.isEnabled() ? "" : " (" + (m.getErrorReason() != null ? m.getErrorReason().getClass().getSimpleName() : "Not Enabled") + ")";
summaryMessages.add(name + " " + state + " " + timeString + error);
}
summaryMessages.add(" ");
String totalTimeString = NumberUtil.round(totalTime, 4);
summaryMessages.add("Total time: " + totalTimeString + "s");
// success
double successRate = successCount / getModules().size() * 100;
String successRateString = (successRate <= 25 ? ConsoleColor.DARK_RED
: successRate <= 50 ? ConsoleColor.RED
: successRate <= 75 ? ConsoleColor.GOLD
: successRate <= 99 ? ConsoleColor.YELLOW
: ConsoleColor.GREEN
) + NumberUtil.round(successRate, 4) + "%" + ConsoleColor.RESET;
// time and footer
String averageTimeString = NumberUtil.round(totalTime / getModules().size(), 4);
summaryMessages.add("Success rate: " + successRateString + " | Average time: " + averageTimeString + "s");
summaryMessages.add(Strings.repeat("-", 75));
// send all messages
summaryMessages.forEach(s -> logger.info(s));
}
示例6: paddedLevelName
import com.google.common.base.Strings; //导入方法依赖的package包/类
private static String paddedLevelName(Level level) {
return Logging.levelColor(level) + Strings.padEnd(levelName(level), 6, ' ') + ChatColor.RESET;
}