List of usage examples for com.google.common.collect Sets newTreeSet
public static <E extends Comparable> TreeSet<E> newTreeSet()
From source file:org.kiji.schema.tools.LsTool.java
/** * Returns a set of instance names.//w w w .j ava2 s .c o m * * @param hbaseURI URI of the HBase instance to list the content of. * @return ordered set of instance names. * @throws IOException on I/O error. */ protected static Set<String> getInstanceNames(KijiURI hbaseURI) throws IOException { // TODO(SCHEMA-188): Consolidate this logic in a single central place: final Configuration conf = HBaseConfiguration.create(); conf.set(HConstants.ZOOKEEPER_QUORUM, Joiner.on(",").join(hbaseURI.getZookeeperQuorumOrdered())); conf.setInt(HConstants.ZOOKEEPER_CLIENT_PORT, hbaseURI.getZookeeperClientPort()); final HBaseAdmin hbaseAdmin = HBaseFactory.Provider.get().getHBaseAdminFactory(hbaseURI).create(conf); try { final Set<String> instanceNames = Sets.newTreeSet(); for (HTableDescriptor hTableDescriptor : hbaseAdmin.listTables()) { final String instanceName = parseInstanceName(hTableDescriptor.getNameAsString()); if (null != instanceName) { instanceNames.add(instanceName); } } return instanceNames; } finally { ResourceUtils.closeOrLog(hbaseAdmin); } }
From source file:org.kiji.schema.impl.KijiResultRowData.java
/** {@inheritDoc} */ @Override//from ww w . j a va2 s .c o m public NavigableSet<String> getQualifiers(final String family) { final KijiColumnName column = KijiColumnName.create(family, null); validateColumnRequest(column); final NavigableSet<String> qualifiers = Sets.newTreeSet(); for (final KijiCell<?> cell : mResult.narrowView(column)) { qualifiers.add(cell.getColumn().getQualifier()); } return qualifiers; }
From source file:com.moz.fiji.schema.tools.LsTool.java
/** * Returns a set of instance names.//w w w .j a va 2 s. c o m * * @param hbaseURI URI of the HBase instance to list the content of. * @return ordered set of instance names. * @throws IOException on I/O error. */ protected static Set<String> getInstanceNames(FijiURI hbaseURI) throws IOException { // TODO(SCHEMA-188): Consolidate this logic in a single central place: final Configuration conf = HBaseConfiguration.create(); conf.set(HConstants.ZOOKEEPER_QUORUM, Joiner.on(",").join(hbaseURI.getZookeeperQuorumOrdered())); conf.setInt(HConstants.ZOOKEEPER_CLIENT_PORT, hbaseURI.getZookeeperClientPort()); final HBaseAdmin hbaseAdmin = HBaseFactory.Provider.get().getHBaseAdminFactory(hbaseURI).create(conf); try { final Set<String> instanceNames = Sets.newTreeSet(); for (HTableDescriptor hTableDescriptor : hbaseAdmin.listTables()) { final String instanceName = parseInstanceName(hTableDescriptor.getNameAsString()); if (null != instanceName) { instanceNames.add(instanceName); } } return instanceNames; } finally { ResourceUtils.closeOrLog(hbaseAdmin); } }
From source file:org.eclipse.wb.internal.swing.model.property.editor.font.UiManagerFontPage.java
/** * Prepares {@link FontInfo}'s for {@link Font}'s from {@link UIManager}. *//* w w w . jav a 2s .c om*/ private static void prepareFonts() { if (m_fonts == null) { m_fonts = Lists.newArrayList(); UIDefaults defaults = UIManager.getLookAndFeelDefaults(); // prepare set of all String keys in UIManager Set<String> allKeys = Sets.newTreeSet(); for (Iterator<?> I = defaults.keySet().iterator(); I.hasNext();) { Object key = I.next(); if (key instanceof String) { allKeys.add((String) key); } } // add FontInfo for each Font key for (String key : allKeys) { Font font = defaults.getFont(key); if (font != null) { UiManagerFontInfo fontInfo = new UiManagerFontInfo(key, font); m_fonts.add(fontInfo); } } } }
From source file:blockplus.model.polyomino.PolyominoInstances.java
private static SortedSet<IPosition> translatePositions(final Iterable<IPosition> positions, final Direction direction) { final SortedSet<IPosition> newPositions = Sets.newTreeSet(); for (final IPosition position : positions) newPositions.add(position.apply(direction)); return newPositions; }
From source file:com.moz.fiji.schema.impl.FijiResultRowData.java
/** {@inheritDoc} */ @Override/*from www.j ava 2 s . com*/ public NavigableSet<String> getQualifiers(final String family) { final FijiColumnName column = FijiColumnName.create(family, null); validateColumnRequest(column); final NavigableSet<String> qualifiers = Sets.newTreeSet(); for (final FijiCell<?> cell : mResult.narrowView(column)) { qualifiers.add(cell.getColumn().getQualifier()); } return qualifiers; }
From source file:ezbake.groups.service.query.AuthorizationQuery.java
@Override public Set<Long> getFromCachable(Collection<String> value) throws Exception { Set<Long> authorizations = Sets.newTreeSet(); try {//from w ww. j a v a 2s. c o m for (String member : value) { authorizations.add(Long.parseLong(member, 10)); } return authorizations; } catch (NumberFormatException e) { throw new Exception(e); } }
From source file:gov.nih.nci.caintegrator.external.biodbnet.BioDbNetSearchImpl.java
/** * {@inheritDoc}/* www . j ava2 s .co m*/ */ @Override public Set<GeneResults> retrieveGenesById(SearchParameters params) { Set<GeneResults> retrievedGenes = Sets.newTreeSet(); Db2DbParams db2dbParams = new Db2DbParams(); db2dbParams.setTaxonId(params.getTaxon().getTaxonId()); db2dbParams.setInput(GENE_LOOKUP_ID); db2dbParams.setOutputs(GENE_LOOKUP_OUTPUTS); db2dbParams.setInputValues(params.getInputValues()); String results = bioDbNetRemoteService.db2db(db2dbParams); CSVReader reader = new CSVReader(new StringReader(results), '\t', '\'', 1); try { List<String[]> lines = reader.readAll(); for (String[] nextLine : lines) { GeneResults gene = extractGene(nextLine); if (!emptyGene(gene)) { retrievedGenes.add(gene); } } } catch (IOException e) { LOG.error("Unabled to read dbBioNet gene results.", e); } finally { IOUtils.closeQuietly(reader); } return params.isFilterGenesOnStudy() && !retrievedGenes.isEmpty() ? filterGenes(retrievedGenes, params) : retrievedGenes; }
From source file:blockplus.transport.BlockplusGame.java
public IGame<Context> play(final IMoveSubmit moveSubmitInterface) { final Context context = this.getContext(); final SortedSet<IPosition> positions = Sets.newTreeSet(); for (final JsonElement element : moveSubmitInterface.getPositions()) { final int id = element.getAsInt(); final IPosition position = Position(id / 20, id % 20); // TODO !!! positions.add(position);/* w w w .ja v a2s . c om*/ } final Move move = new Move(context.side(), positions); return new BlockplusGame(this.getOrdinal(), this.getClients(), context.apply(move).forward(), this.isPaused); }
From source file:com.eucalyptus.loadbalancing.dns.LoadBalancerResolver.java
private static List<String> resolveName(final Name name) { final Name hostName = name.relativize(LoadBalancerDomainName.getLoadBalancerSubdomain()); final Optional<LoadBalancerDomainName> domainName = LoadBalancerDomainName.findMatching(hostName); final Set<String> ips = Sets.newTreeSet(); if (domainName.isPresent()) { final Pair<String, String> accountNamePair = domainName.get().toScopedLoadBalancerName(hostName); try (final TransactionResource tx = Entities.transactionFor(LoadBalancer.class)) { final LoadBalancer loadBalancer = LoadBalancers.getLoadbalancer(accountNamePair.getLeft(), accountNamePair.getRight()); final Predicate<LoadBalancerServoInstanceCoreView> canResolve = new Predicate<LoadBalancerServoInstanceCoreView>() { @Override/*from w w w. j a v a2s .c o m*/ public boolean apply(LoadBalancerServoInstanceCoreView arg0) { return arg0.canResolveDns(); } }; final List<LoadBalancerServoInstanceCoreView> servos = Lists.newArrayList(); for (final LoadBalancerAutoScalingGroupCoreView group : loadBalancer.getAutoScaleGroups()) { servos.addAll(INSTANCE.apply(group).getServos()); } final Function<LoadBalancerServoInstanceCoreView, String> ipExtractor = loadBalancer .getScheme() == LoadBalancer.Scheme.Internal ? LoadBalancerServoInstanceCoreView.privateIp() : LoadBalancerServoInstanceCoreView.address(); Iterables.addAll(ips, Iterables.transform(Collections2.filter(servos, canResolve), ipExtractor)); } } List<String> ipList = Lists.newArrayList(ips); Collections.sort(ipList); return ipList; }