List of usage examples for com.google.common.collect Sets newTreeSet
public static <E extends Comparable> TreeSet<E> newTreeSet()
From source file:de.matzefratze123.heavyspleef.core.FlagManager.java
public FlagManager(JavaPlugin plugin, GamePropertyBundle defaults) { this.plugin = plugin; this.defaults = defaults; this.flags = Maps.newLinkedHashMap(); this.propertyBundles = Sets.newTreeSet(); this.requestedProperties = new DefaultGamePropertyBundle(Maps.newEnumMap(GameProperty.class)); }
From source file:com.metamx.druid.index.v1.Rowboat.java
public void addRow(int indexNum, int rowNum) { TreeSet<Integer> rowNums = comprisedRows.get(indexNum); if (rowNums == null) { rowNums = Sets.newTreeSet(); comprisedRows.put(indexNum, rowNums); }/* www . j av a 2s .co m*/ rowNums.add(rowNum); }
From source file:com.ebay.xcelite.writer.BeanSheetWriter.java
@SuppressWarnings("unchecked") private void writeData(Collection<T> data) { try {//from w w w . j ava 2s.c om Set<Col> columnsToAdd = Sets.newTreeSet(); for (T t : data) { if (anyColumn != null) { appendAnyColumns(t, columnsToAdd); } } addColumns(columnsToAdd, true); for (T t : data) { org.apache.poi.ss.usermodel.Row row = sheet.getNativeSheet().createRow(rowIndex); int i = 0; for (Col col : columns) { Set<Field> fields = ReflectionUtils.getAllFields(t.getClass(), withName(col.getFieldName())); Field field = fields.iterator().next(); field.setAccessible(true); Object fieldValueObj = null; if (col.isAnyColumn()) { Map<String, Object> anyColumnMap = (Map<String, Object>) field.get(t); fieldValueObj = anyColumnMap.get(col.getName()); } else { fieldValueObj = field.get(t); } Cell cell = row.createCell(i); writeToCell(cell, col, fieldValueObj); i++; } rowIndex++; } } catch (SecurityException e) { throw new RuntimeException(e); } catch (IllegalArgumentException e) { throw new RuntimeException(e); } catch (IllegalAccessException e) { throw new RuntimeException(e); } }
From source file:co.cask.cdap.data.stream.MultiLiveStreamFileReader.java
public MultiLiveStreamFileReader(StreamConfig streamConfig, Iterable<? extends StreamFileOffset> offsets) { this.allSources = Sets.newTreeSet(); for (StreamFileOffset source : offsets) { StreamEventSource eventSource = new StreamEventSource(streamConfig, source); allSources.add(eventSource);/*from w w w. ja v a 2 s .co m*/ } this.eventSources = new ObjectHeapPriorityQueue<>(allSources.size()); this.emptySources = Sets.newHashSet(allSources); this.offsetsView = Iterables.transform(allSources, new Function<StreamEventSource, StreamFileOffset>() { @Override public StreamFileOffset apply(StreamEventSource input) { return input.getPosition(); } }); }
From source file:blockplus.model.OptionsSupplier.java
private Map<IPosition, Set<IPosition>> getPotentialPositionsByLight(final Board board, final Colors color, final Iterable<IPosition> lights, final int radius) { final Map<IPosition, Set<IPosition>> map = Maps.newLinkedHashMap(); for (final IPosition light : lights) { final Set<IPosition> potentialReferentialPositions = Sets.newTreeSet(); for (int k = 0; k <= radius; ++k) for (final IPosition neighbour : board.neighbours(light, k)) if (board.isMutable(color, neighbour)) potentialReferentialPositions.add(neighbour); map.put(light, potentialReferentialPositions); }//from ww w .j a va 2s . c o m return map; }
From source file:com.gu.management.spring.ManagementUrlDiscoveryService.java
private Set<String> getAllRequestableUrls(AbstractUrlHandlerMapping urlHandlerMappings) { Set<String> urls = Sets.newTreeSet(); Map<String, Object> urlMap = urlHandlerMappings.getHandlerMap(); for (Entry<String, Object> urlMapping : urlMap.entrySet()) { String url = urlMapping.getKey(); Object controller = urlMapping.getValue(); if (!url.contains("*")) { LOGGER.debug(""); LOGGER.debug(String.format( "Adding %s provided by %s without further inspection because it's not a wildcard url", url, controller));//from w w w . j a v a2s. com urls.add(url); } else { LOGGER.debug(String.format("Inspecting for urls under %s provided by %s...", url, controller)); urls.addAll(getUrlsForController(url, controller)); LOGGER.debug(String.format("Inspected for urls under %s provided by %s", url, controller)); } } return urls; }
From source file:org.apache.blur.command.TermsCommand.java
@Override public List<String> combine(CombiningContext context, Map<? extends Location<?>, List<String>> results) throws IOException, InterruptedException { SortedSet<String> terms = Sets.newTreeSet(); for (List<String> t : results.values()) { terms.addAll(t);// ww w . j a v a 2s . com } return Lists.newArrayList(terms).subList(0, Math.min((int) size, terms.size())); }
From source file:com.threerings.presents.tools.cpp.GenCPPServiceTask.java
@Override protected void generateMarshaller(File source, ServiceDescription sdesc) throws Exception { String name = sdesc.sname.replace("Service", "Marshaller"); String mpackage = sdesc.spackage.replace(".client", ".data"); List<String> namespaces = makeNamespaces(mpackage); Map<String, Object> ctx = Maps.newHashMap(); ctx.put("name", name); ctx.put("javaName", mpackage + "." + name); ctx.put("namespaces", namespaces); ctx.put("namespace", Joiner.on("::").join(namespaces)); ctx.put("methods", MethodDescriptor.from(sdesc.methods)); ctx.put("listeners", sdesc.listeners); ctx.put("argbuilder", new CPPArgBuilder()); Set<String> includes = Sets.newTreeSet(); Set<String> implIncludes = Sets.newTreeSet(); for (ServiceMethod meth : sdesc.methods) { for (Type type : meth.method.getGenericParameterTypes()) { CPPType cppType = new CPPType(type); if (cppType.primitive) { implIncludes.add("presents/box/Boxed" + cppType.interpreter + ".h"); }/*from ww w .j a v a 2s. c o m*/ while (cppType != null) { if (cppType.representationImport != null) { includes.add(cppType.representationImport); } cppType = cppType.dependent; } } } ctx.put("includes", implIncludes); writeTemplate(CPP_TMPL, makePath(_cpproot, namespaces, name, ".cpp"), ctx); ctx.put("includes", includes); writeTemplate(HEADER_TMPL, makePath(_cpproot, namespaces, name, ".h"), ctx); super.generateMarshaller(source, sdesc); }
From source file:edu.harvard.med.screensaver.db.CellsDAOImpl.java
@Override public SortedSet<ExperimentalCellInformation> findCellExperimentsFromCLOIds(String[] cloIds) { Set<Cell> cells = findCellsByCloIds(cloIds); SortedSet<ExperimentalCellInformation> icis = Sets.newTreeSet(); for (Cell cell : cells) { icis.addAll(_dao.findEntitiesByProperty(ExperimentalCellInformation.class, "cell", cell)); }// w ww. ja v a2 s. c om log.debug("found: " + icis.size() + " icis for this list of cells"); return icis; }
From source file:ru.frostman.web.plugin.JavinPlugins.java
/** * Reload all Javin plugins and return aggregated plugin to run some handlers. * * @return true if app classes should be reloaded *//* w w w . ja va 2s.c om*/ public static boolean update() { if (instance != null && Objects.equal(instance.loadedPlugins, JavinConfig.get().getPlugins())) { return instance.reload(); } else { List<String> pluginClassNames = JavinConfig.get().getPlugins(); Set<Plugin> newPlugins = Sets.newTreeSet(); for (String pluginClassName : pluginClassNames) { Class pluginRawClass; try { pluginRawClass = Class.forName(pluginClassName); } catch (ClassNotFoundException e) { log.warn("Unable to load plugin with main class: " + pluginClassName); continue; } if (Plugin.class.isAssignableFrom(pluginRawClass)) { Plugin plugin; try { plugin = (Plugin) pluginRawClass.newInstance(); } catch (Exception e) { throw new JavinPluginException( "Exception while instantiating plugin with main class: " + pluginClassName, e); } newPlugins.add(plugin); } else { throw new JavinPluginException( "There is class not inherited from Plugin in plugins list: " + pluginClassName); } } instance = new JavinPlugins(Lists.<String>newLinkedList(pluginClassNames), Lists.<Plugin>newLinkedList(newPlugins)); return instance.reload(); } }