List of usage examples for com.google.common.collect Sets newTreeSet
public static <E extends Comparable> TreeSet<E> newTreeSet()
From source file:blackboard.plugin.hayabusa.provider.ModuleItemProvider.java
@Override public Iterable<Command> getCommands() { try {//from w ww. j a v a2 s .c o m // TODO wire these dependencies as fields/constructor inject ModuleDbLoader moduleLoader = ModuleDbLoader.Default.getInstance(); NavigationItemDbLoader niLoader = NavigationItemDbLoader.Default.getInstance(); Multimap<Module, NavigationItemControl> nicByModule = ArrayListMultimap.create(); for (Module module : moduleLoader.heavyLoadByModuleType("bb/admin")) { String subgroup = module.getPortalExtraInfo().getExtraInfo().getValue("subgroup"); List<NavigationItemControl> nics = NavigationItemControl .createList(niLoader.loadBySubgroup(subgroup)); nicByModule.putAll(module, nics); } Set<Command> commands = Sets.newTreeSet(); for (Module module : nicByModule.keys()) { Collection<NavigationItemControl> nics = nicByModule.get(module); for (NavigationItemControl nic : nics) { if (!nic.userHasAccess()) { continue; } String title = String.format("%s: %s", module.getTitle(), nic.getLabel()); String url = FramesetUtil.getTabGroupUrl(blackboard.data.navigation.Tab.TabType.admin, nic.getUrl()); commands.add(new SimpleCommand(title, url, Category.SYSTEM_ADMIN)); } } return commands; } catch (PersistenceException e) { throw new PersistenceRuntimeException(e); } }
From source file:edu.harvard.med.screensaver.ui.libraries.ReagentFinder.java
private SortedSet<String> parseReagentIdentifier() throws IOException { SortedSet<String> parsedIdentifiers = Sets.newTreeSet(); BufferedReader inputReader = new BufferedReader(new StringReader(_reagentIdentifiersInput)); String identifier;//from www .ja va 2 s .c om while ((identifier = inputReader.readLine()) != null) { identifier = identifier.trim(); if (identifier.length() > 0) { parsedIdentifiers.add(identifier); } } return parsedIdentifiers; }
From source file:blackboard.plugin.hayabusa.provider.CourseProvider.java
private Iterable<Command> getAdminCourses() { try {/*from w w w.j a va2 s .c o m*/ List<Course> courses = CourseDbLoader.Default.getInstance().loadAllByServiceLevel(ServiceLevel.FULL); Set<Command> commands = Sets.newTreeSet(); for (Course course : courses) { String url = String.format(ADMIN_COURSE_URL_TEMPLATE, course.getId().toExternalString()); url = FramesetUtil.getTabGroupUrl(blackboard.data.navigation.Tab.TabType.courses, url); SimpleCommand command = new SimpleCommand(course.getTitle(), url, Category.COURSE); commands.add(command); } return commands; } catch (PersistenceException e) { throw new PersistenceRuntimeException(e); } }
From source file:org.apache.apex.malhar.lib.dimensions.aggregator.TopBottomAggregatorFactory.java
/** * The properties of TOP or BOTTOM are count and subCombinations. * count only have one value and subCombinations is a set of string, we can order combinations to simplify the name *///from w w w . ja v a2s . co m @Override protected String getNamePartialForProperties(Map<String, Object> properties) { StringBuilder sb = new StringBuilder(); String count = (String) properties.get(PROPERTY_NAME_COUNT); sb.append(count).append(PROPERTY_SEPERATOR); String[] subCombinations = (String[]) properties.get(PROPERTY_NAME_SUB_COMBINATIONS); Set<String> sortedSubCombinations = Sets.newTreeSet(); for (String subCombination : subCombinations) { sortedSubCombinations.add(subCombination); } for (String subCombination : sortedSubCombinations) { sb.append(subCombination).append(PROPERTY_SEPERATOR); } //delete the last one (PROPERTY_SEPERATOR) return sb.deleteCharAt(sb.length() - 1).toString(); }
From source file:com.github.strawberry.util.Types.java
public static Collection<?> collectionImplementationOf(Class<?> clazz) { Collection collection = null; // If it is a collection or list, use array-list as the implementation. if (clazz.equals(Collection.class) || clazz.equals(List.class)) { collection = Lists.newArrayList(); }// ww w . j a v a2s .c o m // If it is a set, fall back to using a linked hash-set as the implementation. else if (clazz.equals(Set.class)) { collection = Sets.newLinkedHashSet(); } // If it is a sorted set, fall back to using a tree-set as the implementation. else if (clazz.equals(SortedSet.class)) { collection = Sets.newTreeSet(); } // If it is a queue, fall back to using a linked-list. else if (clazz.equals(Queue.class)) { collection = Lists.newLinkedList(); } // Else, create implementation by calling constructor via reflection. else { collection = (Collection) implementationOf(clazz); } return collection; }
From source file:de.faustedition.xml.XMLQueryResource.java
@Get("html") public Representation queryForm() throws IOException { Map<String, Object> viewModel = new HashMap<String, Object>(); List<Map<String, Object>> files = queryExpression != null ? query() : Lists.<Map<String, Object>>newArrayList(); viewModel.put("folder", folder); viewModel.put("xpath", queryExpression); if (mode == Mode.XML || mode == Mode.FILES) { viewModel.put("files", files); } else if (mode == Mode.VALUES) { Set<String> uniqueValues = Sets.newTreeSet(); for (Map<String, Object> file : files) { if (file.containsKey("results")) { uniqueValues.addAll((List<String>) file.get("results")); }//ww w. j a va 2 s .com } viewModel.put("values", uniqueValues.toArray()); } if (mode != null) viewModel.put("mode", mode.toString().toLowerCase()); return viewFactory.create("xml-query", getRequest().getClientInfo(), viewModel); }
From source file:org.thiesen.jiffs.jobs.clusterer.ClusterFinder.java
private Set<String> makeAllWordsSet(final Iterable<String> firstWords, final Iterable<String> secondWords) { final Set<String> allWords = Sets.newTreeSet(); Iterables.addAll(allWords, firstWords); Iterables.addAll(allWords, secondWords); return allWords; }
From source file:org.obm.domain.dao.UserPatternDaoJdbcImpl.java
@VisibleForTesting Set<String> getUserPatterns(ObmUser user) { Set<String> patterns = Sets.newTreeSet(); patterns.add(user.getLogin());//from w w w.jav a 2s. c o m if (user.getLastName() != null) { Iterables.addAll(patterns, splitWords(user.getLastName())); } if (user.getFirstName() != null) { Iterables.addAll(patterns, splitWords(user.getFirstName())); } if (user.isEmailAvailable()) { patterns.add(user.getEmail()); patterns.addAll(user.getEmailAlias()); } return patterns; }
From source file:blackboard.plugin.hayabusa.provider.SendEmailProvider.java
@Override public Iterable<Command> getCommands() { try {/* w ww .j a v a 2 s.c o m*/ // TODO wire these dependencies as fields/constructor inject NavigationItemDbLoader niLoader = NavigationItemDbLoader.Default.getInstance(); // For admin List<NavigationItemControl> nics_admin = NavigationItemControl .createList(niLoader.loadByFamily(INTERNAL_HANDLER)); ModuleDbLoader moduleLoader = ModuleDbLoader.Default.getInstance(); Module module = moduleLoader.loadByExtRef("platform/admin-tools"); NavigationItemControl family = NavigationItemControl .createInstance(niLoader.loadByInternalHandle(INTERNAL_HANDLER)); Set<Command> commands = Sets.newTreeSet(); for (NavigationItemControl nic : nics_admin) { if (!nic.userHasAccess()) { continue; } String title = String.format("%s - %s: %s", module.getTitle(), family.getLabel(), nic.getLabel()); String url = FramesetUtil.getTabGroupUrl(blackboard.data.navigation.Tab.TabType.admin, nic.getUrl()); commands.add(new SimpleCommand(title, url, Category.SYSTEM_ADMIN)); } return commands; } catch (PersistenceException e) { throw new PersistenceRuntimeException(e); } }
From source file:org.locationtech.geogig.api.RevTreeBuilder.java
/** * Only useful to {@link #build() build} the named {@link #empty() empty} tree *///from ww w. java 2 s . c om private RevTreeBuilder() { db = null; treeChanges = Maps.newTreeMap(); featureChanges = Maps.newTreeMap(); deletes = Sets.newTreeSet(); bucketTreesByBucket = Maps.newTreeMap(); pendingWritesCache = Maps.newTreeMap(); }