use of java.util.StringJoiner in project jabref by JabRef.
the class FieldFormatterCleanups method getMetaDataString.
private static String getMetaDataString(List<FieldFormatterCleanup> actionList, String newline) {
//first, group all formatters by the field for which they apply
Map<String, List<String>> groupedByField = new HashMap<>();
for (FieldFormatterCleanup cleanup : actionList) {
String key = cleanup.getField();
// add new list into the hashmap if needed
if (!groupedByField.containsKey(key)) {
groupedByField.put(key, new ArrayList<>());
}
//add the formatter to the map if it is not already there
List<String> formattersForKey = groupedByField.get(key);
if (!formattersForKey.contains(cleanup.getFormatter().getKey())) {
formattersForKey.add(cleanup.getFormatter().getKey());
}
}
// convert the contents of the hashmap into the correct serialization
StringBuilder result = new StringBuilder();
for (Map.Entry<String, List<String>> entry : groupedByField.entrySet()) {
result.append(entry.getKey());
StringJoiner joiner = new StringJoiner(",", "[", "]" + newline);
entry.getValue().forEach(joiner::add);
result.append(joiner.toString());
}
return result.toString();
}
use of java.util.StringJoiner in project JMRI by JMRI.
the class WebAppManager method getAngularSources.
public String getAngularSources(Profile profile, Locale locale) {
// NOI18N
StringJoiner sources = new StringJoiner("\n", "\n\n", "\n");
List<URL> urls = new ArrayList<>();
this.getManifests(profile).forEach((WebManifest manifest) -> {
urls.addAll(manifest.getAngularSources());
});
urls.forEach((URL source) -> {
try {
sources.add(FileUtil.readURL(source));
} catch (IOException ex) {
log.error("Unable to read {}", source, ex);
}
});
return sources.toString();
}
use of java.util.StringJoiner in project jdk8u_jdk by JetBrains.
the class AVAComparator method toRFC2253StringInternal.
private String toRFC2253StringInternal(boolean canonical, Map<String, String> oidMap) {
// normally, an RDN only contains one AVA
if (assertion.length == 1) {
return canonical ? assertion[0].toRFC2253CanonicalString() : assertion[0].toRFC2253String(oidMap);
}
AVA[] toOutput = assertion;
if (canonical) {
// order the string type AVA's alphabetically,
// followed by the oid type AVA's numerically
toOutput = assertion.clone();
Arrays.sort(toOutput, AVAComparator.getInstance());
}
StringJoiner sj = new StringJoiner("+");
for (AVA ava : toOutput) {
sj.add(canonical ? ava.toRFC2253CanonicalString() : ava.toRFC2253String(oidMap));
}
return sj.toString();
}
use of java.util.StringJoiner in project jdk8u_jdk by JetBrains.
the class DefaultProxySelector method toPattern.
/**
* @param mask non-null mask
* @return {@link java.util.regex.Pattern} corresponding to this mask
* or {@code null} in case mask should not match anything
*/
static Pattern toPattern(String mask) {
boolean disjunctionEmpty = true;
StringJoiner joiner = new StringJoiner("|");
for (String disjunct : mask.split("\\|")) {
if (disjunct.isEmpty())
continue;
disjunctionEmpty = false;
String regex = disjunctToRegex(disjunct.toLowerCase());
joiner.add(regex);
}
return disjunctionEmpty ? null : Pattern.compile(joiner.toString());
}
use of java.util.StringJoiner in project jdk8u_jdk by JetBrains.
the class TestPolicy method toString.
/*
* Overloaded methods from the Policy class
*/
@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();
}
Aggregations