Example usage for com.google.common.collect Iterables toString

List of usage examples for com.google.common.collect Iterables toString

Introduction

In this page you can find the example usage for com.google.common.collect Iterables toString.

Prototype

public static String toString(Iterable<?> iterable) 

Source Link

Document

Returns a string representation of iterable , with the format [e1, e2, ..., en] (that is, identical to java.util.Arrays Arrays .toString(Iterables.toArray(iterable)) ).

Usage

From source file:com.pkware.truth.android.view.animation.GridLayoutAnimationControllerSubject.java

private static String directionToString(@GridLayoutAnimationControllerDirection int direction) {
    List<String> parts = new ArrayList<>();
    int horizontal = direction & DIRECTION_HORIZONTAL_MASK;
    int vertical = direction & DIRECTION_VERTICAL_MASK;
    if ((horizontal & DIRECTION_RIGHT_TO_LEFT) != 0) {
        parts.add("rightToLeft");
    } else {/* ww  w  .  ja  v  a  2s  . c om*/
        parts.add("leftToRight");
    }
    if ((vertical & DIRECTION_BOTTOM_TO_TOP) != 0) {
        parts.add("bottomToTop");
    } else {
        parts.add("topToBottom");
    }
    return Iterables.toString(parts);
}

From source file:org.elasticsearch.river.subversion.crawler.Parameters.java

@Override
public String toString() {
    return Objects.toStringHelper(this).add("login", login).add("path", path)
            .add("startRevision", startRevision).add("endRevision", endRevision)
            .add("maximumFileSize", maximumFileSize)
            .add("patternsToFilter", Iterables.toString(patternsToFilter)).add("storeDiffs", storeDiffs)
            .toString();//from  www.j  a va  2s  .  c  om
}

From source file:com.torodb.kvdocument.values.KvDocument.java

@Override
public String toString() {
    StringBuilder toStringBuilder = new StringBuilder(Iterables.toString(this));

    toStringBuilder.setCharAt(0, '{');
    toStringBuilder.setCharAt(toStringBuilder.length() - 1, '}');

    return toStringBuilder.toString();
}

From source file:eu.interedition.collatex.dekker.TranspositionDetector.java

public List<List<Match>> detect(List<List<Match>> phraseMatches, VariantGraph base) {
    //rank the variant graph
    base.rank();/*from w  w  w .j  a  va 2  s .c  om*/

    // gather matched ranks into a list ordered by their natural order
    final List<Integer> ranks = Lists.newArrayList();
    for (List<Match> phraseMatch : phraseMatches) {
        ranks.add(phraseMatch.get(0).vertex.getRank());
    }
    Collections.sort(ranks);

    // detect transpositions
    final List<List<Match>> transpositions = Lists.newArrayList();
    int previousRank = 0;
    Tuple<Integer> previous = new Tuple<Integer>(0, 0);

    for (List<Match> phraseMatch : phraseMatches) {
        VariantGraphVertex baseToken = phraseMatch.get(0).vertex;
        int rank = baseToken.getRank();
        int expectedRank = ranks.get(previousRank);
        Tuple<Integer> current = new Tuple<Integer>(expectedRank, rank);
        if (expectedRank != rank && !isMirrored(previous, current)) {
            transpositions.add(phraseMatch);
        }
        previousRank++;
        previous = current;
    }
    if (LOG.isTraceEnabled()) {
        for (List<Match> transposition : transpositions) {
            LOG.trace("Detected transposition: {}", Iterables.toString(transposition));
        }
    }
    return transpositions;
}

From source file:com.analog.lyric.benchmarking.utils.doublespace.test.Utilities.java

public static <T> void compareIterables(Iterable<T> expected, Iterable<T> actual) {
    boolean elementsEqual = true;
    final Iterator<T> it_expected = expected.iterator();
    final Iterator<T> it_actual = actual.iterator();
    String message = "equal elements";
    while (it_expected.hasNext() && it_actual.hasNext()) {
        final T an_expected = it_expected.next();
        final T an_actual = it_actual.next();
        elementsEqual &= compare(an_expected, an_actual);
    }/*  ww  w.j a v  a  2 s  .  com*/
    elementsEqual &= it_expected.hasNext() == it_actual.hasNext();
    if (!elementsEqual) {
        final String expected_string = Iterables.toString(Iterables.transform(expected, stringify));
        final String actual_string = Iterables.toString(Iterables.transform(actual, stringify));
        message = String.format("Exected \"%s\",  actual \"%s\"", expected_string, actual_string);
    }
    assertThat(message, elementsEqual, equalTo(true));
}

From source file:se.kth.id2203.overlay.LookupTable.java

@Override
public String toString() {
    StringBuilder sb = new StringBuilder();
    sb.append("LookupTable(\n");
    for (Integer key : partitions.keySet()) {
        sb.append(key);//from  www .  ja  v a2s  . c  om
        sb.append(" -> ");
        sb.append(Iterables.toString(partitions.get(key)));
        sb.append("\n");
    }
    sb.append(")");
    return sb.toString();
}

From source file:org.jclouds.vcloud.director.v1_5.predicates.ReferencePredicates.java

/**
 * Matches {@link Reference}s with names in the given collection.
 *
 * @param T type of the reference, for example {@link Link}
 * @param names collection of values for the name attribute of the referenced object
 * @return predicate that will match references with names starting with the given prefix
 *//*from   w ww. ja va2  s .com*/
public static <T extends Reference> Predicate<T> nameIn(final Iterable<String> names) {
    checkNotNull(names, "names must be defined");

    return new Predicate<T>() {
        @Override
        public boolean apply(T reference) {
            String name = reference.getName();
            return Iterables.contains(names, name);
        }

        @Override
        public String toString() {
            return "nameIn(" + Iterables.toString(names) + ")";
        }
    };
}

From source file:io.scigraph.frames.Concept.java

@Override
public String toString() {
    return String.format("%s (%s)", Iterables.toString(getLabels()), getIri());
}

From source file:edu.sdsc.scigraph.frames.Concept.java

@Override
public String toString() {
    return String.format("%s (%s)", Iterables.toString(getLabels()), getFragment());
}

From source file:org.eclipse.incquery.viewers.runtime.validators.ItemValidator.java

@Override
public void executeAdditionalValidation(Annotation annotation, IIssueCallback validator) {
    // Label validation is handled in parent class
    super.executeAdditionalValidation(annotation, validator);

    ValueReference hierarchyRef = CorePatternLanguageHelper.getFirstAnnotationParameter(annotation,
            "hierarchy");
    if (hierarchyRef instanceof StringValue) {
        String value = ((StringValue) hierarchyRef).getValue();

        final List<String> valueList = Lists.transform(Arrays.asList(HierarchyPolicy.values()),
                new Function<HierarchyPolicy, String>() {

                    @Override//from  w  ww . j a  v  a 2 s .com
                    public String apply(HierarchyPolicy policy) {
                        return policy.name().toLowerCase();
                    }
                });

        if (!valueList.contains(value.toLowerCase())) {
            validator.error(
                    String.format("Invalid hierarchy literal %s. Possible values are %s.", value,
                            Iterables.toString(valueList)),
                    hierarchyRef, PatternLanguagePackage.Literals.STRING_VALUE__VALUE, HIERARCHY_LITERAL_ISSUE);
        }
    }
}