Example usage for com.google.common.base Functions toStringFunction

List of usage examples for com.google.common.base Functions toStringFunction

Introduction

In this page you can find the example usage for com.google.common.base Functions toStringFunction.

Prototype

public static Function<Object, String> toStringFunction() 

Source Link

Document

Returns a function that calls toString() on its argument.

Usage

From source file:org.apache.helix.tools.ClusterExternalViewVerifier.java

boolean verifyLiveNodes(List<ParticipantId> actualLiveNodes) {
    Collections.sort(actualLiveNodes);
    List<String> rawActualLiveNodes = Lists.transform(actualLiveNodes, Functions.toStringFunction());
    return _expectSortedLiveNodes.equals(rawActualLiveNodes);
}

From source file:com.mycila.ujd.mbean.JmxAnalyzer.java

private <T> Iterable<String> sort(Iterable<T> it) {
    Set<String> sorted = new TreeSet<String>();
    Iterables.addAll(sorted, Iterables.transform(it, Functions.toStringFunction()));
    return sorted;
}

From source file:de.cosmocode.palava.store.MemoryStore.java

@Override
public Set<String> list() throws IOException {
    return Sets.newHashSet(Collections2.transform(map.keySet(), Functions.toStringFunction()));
}

From source file:edu.harvard.med.screensaver.ui.arch.util.JSFUtils.java

/**
 * Creates a UISelectItems object that can be assigned to the "value"
 * attribute of a UISelectItems JSF component.
 *//*from   w w  w  .  ja va 2  s.co  m*/
public static List<SelectItem> createUISelectItems(Collection items) {
    return createUISelectItems(items, false, null, Functions.toStringFunction());
}

From source file:com.b2international.index.lucene.IndexFieldBase.java

@Override
public final List<String> getValuesAsStringList(Document doc) {
    return FluentIterable.from(getValues(doc)).transform(Functions.toStringFunction()).toList();
}

From source file:com.google.devtools.build.lib.rules.android.AndroidResourceParsingActionBuilder.java

private static String convertRoots(Iterable<PathFragment> roots) {
    return Joiner.on("#").join(Iterables.transform(roots, Functions.toStringFunction()));
}

From source file:com.facebook.buck.cxx.CxxPreprocessStep.java

@VisibleForTesting
protected ImmutableList<String> getCommand() {
    return ImmutableList.<String>builder().add(preprocessor.toString()).add("-E").addAll(flags)
            .addAll(MoreIterables.zipAndConcat(Iterables.cycle("-I"),
                    Iterables.transform(includes, Functions.toStringFunction())))
            .addAll(MoreIterables.zipAndConcat(Iterables.cycle("-isystem"),
                    Iterables.transform(systemIncludes, Functions.toStringFunction())))
            .add(input.toString()).build();
}

From source file:com.isotrol.impe3.core.impl.AbstractMultiStringParameters.java

public Set<String> getNames() {
    final Set<CaseIgnoringString> keys = map().keySet();
    return new AbstractSet<String>() {

        public boolean add(String e) {
            throw new UnsupportedOperationException();
        }/*from  w ww. jav a  2 s . co m*/

        public void clear() {
            throw new UnsupportedOperationException();
        }

        public boolean contains(Object o) {
            Preconditions.checkNotNull(o);
            return keys.contains(CaseIgnoringString.valueOf((String) o));
        }

        public boolean isEmpty() {
            return keys.isEmpty();
        }

        public Iterator<String> iterator() {
            return Iterators.transform(keys.iterator(), Functions.toStringFunction());
        }

        public boolean remove(Object o) {
            throw new UnsupportedOperationException();
        }

        public boolean removeAll(Collection<?> c) {
            throw new UnsupportedOperationException();
        }

        public boolean retainAll(Collection<?> c) {
            throw new UnsupportedOperationException();
        }

        public int size() {
            return keys.size();
        }
    };
}

From source file:com.b2international.index.lucene.IndexFieldBase.java

@Override
public final Set<String> getValuesAsStringSet(Document doc) {
    return FluentIterable.from(getValues(doc)).transform(Functions.toStringFunction()).toSet();
}

From source file:com.facebook.buck.cxx.CxxPreprocessStep.java

@VisibleForTesting
protected static Function<String, String> createOutputLineProcessor(final Path workingDir,
        final ImmutableMap<Path, Path> replacementPaths, final Optional<DebugPathSanitizer> sanitizer) {

    return new Function<String, String>() {

        private final Pattern lineMarkers = Pattern.compile("^# (?<num>\\d+) \"(?<path>[^\"]+)\"(?<rest>.*)?$");

        @Override/*from w ww  .java  2 s  .  c  o  m*/
        public String apply(String line) {
            if (line.startsWith("# ")) {
                Matcher m = lineMarkers.matcher(line);
                if (m.find()) {
                    String originalPath = m.group("path");
                    String replacementPath = originalPath;

                    replacementPath = Optional.fromNullable(replacementPaths.get(Paths.get(replacementPath)))
                            .transform(Functions.toStringFunction()).or(replacementPath);

                    if (sanitizer.isPresent()) {
                        replacementPath = sanitizer.get().sanitize(Optional.of(workingDir), replacementPath);
                    }

                    if (!originalPath.equals(replacementPath)) {
                        String num = m.group("num");
                        String rest = m.group("rest");
                        return "# " + num + " \"" + replacementPath + "\"" + rest;
                    }
                }
            }
            return line;
        }

    };
}