Example usage for com.google.common.base Splitter on

List of usage examples for com.google.common.base Splitter on

Introduction

In this page you can find the example usage for com.google.common.base Splitter on.

Prototype

@CheckReturnValue
@GwtIncompatible("java.util.regex")
public static Splitter on(final Pattern separatorPattern) 

Source Link

Document

Returns a splitter that considers any subsequence matching pattern to be a separator.

Usage

From source file:org.locationtech.geogig.repository.LocalRemoteRefSpec.java

public static List<LocalRemoteRefSpec> parse(final String remoteName, final String refspecs) {
    Preconditions.checkArgument(!Strings.isNullOrEmpty(remoteName));
    Preconditions.checkArgument(!Strings.isNullOrEmpty(remoteName.trim()));
    Preconditions.checkArgument(!Strings.isNullOrEmpty(refspecs), "no refspecs provided");
    Preconditions.checkArgument(!Strings.isNullOrEmpty(refspecs.trim()), "no refspecs provided");

    List<String> refs = Splitter.on(';').omitEmptyStrings().trimResults().splitToList(refspecs);
    return refs.stream().map(spec -> LocalRemoteRefSpec.parseSingle(remoteName, spec))
            .collect(Collectors.toList());
}

From source file:org.apache.james.util.Host.java

private static ImmutableList<Host> parseHosts(String hostsString, Optional<Integer> defaultPort) {
    return Splitter.on(',').omitEmptyStrings().splitToList(hostsString).stream()
            .map(string -> Host.parse(string, defaultPort)).distinct().collect(Guavate.toImmutableList());
}

From source file:co.cask.tigon.sql.internal.StreamSchemaCodec.java

/**
 * Generate {@link co.cask.tigon.sql.flowlet.StreamSchema} from serialized Schema String.
 *///from  w  ww .  j  a  v a 2 s .  co m
public static StreamSchema deserialize(String schemaString) {
    Iterable<String> fieldArray = Splitter.on(';').trimResults().omitEmptyStrings().split(schemaString);
    StreamSchema.Builder builder = new StreamSchema.Builder();
    for (String field : fieldArray) {
        Iterable<String> defnArray = Splitter.onPattern("\\s+").trimResults().omitEmptyStrings().split(field);
        List<String> defnList = Lists.newArrayList(defnArray);
        //We expect FieldType, FieldName (optional : FieldAttribute)
        Preconditions.checkArgument(defnList.size() >= 2);
        GDATFieldType type = GDATFieldType.getGDATFieldType(defnList.get(0).toUpperCase());
        String fieldName = defnList.get(1);
        builder.addField(fieldName, type);
    }
    return builder.build();
}

From source file:com.enonic.cms.core.resource.ResourceKey.java

private static String[] split(final String path) {
    final Iterable<String> result = Splitter.on("/").omitEmptyStrings().trimResults().split(path);
    return Iterables.toArray(result, String.class);
}

From source file:org.eclipse.che.inject.StringArrayConverter.java

@Override
public Object convert(String value, TypeLiteral<?> toType) {
    return Iterables.toArray(Splitter.on(PATTERN).split(value), String.class);
}

From source file:de.chaosfisch.google.youtube.upload.metadata.TagParser.java

public static List<String> parse(final String input) {
    final List<String> tags = Splitter.on(TAG_DELIMITER).omitEmptyStrings().splitToList(input);
    final List<String> result = new ArrayList<>(tags.size());

    for (final String tag : tags) {
        if (!result.contains(tag.trim())) {
            result.add(tag.trim());//from  w w  w. j  av a 2s.c  o  m
        }
    }
    return result;
}

From source file:com.haulmont.cuba.core.sys.AppContextLoader.java

public static void createPersistenceXml(String storeName) {
    String configPropertyName = AppContextLoader.PERSISTENCE_CONFIG;
    String fileName = "persistence.xml";
    if (!Stores.isMain(storeName)) {
        configPropertyName = configPropertyName + "_" + storeName;
        fileName = storeName + "-" + fileName;
    }/*ww  w. j  a va2 s .  c om*/

    String configProperty = AppContext.getProperty(configPropertyName);
    if (Strings.isNullOrEmpty(configProperty)) {
        log.debug("Property {} is not set, assuming {} is not a RdbmsStore", configPropertyName, storeName);
        return;
    }

    List<String> files = Splitter.on(AppProperties.SEPARATOR_PATTERN).omitEmptyStrings().trimResults()
            .splitToList(configProperty);
    if (!Stores.isMain(storeName) && !files.contains("base-persistence.xml")) {
        files = new ArrayList<>(files);
        files.add(0, "base-persistence.xml");
    }

    PersistenceConfigProcessor processor = new PersistenceConfigProcessor();
    processor.setStorageName(storeName);
    processor.setSourceFiles(files);

    String dataDir = AppContext.getProperty("cuba.dataDir");
    processor.setOutputFile(dataDir + "/" + fileName);

    processor.create();
}

From source file:com.haulmont.cuba.core.sys.AvailableLocalesFactory.java

@Override
public Object build(String string) {
    if (string == null)
        return null;

    Map<String, Locale> result = new LinkedHashMap<>();
    for (String item : Splitter.on(';').trimResults().omitEmptyStrings().split(string)) {
        String[] parts = item.split("\\|");
        result.put(parts[0], LocaleUtils.toLocale(parts[1]));
    }//from  w  w w .  ja v  a  2 s .  c  o  m
    return result;
}

From source file:org.apache.metron.dataloads.nonbulk.taxii.TableInfo.java

public TableInfo(String s) {
    Iterable<String> i = Splitter.on(":").split(s);
    if (Iterables.size(i) != 2) {
        throw new IllegalStateException("Malformed table:cf => " + s);
    }/*from   w w w .jav  a  2  s .c  o m*/
    tableName = Iterables.getFirst(i, null);
    columnFamily = Iterables.getLast(i);
}

From source file:org.corpus_tools.annis.benchmark.generator.StringSetConverter.java

@Override
public Set<String> fromString(String string) {
    return new LinkedHashSet<>(Splitter.on(",").omitEmptyStrings().trimResults().splitToList(string));
}