List of usage examples for com.google.common.collect Sets newTreeSet
public static <E extends Comparable> TreeSet<E> newTreeSet()
From source file:net.sf.uadetector.internal.data.DataBlueprint.java
public DataBlueprint() { final TreeSet<BrowserPattern> browserPatternSet = Sets.newTreeSet(); final BrowserPattern browserPattern = new BrowserPattern(1, Pattern.compile("[a-z]+"), 1); browserPatternSet.add(browserPattern); browserPatterns.put(1, browserPatternSet); final SortedSet<OperatingSystemPattern> osPatternSet = new TreeSet<OperatingSystemPattern>(); final OperatingSystemPattern operatingSystemPattern = new OperatingSystemPattern(1, Pattern.compile("1"), 1);//from w ww .ja va2s . co m osPatternSet.add(operatingSystemPattern); final OperatingSystem operatingSystem = new OperatingSystem(1, "n1", "f1", "iu1", osPatternSet, "p1", "pu1", "u1", "i1"); operatingSystems.add(operatingSystem); patternToOperatingSystemMap.put(operatingSystemPattern, operatingSystem); final BrowserType browserType = new BrowserType(1, "Browser"); browserTypes.put(browserType.getId(), browserType); final Browser browser = new Browser(4256, UserAgentFamily.FIREBIRD, UserAgentFamily.FIREBIRD.getName(), browserPatternSet, browserType, operatingSystem, "icn", "iu1", "p1", "pu1", "u1"); browsers.add(browser); patternToBrowserMap.put(browserPattern, browser); browserToOperatingSystemMappings .add(new BrowserOperatingSystemMapping(browser.getId(), operatingSystem.getId())); final TreeSet<DevicePattern> devicePatternSet = Sets.newTreeSet(); final DevicePattern devicePattern = new DevicePattern(1, Pattern.compile("[a-z]+"), 1); devicePatternSet.add(devicePattern); devicePatterns.put(1, devicePatternSet); final Device device = new Device("device-category-name", 1, Category.OTHER, "device.png", "device-info", devicePatternSet); devices.add(device); patternToDeviceMap.put(devicePattern, device); final Robot robot = new Robot(12, "Majestic-12", UserAgentFamily.MJ12BOT, "Majestic-12 bot", "http://majestic12.co.uk/bot.php", "Majestic-12", "http://www.majestic12.co.uk/", "MJ12bot/v1.4.3", "mj12.png"); robots.add(robot); }
From source file:com.google.testing.pogen.parser.template.VariableInfo.java
/** * Constructs the information of a template variable with the specified name, the specified start * position and the specified attribute name. * /*from ww w. j av a2 s . c om*/ * @param printCommandText the command text to print the template variable * @param name the name of this template variable * @param startIndex the start position of this template variable in the parsed template * @param containedByText the boolean whether this template variable is contained by a text * element * @param manipulableTag the boolean whether this template variable is dummy for * the manipulable tags such as a and input */ public VariableInfo(String printCommandText, String name, int startIndex, boolean containedByText, boolean manipulableTag) { Preconditions.checkArgument(!Strings.isNullOrEmpty(name)); Preconditions.checkArgument(startIndex >= 0); this.printCommandText = printCommandText; name = NameConverter.replaceSignsToTexts(name); this.name = NameConverter.getJavaIdentifier(name); this.startIndex = startIndex; this.attributeNames = Sets.newTreeSet(); this.containedByText = containedByText; this.manipulableTag = manipulableTag; }
From source file:org.smartdeveloperhub.vocabulary.util.VocabularyHelper.java
Set<String> prefixes() { final Namespace namespace = Namespace.create(this.module.ontology()); final Multimap<String, String> prefixes = namespacePrefixes(); final SortedSet<String> nsPrefixes = Sets.newTreeSet(); for (final String ns : namespace.variants()) { final Collection<String> collection = prefixes.get(ns); if (collection != null) { nsPrefixes.addAll(collection); }/*from ww w . ja v a 2s . c om*/ } return nsPrefixes; }
From source file:org.ambraproject.wombat.config.theme.FileTheme.java
protected Collection<String> fetchStaticResourcePaths(String searchRoot) throws IOException { File searchRootFile = new File(root, searchRoot); Set<String> filePaths = Sets.newTreeSet(); Deque<File> queue = new ArrayDeque<>(); queue.add(searchRootFile);// w ww . jav a 2s. co m while (!queue.isEmpty()) { File file = queue.removeFirst(); if (file.isDirectory()) { queue.addAll(Arrays.asList(file.listFiles())); } else if (file.exists()) { String relativePath = file.getAbsolutePath() .substring(searchRootFile.getAbsolutePath().length() + 1); filePaths.add(relativePath); } } return filePaths; }
From source file:de.tuberlin.uebb.jdae.transformation.InitializationCausalisation.java
public InitializationCausalisation(final InitializationMatching matching, final Logger logger) { logger.log(Level.INFO, "Starting initial dependency analysis."); final TransitiveRelation<Integer> depends = Relations.newTransitiveRelation(); final List<Integer> sorted = Lists.newArrayList(); final int n = matching.assignment.length; final List<DerivedEquation> eqns = matching.allEquations; /* ensure derived equations are in same block as their originals */ for (int i = 1; i < n; i++) { if (eqns.get(i).eqn == eqns.get(i - 1).eqn) { depends.relate(i, i - 1);/*from w ww. j a va 2 s. c o m*/ depends.relate(i - 1, i); } } for (int i = 0; i < n; i++) { for (GlobalVariable v : eqns.get(i).need()) { final int j = matching.inverse[matching.numberOf(v)]; depends.relate(i, j); } sorted.add(i); } final Comparator<Integer> depCompare = new Comparator<Integer>() { @Override public int compare(Integer a, Integer b) { final boolean a_dep_b = depends.areRelated(a, b); final boolean b_dep_a = depends.areRelated(b, a); if (a_dep_b && b_dep_a) return 0; else if (a_dep_b) { return 1; } else { return -1; } } }; Collections.sort(sorted, depCompare); computations = Lists.newArrayList(); iteratees = Lists.newArrayList(); int k = 0; while (k < n) { final Set<GlobalVariable> blockVars = Sets.newTreeSet(); final Map<GlobalEquation, DerivedEquation> blockEqns = Maps.newHashMap(); final Integer eq = sorted.get(k); int l = 0; while ((k + l) < n && depCompare.compare(eq, sorted.get(k + l)) == 0) { final int i = sorted.get(k + l); final int j = matching.assignment[i]; final DerivedEquation derivedEquation = eqns.get(i); if (blockEqns.containsKey(derivedEquation.eqn) && blockEqns.get(derivedEquation.eqn).maxOrder > derivedEquation.maxOrder) { // Do nothing } else { blockEqns.put(derivedEquation.eqn, derivedEquation); } blockVars.add(matching.variables[j]); l++; } k += l; logger.log(Level.INFO, "Initialization block of {0} equation(s) computing {1}", new Object[] { blockEqns.size(), blockVars }); computations.add(ImmutableSet.copyOf(blockEqns.values())); iteratees.add(blockVars); } }
From source file:org.obiba.opal.core.service.security.DefaultSubjectAclService.java
@Override public void deleteNodePermissions(String node) { Iterable<SubjectAcl> subjectAcls = orientDbService.list(SubjectAcl.class, "select from " + SubjectAcl.class.getSimpleName() + " where node = ? or node like ?", node, node + "/%"); Set<Subject> subjects = Sets.newTreeSet(); for (SubjectAcl acl : subjectAcls) { subjects.add(acl.getSubject());// w w w. j av a 2 s . co m delete(acl); } notifyListeners(subjects); }
From source file:org.incode.eurocommercial.contactapp.dom.contacts.ContactRepository.java
@Programmatic public java.util.List<Contact> findByContactRoleName(String regex) { java.util.SortedSet<Contact> contacts = Sets.newTreeSet(); for (ContactRole contactRole : contactRoleRepository.findByName(regex)) { contacts.add(contactRole.getContact()); }/*from w ww .j a v a 2s . co m*/ return asSortedList(contacts); }
From source file:org.gradle.cache.internal.UnusedVersionsCacheCleanup.java
private void determineUsedVersions() { usedVersions = Sets.newTreeSet(); for (GradleVersion gradleVersion : getUsedGradleVersionsSmallerThanCurrent()) { usedVersions.addAll(cacheVersionMapping.getVersionUsedBy(gradleVersion).asSet()); }//www. j a v a2 s.c o m }
From source file:com.gwtplatform.dispatch.rest.delegates.rebind.DelegateGenerator.java
@Override public DelegateDefinition generate(ResourceDefinition resourceDefinition) throws UnableToCompleteException { this.resourceDefinition = resourceDefinition; imports = Sets.newTreeSet(); imports.add(RestAction.class.getName()); imports.add(resourceDefinition.getResourceInterface().getQualifiedSourceName()); imports.add(resourceDefinition.getQualifiedName()); methodDefinitions = Lists.newArrayList(); generateMethods();//from w ww .j av a 2s .com PrintWriter printWriter = tryCreate(); mergeTemplate(printWriter); commit(printWriter); maybeRegisterGinBinding(); DelegateDefinition definition = new DelegateDefinition(getPackageName(), getImplName(), resourceDefinition, methodDefinitions); generatedDelegates.add(definition); return definition; }
From source file:indigo.invariants.LogicExpression.java
public Set<String> getConstrainedSets() { Set<String> constrainedSets = Sets.newTreeSet(); parsedExpr.evaluate(new GetContrainedSets(constrainedSets)); return constrainedSets; }