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

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

Introduction

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

Prototype

public static <E> Builder<E> orderedBy(Comparator<E> comparator) 

Source Link

Usage

From source file:org.apache.abdera2.common.misc.ArrayBuilder.java

public static <T> ArrayBuilder<T> sortedSet(Class<? super T> _class, Comparator<T> comp) {
    return new ArrayBuilder<T>(_class, ImmutableSortedSet.orderedBy(comp));
}

From source file:org.caleydo.view.bicluster.ScanLZTable.java

@Override
public List<FuzzyClustering> call() throws Exception {
    final int rows = lOrZ.depth();
    final int clusters = lOrZ.size();

    List<FuzzyClustering> l = new ArrayList<>(clusters);
    for (int i = 0; i < clusters; ++i) {
        ImmutableSortedSet.Builder<IntFloat> b = ImmutableSortedSet.orderedBy(IntFloat.BY_MEMBERSHIP);
        for (int j = 0; j < rows; ++j) {
            float p = lOrZ.getRaw(i, j);
            b.add(new IntFloat(j, p));
        }/*from  ww w.  ja va  2  s.  c om*/
        l.add(new FuzzyClustering(b.build()));
    }
    return ImmutableList.copyOf(l);
}

From source file:org.caleydo.view.domino.internal.tourguide.ui.EntityTypeSelector.java

/**
 * @return//from   w w w  . j a v a2s .c  om
 */
public static Set<IDCategory> findAllUsedIDCategories() {
    ImmutableSet.Builder<IDCategory> b = ImmutableSortedSet.orderedBy(new Comparator<IDCategory>() {
        @Override
        public int compare(IDCategory o1, IDCategory o2) {
            return String.CASE_INSENSITIVE_ORDER.compare(o1.getCategoryName(), o2.getCategoryName());
        }
    });
    IDataSupportDefinition inhomogenous = DataSupportDefinitions.inhomogenousTables;
    for (ATableBasedDataDomain d : DataDomainManager.get().getDataDomainsByType(ATableBasedDataDomain.class)) {
        b.add(d.getRecordIDCategory());
        if (!inhomogenous.apply(d)) // just in case of uniform tables
            b.add(d.getDimensionIDCategory());
    }
    return b.build();
}

From source file:controllers.PermissionController.java

public static void create() {
    // get all the stream and all the groups...

    Set<String> streams = null;
    Set<String> groups = null;
    try {/*from   ww w .ja v  a2s .c o  m*/
        MetadataService meta = Locator.getMetaService(getNode());
        streams = ImmutableSortedSet.orderedBy(new Comparator<String>() {
            @Override
            public int compare(String r1, String r2) {
                return r1.compareToIgnoreCase(r2);
            }
        }).addAll(Collections2.transform(meta.listWhere("stream", null), new Function<MetaResource, String>() {
            @Override
            public String apply(MetaResource input) {
                return input.getResource().getUrl() + "#" + input.getResource().getName();
            }
        })).build();

        groups = ImmutableSortedSet.orderedBy(new Comparator<String>() {
            @Override
            public int compare(String r1, String r2) {
                return r1.compareToIgnoreCase(r2);
            }
        }).addAll(Collections2.transform(meta.listWhere("group", null), new Function<MetaResource, String>() {
            @Override
            public String apply(MetaResource input) {
                return input.getResource().getUrl() + "#" + input.getResource().getName();
            }
        })).build();

    } catch (Exception e) {
        e.printStackTrace();
        flash.error("Problem while getting data");
        index();
    }
    render(groups, streams);
}

From source file:com.outerspacecat.openid.rp.Service.java

Service(final int priority, final Iterable<Endpoint> endpoints) {
    Preconditions.checkArgument(priority >= 0, "priority must be non negative");
    Preconditions.checkNotNull(endpoints, "endpoints required");
    Preconditions.checkArgument(endpoints.iterator().hasNext(), "one or more endpoints required");
    for (Endpoint endpoint : endpoints)
        Preconditions.checkNotNull(endpoint, "all endpoints must be non null");

    this.priority = priority;
    this.endpoints = ImmutableSortedSet.orderedBy(new Comparator<Endpoint>() {
        @Override//from w w w . ja v a 2 s.  c om
        public int compare(final Endpoint obj1, final Endpoint obj2) {
            return obj2.getPriority() - obj1.getPriority();
        }
    }).addAll(endpoints).build();
}

From source file:org.caleydo.core.view.internal.ColorPalettePicker.java

public ColorPalettePicker() {
    setLayout(GLLayouts.flowVertical(10));
    ImmutableSortedSet.Builder<IColorPalette> b = ImmutableSortedSet.orderedBy(new Comparator<IColorPalette>() {
        @Override//from w ww  . j  a  v a  2 s  .  com
        public int compare(IColorPalette o1, IColorPalette o2) {
            int c;
            if ((c = o1.getType().compareTo(o2.getType())) != 0)
                return c;
            c = o1.getSizes().last() - o2.getSizes().last();
            if (c != 0)
                return -c;
            return String.CASE_INSENSITIVE_ORDER.compare(o1.getLabel(), o2.getLabel());
        }
    });
    b.add(ColorBrewer.values());
    b.add(AlexColorPalette.values());

    final ImmutableList<IColorPalette> l = b.build().asList();
    GLElementContainer c = new GLElementContainer(GLLayouts.flowHorizontal(2));
    for (IColorPalette p : l.subList(0, l.size() / 2))
        c.add(new ColorPalette(p));
    this.add(c);
    c = new GLElementContainer(GLLayouts.flowHorizontal(2));
    for (IColorPalette p : l.subList(l.size() / 2, l.size()))
        c.add(new ColorPalette(p));
    this.add(c);

}

From source file:com.facebook.buck.test.result.groups.MockingDSL.java

static void deps(BuildRule buildRule, BuildRule... dependencies) {
    Comparator<BuildRule> comparator = new Comparator<BuildRule>() {
        @Override/*www.  j a  v  a 2 s  . c o m*/
        public int compare(BuildRule o1, BuildRule o2) {
            return o1.hashCode() - o2.hashCode();
        }
    };
    ImmutableSortedSet.Builder<BuildRule> builder = ImmutableSortedSet.orderedBy(comparator);
    for (BuildRule dependency : dependencies) {
        builder.add(dependency);
    }
    ImmutableSortedSet<BuildRule> dependenciesSet = builder.build();
    expect(buildRule.getDeps()).andReturn(dependenciesSet).anyTimes();
}

From source file:io.crate.metadata.sys.ColumnRegistrar.java

ColumnRegistrar(TableIdent tableIdent, RowGranularity rowGranularity) {
    this.tableIdent = tableIdent;
    this.rowGranularity = rowGranularity;
    this.infosBuilder = ImmutableSortedMap.naturalOrder();
    this.columnsBuilder = ImmutableSortedSet.orderedBy(ReferenceInfo.COMPARE_BY_COLUMN_IDENT);
}

From source file:io.crate.metadata.table.ColumnRegistrar.java

public ColumnRegistrar(TableIdent tableIdent, RowGranularity rowGranularity) {
    this.tableIdent = tableIdent;
    this.rowGranularity = rowGranularity;
    this.infosBuilder = ImmutableSortedMap.naturalOrder();
    this.columnsBuilder = ImmutableSortedSet.orderedBy(Reference.COMPARE_BY_COLUMN_IDENT);
}

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

@Override
public ImmutableSortedSet<E> deserialize(DeserializationContext context, CodedInputStream codedIn)
        throws SerializationException, IOException {
    ImmutableSortedSet.Builder<E> builder = ImmutableSortedSet.orderedBy(context.deserialize(codedIn));
    int size = codedIn.readInt32();
    for (int i = 0; i < size; i++) {
        builder.add(context.<E>deserialize(codedIn));
    }/*ww  w. j  av a2 s.  c  o  m*/
    return builder.build();
}