當前位置: 首頁>>代碼示例>>Java>>正文


Java Chars.asList方法代碼示例

本文整理匯總了Java中com.google.common.primitives.Chars.asList方法的典型用法代碼示例。如果您正苦於以下問題:Java Chars.asList方法的具體用法?Java Chars.asList怎麽用?Java Chars.asList使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.google.common.primitives.Chars的用法示例。


在下文中一共展示了Chars.asList方法的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: filter

import com.google.common.primitives.Chars; //導入方法依賴的package包/類
@Override
public Object filter(Object var, JinjavaInterpreter interpreter, String... args) {
  List<?> result;

  if (var instanceof String) {
    result = Chars.asList(((String) var).toCharArray());
  }

  else if (Collection.class.isAssignableFrom(var.getClass())) {
    result = Lists.newArrayList((Collection<?>) var);
  }

  else {
    result = Lists.newArrayList(var);
  }

  return result;
}
 
開發者ID:HubSpot,項目名稱:jinjava,代碼行數:19,代碼來源:ListFilter.java

示例2: split

import com.google.common.primitives.Chars; //導入方法依賴的package包/類
/**
 * Split iterable.
 *
 * @param str        the str
 * @param separators the separators
 * @return the iterable
 */
public static Iterable<String> split(final String str, final char... separators) {
    if (isEmpty(str))
        return Lists.newArrayList();

    List<String> result = Lists.newArrayList();
    List<Character> seps = Chars.asList(separators);

    int length = str.length();
    int startIndex = 0;
    for (int i = 0; i < length; i++) {
        if (seps.contains(str.charAt(i))) {
            if (i - 1 - startIndex > 0) {
                result.add(str.substring(startIndex, i - 1));
            }
            startIndex = i + 1;
        }
    }

    return result;
}
 
開發者ID:debop,項目名稱:debop4j,代碼行數:28,代碼來源:StringTool.java

示例3: testSanitizesRegularProperty

import com.google.common.primitives.Chars; //導入方法依賴的package包/類
public void testSanitizesRegularProperty() {
  // Test boundaries.
  char[] boundaryChars = {/* '/' is allowed */ ':', '@', '[', '`', '{'};
  for (Character c : Chars.asList(boundaryChars)) {
    assertBackgroundSizeStringSanitized(c.toString());
  }

  // Empty strings.
  assertBackgroundSizeStringSanitized("");
  assertBackgroundSizeStringSanitized(" ");
  assertBackgroundSizeStringSanitized("\t");
  // Unlike jslayout, comma is not allowed.
  assertBackgroundSizeStringSanitized(",");
  // Non-whitelisted characters.
  assertBackgroundSizeStringSanitized(";");
  // Function call characters.
  assertBackgroundSizeStringSanitized("(");
  assertBackgroundSizeStringSanitized(")");
  assertBackgroundSizeStringSanitized("calc()");
  // Newlines.
  assertBackgroundSizeStringSanitized("\n");
  assertBackgroundSizeStringSanitized("\r");
  // Comments.
  assertBackgroundSizeStringSanitized("foo /*");
  assertBackgroundSizeStringSanitized("foo //foo");
  // Escape sequences.
  assertBackgroundSizeStringSanitized("\\ff ");
}
 
開發者ID:google,項目名稱:safe-html-types,代碼行數:29,代碼來源:SafeStyleBuilderTest.java

示例4: replace

import com.google.common.primitives.Chars; //導入方法依賴的package包/類
/**
 * Replaces all values in the input with the corresponding values from the {@link ArenaScoreboard#replacements}
 *
 * @param input the input string
 * @param player the player
 * @return the new string
 * @since 5.3.0
 */
@NotNull
@Contract(value = "null, _ -> fail", pure = true)
private String replace(String input, Player player) {
    List<Character> list = new ArrayList<>(Chars.asList(input.toCharArray()));
    Matcher matcher = Pattern.compile("%([^%]+)%").matcher(input);

    while (matcher.find()) {
        for (int i = matcher.start(); i < matcher.end(); i++)
            list.remove(matcher.start());

        Function<Player, String> function = replacements.get(matcher.group(1));

        if (function == null)
            continue;

        char[] replacement = function.apply(player).toCharArray();

        int length = replacement.length;
        for (int i = 0; i < length; i++)
            list.add(matcher.start() + i, replacement[i]);

        StringBuilder builder = new StringBuilder();

        for (char c : list)
            builder.append(c);

        input = builder.toString();

        matcher.reset(input);
    }

    return input;
}
 
開發者ID:stefvanschie,項目名稱:buildinggame,代碼行數:42,代碼來源:ArenaScoreboard.java

示例5: asCharList

import com.google.common.primitives.Chars; //導入方法依賴的package包/類
/**
 * Wrap a character sequence in a list so it can be scanned by a pattern.
 *
 * @param charSequence The backing sequence.
 * @return A list wrapping the sequence.
 */
public static List<Character> asCharList(CharSequence charSequence) {
    // TODO: no copies - wrap the sequence for real.
    if (charSequence instanceof String) {
        char[] chars = ((String) charSequence).toCharArray();
        return Chars.asList(chars);
    }
    ArrayList<Character> charList = new ArrayList<>(charSequence.length());
    for (int i = 0; i < charSequence.length(); i++) {
        charList.add(charSequence.charAt(i));
    }
    return charList;
}
 
開發者ID:yanchith,項目名稱:pattern,代碼行數:19,代碼來源:Patterns.java

示例6: deleteCharAny

import com.google.common.primitives.Chars; //導入方法依賴的package包/類
/**
 * Delete char any.
 *
 * @param str   the str
 * @param chars the chars
 * @return the string
 */
public static String deleteCharAny(final String str, final char... chars) {
    if (isEmpty(str))
        return str;

    StringBuilder builder = new StringBuilder();
    final List<Character> charList = Chars.asList(chars);

    char[] strArray = str.toCharArray();
    for (char c : strArray) {
        if (!charList.contains(c))
            builder.append(c);
    }
    return builder.toString();
}
 
開發者ID:debop,項目名稱:debop4j,代碼行數:22,代碼來源:StringTool.java

示例7: deleteChar

import com.google.common.primitives.Chars; //導入方法依賴的package包/類
/**
 * Delete char.
 *
 * @param str   the str
 * @param chars the chars
 * @return the string
 */
public static String deleteChar(final String str, final char[] chars) {
    if (isEmpty(str))
        return str;

    StringBuilder builder = new StringBuilder();
    final List<Character> charList = Chars.asList(chars);

    char[] strArray = str.toCharArray();
    for (char c : strArray) {
        if (!charList.contains(c))
            builder.append(c);
    }
    return builder.toString();
}
 
開發者ID:debop,項目名稱:debop4j,代碼行數:22,代碼來源:StringTool.java

示例8:

import com.google.common.primitives.Chars; //導入方法依賴的package包/類
public static Iterable<Character> $in(char[] elements) {
  return Chars.asList(elements);
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:4,代碼來源:Intrinsics.java

示例9: swapCase

import com.google.common.primitives.Chars; //導入方法依賴的package包/類
public static String swapCase(String str) {
    List<Character> chars = Chars.asList(nullToEmpty(str).toCharArray());
    return from(chars).transform(flip()).join(on(""));
}
 
開發者ID:qianyan,項目名稱:underscore.string.java,代碼行數:5,代碼來源:UnderscoreString.java

示例10: translate

import com.google.common.primitives.Chars; //導入方法依賴的package包/類
public static String translate(String str, HashMap<Character, Character> dictionary, HashSet<Character> deletedChars) {
    List<Character> chars = Chars.asList(nullToEmpty(str).toCharArray());
    return from(chars).filter(without(deletedChars)).transform(in(dictionary)).filter(without(new HashSet<Character>() {{
        add(null);
    }})).join(on(""));
}
 
開發者ID:qianyan,項目名稱:underscore.string.java,代碼行數:7,代碼來源:UnderscoreString.java

示例11: ascii

import com.google.common.primitives.Chars; //導入方法依賴的package包/類
public static Optional<String> ascii(String s) {
    List<Character> chars = Chars.asList(nullToEmpty(s).toCharArray());

    return from(chars).transform(isAscii()).allMatch(is(true)) ? Optional.<String>of(s) : Optional.<String>absent();
}
 
開發者ID:qianyan,項目名稱:underscore.string.java,代碼行數:6,代碼來源:UnderscoreString.java

示例12: getSpecialChars

import com.google.common.primitives.Chars; //導入方法依賴的package包/類
static List<Character> getSpecialChars() {
  return Chars.asList(SPECIAL_CHARS);
}
 
開發者ID:JetBrains,項目名稱:mapper,代碼行數:4,代碼來源:JsonUtil.java

示例13: MyCompletionProvider

import com.google.common.primitives.Chars; //導入方法依賴的package包/類
MyCompletionProvider(@Nonnull Collection<String> values, boolean supportsNegativeValues) {
  super(new DefaultTextCompletionValueDescriptor.StringValueDescriptor(),
        supportsNegativeValues ? ContainerUtil.append(Chars.asList(SEPARATORS), '-') : Chars.asList(SEPARATORS), values, false);
}
 
開發者ID:consulo,項目名稱:consulo,代碼行數:5,代碼來源:MultilinePopupBuilder.java


注:本文中的com.google.common.primitives.Chars.asList方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。