Example usage for com.google.common.collect ImmutableSortedSet comparator

List of usage examples for com.google.common.collect ImmutableSortedSet comparator

Introduction

In this page you can find the example usage for com.google.common.collect ImmutableSortedSet comparator.

Prototype

public Comparator<? super E> comparator() 

Source Link

Usage

From source file:com.facebook.buck.android.AndroidResourceHelper.java

/**
 * Filters out the set of {@code android_resource()} dependencies from {@code deps}. As a special
 * case, if an {@code android_prebuilt_aar()} appears in the deps, the {@code android_resource()}
 * that corresponds to the AAR will also be included in the output.
 * <p>//from w  ww .  ja v a  2  s. c o  m
 */
public static ImmutableSortedSet<BuildRule> androidResOnly(ImmutableSortedSet<BuildRule> deps) {
    return FluentIterable.from(deps).transform(new Function<BuildRule, BuildRule>() {
        @Override
        @Nullable
        public BuildRule apply(BuildRule buildRule) {
            if (buildRule instanceof HasAndroidResourceDeps) {
                return buildRule;
            }
            return null;
        }
    }).filter(Objects::nonNull).toSortedSet(deps.comparator());
}

From source file:com.google.devtools.build.lib.skyframe.serialization.ImmutableSortedSetCodec.java

@Override
public void serialize(SerializationContext context, ImmutableSortedSet<E> object, CodedOutputStream codedOut)
        throws SerializationException, IOException {
    context.serialize(object.comparator(), codedOut);
    codedOut.writeInt32NoTag(object.size());
    for (Object obj : object) {
        context.serialize(obj, codedOut);
    }/*from   w  ww. j av a2 s  .c  o m*/
}