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.jclouds.aliyun.ecs.domain.regionscoped.RegionAndId.java

public static RegionAndId fromSlashEncoded(String id) {
    Iterable<String> parts = Splitter.on('/').split(checkNotNull(id, "id"));
    checkArgument(Iterables.size(parts) == 2, "id must be in format regionId/id");
    return RegionAndId.create(Iterables.get(parts, 0), Iterables.get(parts, 1));
}

From source file:com.github.alexcojocaru.mojo.elasticsearch.v2.configuration.Artifacts.java

public static AbstractArtifact fromCoordinates(String coordinates) {
    Iterable<String> splitted = Splitter.on(':').omitEmptyStrings().trimResults().split(coordinates);
    String[] strings = Iterables.toArray(splitted, String.class);
    if (strings.length < THREE || strings.length > FIVE) {
        throw new InvalidCoordinatesException(coordinates);
    } else {/*from   www . ja  va  2 s .c om*/
        String extension = "jar"; // DEFAULT
        String classifier = null; // DEFAULT
        String groupId = strings[ZERO];
        String artifactId = strings[ONE];
        String version = strings[strings.length - ONE];
        if (strings.length == FOUR) {
            extension = strings[TWO];
        }
        if (strings.length == FIVE) {
            classifier = strings[THREE];
        }
        return new DefaultArtifact(groupId, artifactId, version, classifier, extension);
    }
}

From source file:com.facebook.presto.connector.thrift.location.HostList.java

@SuppressWarnings("unused")
public static HostList fromString(String hosts) {
    return new HostList(Splitter.on(',').trimResults().omitEmptyStrings().splitToList(hosts).stream()
            .map(HostAddress::fromString).collect(toImmutableList()));
}

From source file:com.facebook.presto.metadata.QualifiedTableName.java

@JsonCreator
public static QualifiedTableName valueOf(String tableName) {
    requireNonNull(tableName, "tableName is null");

    ImmutableList<String> ids = ImmutableList.copyOf(Splitter.on('.').split(tableName));
    checkArgument(ids.size() == 3, "Invalid tableName %s", tableName);

    return new QualifiedTableName(ids.get(0), ids.get(1), ids.get(2));
}

From source file:org.apache.metron.indexing.dao.IndexDaoFactory.java

public static List<IndexDao> create(String daoImpls, AccessConfig config) throws ClassNotFoundException,
        NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException {
    List<IndexDao> ret = new ArrayList<>();
    for (String daoImpl : Splitter.on(",").split(daoImpls)) {
        Class<? extends IndexDao> clazz = (Class<? extends IndexDao>) Class.forName(daoImpl);
        IndexDao instance = clazz.getConstructor().newInstance();
        instance.init(config);//from w  ww . j a  v a2 s .  c om
        ret.add(instance);
    }
    return ret;
}

From source file:org.jclouds.googlecomputeengine.compute.domain.internal.RegionAndName.java

public static RegionAndName fromSlashEncoded(String name) {
    Iterable<String> parts = Splitter.on('/').split(checkNotNull(name, "name"));
    checkArgument(Iterables.size(parts) == 2, "name must be in format regionId/name");
    return fromRegionAndName(Iterables.get(parts, 0), Iterables.get(parts, 1));
}

From source file:org.onehippo.cms7.essentials.dashboard.utils.PayloadUtils.java

public static List<String> extractValueList(final String value) {
    if (Strings.isNullOrEmpty(value)) {
        return Collections.emptyList();
    }/*from   w ww.j  a  va  2s  .  c  o m*/
    final Splitter splitter = Splitter.on(",").omitEmptyStrings().trimResults();
    final Iterable<String> iterable = splitter.split(value);
    return Lists.newArrayList(iterable);
}

From source file:com.mcmiddleearth.plotbuild.utils.ListUtil.java

public static List<UUID> playerListFromString(String uuids) {
    ArrayList<UUID> players = new ArrayList<>();
    if (uuids.length() > 0) {
        for (String uuid : Splitter.on(';').split(uuids)) {
            players.add(UUID.fromString(uuid));
        }//ww  w. jav  a  2  s.c  om
    }
    return players;
}

From source file:com.google.api.codegen.discovery.transformer.go.GoSampleNamer.java

/**
 * Returns the package name of the service.
 *
 * <p>Only intended for use in Go. For example: "google.golang.org/api/logging/v2beta1" returns
 * "logging"/*from   w w  w .j av  a2s  . co m*/
 */
public static String getServicePackageName(String packagePrefix) {
    List<String> split = Splitter.on('/').splitToList(packagePrefix);
    String localName = "";
    if (split.size() < 2) {
        throw new IllegalArgumentException("expected packagePrefix to have at least 2 segments");
    }
    // Get the second to last value.
    // "google.golang.org/api/logging/v2beta1"
    //                        ^^^^^^^
    localName = split.get(split.size() - 2);
    return localName;
}

From source file:com.facebook.presto.metadata.QualifiedObjectName.java

@JsonCreator
public static QualifiedObjectName valueOf(String name) {
    requireNonNull(name, "name is null");

    ImmutableList<String> ids = ImmutableList.copyOf(Splitter.on('.').split(name));
    checkArgument(ids.size() == 3, "Invalid name %s", name);

    return new QualifiedObjectName(ids.get(0), ids.get(1), ids.get(2));
}