Search in sources :

Example 76 with StringJoiner

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();
}
Also used : HashMap(java.util.HashMap) List(java.util.List) ArrayList(java.util.ArrayList) Map(java.util.Map) HashMap(java.util.HashMap) StringJoiner(java.util.StringJoiner)

Example 77 with StringJoiner

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();
}
Also used : ArrayList(java.util.ArrayList) WebManifest(jmri.server.web.spi.WebManifest) IOException(java.io.IOException) StringJoiner(java.util.StringJoiner) URL(java.net.URL)

Example 78 with StringJoiner

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();
}
Also used : StringJoiner(java.util.StringJoiner)

Example 79 with StringJoiner

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());
}
Also used : StringJoiner(java.util.StringJoiner)

Example 80 with StringJoiner

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();
}
Also used : SecurityPermission(java.security.SecurityPermission) AllPermission(java.security.AllPermission) SQLPermission(java.sql.SQLPermission) PropertyPermission(java.util.PropertyPermission) Permission(java.security.Permission) FilePermission(java.io.FilePermission) LoggingPermission(java.util.logging.LoggingPermission) StringJoiner(java.util.StringJoiner)

Aggregations

StringJoiner (java.util.StringJoiner)98 ArrayList (java.util.ArrayList)22 List (java.util.List)11 IOException (java.io.IOException)6 HashSet (java.util.HashSet)6 Map (java.util.Map)6 HashMap (java.util.HashMap)4 Collectors (java.util.stream.Collectors)4 ClassName (com.squareup.javapoet.ClassName)3 FieldSpec (com.squareup.javapoet.FieldSpec)3 ParameterizedTypeName (com.squareup.javapoet.ParameterizedTypeName)3 TypeName (com.squareup.javapoet.TypeName)3 TypeSpec (com.squareup.javapoet.TypeSpec)3 Expression (com.sri.ai.expresso.api.Expression)3 Attribute (io.requery.meta.Attribute)3 Field (java.lang.reflect.Field)3 Scanner (java.util.Scanner)3 RaptorColumnHandle (com.facebook.presto.raptor.RaptorColumnHandle)2 Range (com.facebook.presto.spi.predicate.Range)2 MaterializedResult (com.facebook.presto.testing.MaterializedResult)2