Example usage for com.google.common.collect Sets newTreeSet

List of usage examples for com.google.common.collect Sets newTreeSet

Introduction

In this page you can find the example usage for com.google.common.collect Sets newTreeSet.

Prototype

public static <E> TreeSet<E> newTreeSet(Comparator<? super E> comparator) 

Source Link

Document

Creates a mutable, empty TreeSet instance with the given comparator.

Usage

From source file:org.fenixedu.qubdocs.academic.documentRequests.providers.EnrolmentsDataProvider.java

public Set<CurriculumEntry> getCurriculumEntries() {
    if (curriculumEntries == null) {
        curriculumEntries = Sets.newTreeSet(CurriculumEntry.NAME_COMPARATOR(locale));

        Collection<? extends ICurriculumEntry> enrolments = this.registration.getEnrolments(executionYear);
        curriculumEntries.addAll(CurriculumEntry.transform(registration, enrolments, remarksDataProvider));
    }/*from w  w  w .j  a  v  a2 s.c  o m*/

    return curriculumEntries;
}

From source file:org.estatio.dom.communicationchannel.CommunicationChannels.java

@Programmatic
public SortedSet<CommunicationChannel> findByOwnerAndType(final CommunicationChannelOwner owner,
        final CommunicationChannelType type) {
    final List<CommunicationChannelOwnerLink> links = communicationChannelOwnerLinks
            .findByOwnerAndCommunicationChannelType(owner, type);
    return Sets.newTreeSet(
            Iterables.transform(links, CommunicationChannelOwnerLink.Functions.communicationChannel()));
}

From source file:edu.harvard.med.screensaver.ui.libraries.WellVolumeSearchResults.java

@Override
protected List<? extends TableColumn<WellVolume, ?>> buildColumns() {
    List<TableColumn<WellVolume, ?>> columns = new ArrayList<TableColumn<WellVolume, ?>>();
    columns.add(//from w  w  w.  j av a2 s  .  c  o  m
            new TextColumn<WellVolume>("Library", "The library containing the well", TableColumn.UNGROUPED) {
                @Override
                public String getCellValue(WellVolume wellVolume) {
                    return wellVolume.getWell().getLibrary().getLibraryName();
                }

                @Override
                public boolean isCommandLink() {
                    return true;
                }

                @Override
                public Object cellAction(WellVolume wellVolume) {
                    return _libraryViewer.viewEntity(wellVolume.getWell().getLibrary());
                }
            });
    columns.add(new IntegerColumn<WellVolume>("Plate", "The number of the plate the well is located on",
            TableColumn.UNGROUPED) {
        @Override
        public Integer getCellValue(WellVolume wellVolume) {
            return wellVolume.getWell().getPlateNumber();
        }
    });
    columns.add(new TextColumn<WellVolume>("Well", "The plate coordinates of the well", TableColumn.UNGROUPED) {
        @Override
        public String getCellValue(WellVolume wellVolume) {
            return wellVolume.getWell().getWellName();
        }

        @Override
        public boolean isCommandLink() {
            return true;
        }

        @Override
        public Object cellAction(WellVolume wellVolume) {
            return _wellViewer.viewEntity(wellVolume.getWell());
        }
    });
    columns.add(new SetColumn<WellVolume, String>("Copies", "The copies of this well", TableColumn.UNGROUPED,
            ColumnType.TEXT_SET) {
        @Override
        public Set<String> getCellValue(WellVolume wellVolume) {
            if (wellVolume.getActiveWellInfo().isEmpty()) {
                return Sets.newTreeSet(Arrays.asList(new String[] { "[no active copies]" }));
            }
            return Sets.newTreeSet(wellVolume.getActiveWellInfo().getCopiesList());
        }
    });
    columns.add(new VolumeColumn<WellVolume>("Total Initial Copy Volume",
            "The sum of initial volumes from all copies of this well", TableColumn.UNGROUPED) {
        @Override
        public Volume getCellValue(WellVolume wellVolume) {
            if (wellVolume.getActiveWellInfo().isEmpty())
                return null;
            return wellVolume.getActiveWellInfo().getTotalInitialVolume();
        }
    });
    columns.add(new VolumeColumn<WellVolume>("Consumed Volume",
            "The cumulative volume already used from this well, across all copies", TableColumn.UNGROUPED) {
        @Override
        public Volume getCellValue(WellVolume wellVolume) {
            if (wellVolume.getActiveWellInfo().isEmpty())
                return null;
            return wellVolume.getActiveWellInfo().getConsumedVolume();
        }
    });
    columns.add(new VolumeColumn<WellVolume>("Max Remaining Volume",
            "The maximum remaining volume of this well, across all copies", TableColumn.UNGROUPED) {
        @Override
        public Volume getCellValue(WellVolume wellVolume) {
            if (wellVolume.getActiveWellInfo().isEmpty())
                return null;
            return wellVolume.getActiveWellInfo().getMaxWellCopyVolume().getRemainingVolume();
        }
    });
    columns.add(new TextColumn<WellVolume>("Max Remaining Volume Copy",
            "The copy with the maximum remaining volume of this well", TableColumn.UNGROUPED) {
        @Override
        public String getCellValue(WellVolume wellVolume) {
            if (wellVolume.getActiveWellInfo().isEmpty())
                return null;
            return wellVolume.getActiveWellInfo().getMaxWellCopyVolume().getCopy().getName();
        }
    });
    columns.add(new VolumeColumn<WellVolume>("Min Remaining Volume",
            "The minimum remaining volume of this well, across all copies", TableColumn.UNGROUPED) {
        @Override
        public Volume getCellValue(WellVolume wellVolume) {
            if (wellVolume.getActiveWellInfo().isEmpty())
                return null;
            return wellVolume.getActiveWellInfo().getMinWellCopyVolume().getRemainingVolume();

        }
    });
    columns.add(new TextColumn<WellVolume>("Min Remaining Volume Copy",
            "The copy with the minimum remaining volume of this well", TableColumn.UNGROUPED) {
        @Override
        public String getCellValue(WellVolume wellVolume) {
            if (wellVolume.getActiveWellInfo().isEmpty())
                return null;
            return wellVolume.getActiveWellInfo().getMinWellCopyVolume().getCopy().getName();
        }
    });

    // Retired column info (hidden by default) //

    TableColumn<WellVolume, ?> c = new SetColumn<WellVolume, String>("Copies (Retired)",
            "The retired copies of this well", TableColumn.UNGROUPED, ColumnType.TEXT_SET) {
        @Override
        public Set<String> getCellValue(WellVolume wellVolume) {
            return Sets.newTreeSet(wellVolume.getRetiredWellInfo().getCopiesList());
        }
    };
    c.setVisible(false);
    columns.add(c);

    c = new VolumeColumn<WellVolume>("Total Initial Copy Volume (Retired)",
            "The sum of initial volumes from all copies of this well", TableColumn.UNGROUPED) {
        @Override
        public Volume getCellValue(WellVolume wellVolume) {
            return wellVolume.getRetiredWellInfo().getTotalInitialVolume();
        }
    };
    c.setVisible(false);
    columns.add(c);

    c = new VolumeColumn<WellVolume>("Consumed Volume (Retired)",
            "The cumulative volume already used from this well, across all copies", TableColumn.UNGROUPED) {
        @Override
        public Volume getCellValue(WellVolume wellVolume) {
            return wellVolume.getRetiredWellInfo().getConsumedVolume();
        }
    };
    c.setVisible(false);
    columns.add(c);

    c = new VolumeColumn<WellVolume>("Max Remaining Volume (Retired)",
            "The maximum remaining volume of this well, across all copies", TableColumn.UNGROUPED) {
        @Override
        public Volume getCellValue(WellVolume wellVolume) {
            return wellVolume.getRetiredWellInfo().getMaxWellCopyVolume().getRemainingVolume();
        }
    };
    c.setVisible(false);
    columns.add(c);

    c = new TextColumn<WellVolume>("Max Remaining Volume Copy (Retired)",
            "The copy with the maximum remaining volume of this well", TableColumn.UNGROUPED) {
        @Override
        public String getCellValue(WellVolume wellVolume) {
            return wellVolume.getRetiredWellInfo().getMaxWellCopyVolume().getCopy().getName();
        }
    };
    c.setVisible(false);
    columns.add(c);

    c = new VolumeColumn<WellVolume>("Min Remaining Volume (Retired)",
            "The minimum remaining volume of this well, across all copies", TableColumn.UNGROUPED) {
        @Override
        public Volume getCellValue(WellVolume wellVolume) {
            return wellVolume.getRetiredWellInfo().getMinWellCopyVolume().getRemainingVolume();

        }
    };
    c.setVisible(false);
    columns.add(c);

    c = new TextColumn<WellVolume>("Min Remaining Volume Copy (Retired)",
            "The copy with the minimum remaining volume of this well", TableColumn.UNGROUPED) {
        @Override
        public String getCellValue(WellVolume wellVolume) {
            return wellVolume.getRetiredWellInfo().getMinWellCopyVolume().getCopy().getName();
        }
    };
    c.setVisible(false);
    columns.add(c);

    // done - retired hidden columns - //

    columns.add(new IntegerColumn<WellVolume>("Withdrawals/Adjustments",
            "The number of withdrawals and administrative adjustments made from this well, across all copies",
            TableColumn.UNGROUPED) {
        @Override
        public Integer getCellValue(WellVolume wellVolume) {
            return wellVolume.getWellVolumeAdjustmentCount();
        }

        @Override
        public boolean isCommandLink() {
            return getRowData().getWellVolumeAdjustmentCount() > 0;
        }

        @Override
        public Object cellAction(WellVolume wellVolume) {
            return null;
            // return showRowDetail();
        }
    });

    // TableColumnManager<Well> columnManager = getColumnManager();
    // columnManager.addCompoundSortColumns(columnManager.getColumn("Library"),
    // columnManager.getColumn("Plate"), columnManager.getColumn("Well"));
    // columnManager.addCompoundSortColumns(columnManager.getColumn("Plate"),
    // columnManager.getColumn("Well"));
    // columnManager.addCompoundSortColumns(columnManager.getColumn("Well"),
    // columnManager.getColumn("Plate"));
    // columnManager.addCompoundSortColumns(columnManager.getColumn("Copies"),
    // columnManager.getColumn("Plate"), columnManager.getColumn("Well"),
    // columnManager.getColumn("Copies"));
    // columnManager.addCompoundSortColumns(columnManager.getColumn("Initial
    // Volume"), columnManager.getColumn("Plate"), columnManager.getColumn("Well"),
    // columnManager.getColumn("Copies"));
    // columnManager.addCompoundSortColumns(columnManager.getColumn("Consumed
    // Volume"), columnManager.getColumn("Plate"), columnManager.getColumn("Well"),
    // columnManager.getColumn("Copies"));
    // columnManager.addCompoundSortColumns(columnManager.getColumn("Max Remaining
    // Volume"), columnManager.getColumn("Plate"), columnManager.getColumn("Well"),
    // columnManager.getColumn("Copies"));
    // columnManager.addCompoundSortColumns(columnManager.getColumn("Min Remaining
    // Volume"), columnManager.getColumn("Plate"), columnManager.getColumn("Well"),
    // columnManager.getColumn("Copies"));

    return columns;
}

From source file:org.eel.kitchen.jsonschema.keyword.DependenciesKeywordValidator.java

private void computeSimpleDep(final String field, final Set<String> fields, final ValidationReport report) {
    final Set<String> expected = simple.get(field);
    final SortedSet<String> missing = Sets.newTreeSet(expected);
    missing.removeAll(fields);/*w  w w .j  a va  2 s  .c  o m*/

    if (missing.isEmpty())
        return;

    final ValidationMessage.Builder msg = newMsg().setMessage("missing property dependencies")
            .addInfo("property", field).addInfo("missing", missing)
            .addInfo("expected", Sets.newTreeSet(expected));
    report.addMessage(msg.build());
}

From source file:caveworld.core.CaveBiomeManager.java

@Override
public Set<ICaveBiome> getCaveBiomes() {
    Set<ICaveBiome> result = Sets.newTreeSet(CaveBiome.caveBiomeComparator);
    result.addAll(getCaveBiomeMap().values());

    return result;
}

From source file:edu.harvard.med.screensaver.ui.arch.datatable.column.ColumnType.java

private ColumnType(boolean isNumeric, Converter converter, Set<Operator> validOperators,
        Operator defaultOperator) {/* w  w w  . j av  a2s .c o m*/
    _isNumeric = isNumeric;
    _converter = converter;
    _validOperators = validOperators;
    _defaultOperator = defaultOperator;
    for (Operator operator : Sets.newTreeSet(validOperators)) {
        _operatorSelections.add(new SelectItem(operator, operator.getSymbol()));
    }
}

From source file:com.android.sdklib.repositoryv2.targets.PlatformTarget.java

/**
 * Construct a new {@code PlatformTarget} based on the given package.
 *//*from w  w  w .  ja  v a  2s  .  c  o m*/
public PlatformTarget(@NonNull LocalPackage p, @NonNull AndroidSdkHandler sdkHandler, @NonNull FileOp fop,
        @NonNull ProgressIndicator progress) {
    mPackage = p;
    TypeDetails details = p.getTypeDetails();
    assert details instanceof DetailsTypes.PlatformDetailsType;
    mDetails = (DetailsTypes.PlatformDetailsType) details;

    File optionalDir = new File(p.getLocation(), "optional");
    if (optionalDir.isDirectory()) {
        File optionalJson = new File(optionalDir, "optional.json");
        if (optionalJson.isFile()) {
            mOptionalLibraries = getLibsFromJson(optionalJson);
        }
    }

    File buildProp = new File(getLocation(), SdkConstants.FN_BUILD_PROP);

    if (!fop.isFile(buildProp)) {
        String message = "Build properties not found for package " + p.getDisplayName();
        progress.logWarning(message);
        throw new IllegalArgumentException(message);
    }

    try {
        mBuildProps = ProjectProperties.parsePropertyStream(fop.newFileInputStream(buildProp),
                buildProp.getPath(), null);
    } catch (FileNotFoundException ignore) {
    }
    if (mBuildProps == null) {
        mBuildProps = Maps.newHashMap();
    }
    mBuildToolInfo = sdkHandler.getLatestBuildTool(progress);

    mSkins = Sets.newTreeSet(PackageParserUtils.parseSkinFolder(getFile(IAndroidTarget.SKINS), fop));
}

From source file:com.continuuity.loom.scheduler.dag.TaskDag.java

@Override
public String toString() {
    StringBuilder output = new StringBuilder();
    Comparator<TaskNode> comparator = new TaskNodeComparator();
    TreeSet<TaskNode> nodes = Sets.newTreeSet(comparator);
    nodes.addAll(this.nodes);
    SetMultimap<TaskNode, TaskNode> edges = TreeMultimap.create(comparator, comparator);
    edges.putAll(this.edges);
    output.append("services:\n");
    for (TaskNode node : nodes) {
        output.append(node);//from  w  w w.j  a  v  a2  s  .c  o  m
        output.append("\n");
    }
    output.append("edges:\n");
    for (TaskNode startNode : edges.keySet()) {
        output.append("  ");
        output.append(startNode);
        output.append("\n");
        for (TaskNode endNode : edges.get(startNode)) {
            output.append("    -> ");
            output.append(endNode);
            output.append("\n");
        }
    }
    return output.toString();
}

From source file:com.puppycrawl.tools.checkstyle.checks.TranslationCheck.java

/**
 * Sets language codes of required translations for the check.
 * @param translationCodes a comma separated list of language codes.
 *///from   w  w  w.  j  a  v  a 2  s  .  c o m
public void setRequiredTranslations(String translationCodes) {
    requiredTranslations = Sets
            .newTreeSet(Splitter.on(',').trimResults().omitEmptyStrings().split(translationCodes));
}

From source file:com.google.gerrit.sshd.DispatchCommand.java

@Override
protected String usage() {
    final StringBuilder usage = new StringBuilder();
    usage.append("Available commands");
    if (!getName().isEmpty()) {
        usage.append(" of ");
        usage.append(getName());/* w ww. ja v  a2 s .  com*/
    }
    usage.append(" are:\n");
    usage.append("\n");

    int maxLength = -1;
    for (String name : commands.keySet()) {
        maxLength = Math.max(maxLength, name.length());
    }
    String format = "%-" + maxLength + "s   %s";
    for (String name : Sets.newTreeSet(commands.keySet())) {
        final CommandProvider p = commands.get(name);
        usage.append("   ");
        usage.append(String.format(format, name, Strings.nullToEmpty(p.getDescription())));
        usage.append("\n");
    }
    usage.append("\n");

    usage.append("See '");
    if (getName().indexOf(' ') < 0) {
        usage.append(getName());
        usage.append(' ');
    }
    usage.append("COMMAND --help' for more information.\n");
    usage.append("\n");
    return usage.toString();
}