List of usage examples for com.google.common.collect Sets newTreeSet
public static <E extends Comparable> TreeSet<E> newTreeSet()
From source file:org.apache.s4.example.twitter.TopNTopicPE.java
public void onTime() { TreeSet<TopNEntry> sortedTopics = Sets.newTreeSet(); for (Map.Entry<String, Integer> topicCount : countedTopics.entrySet()) { sortedTopics.add(new TopNEntry(topicCount.getKey(), topicCount.getValue())); }// w w w .j a va 2 s . co m File f = new File("TopNTopics.txt"); StringBuilder sb = new StringBuilder(); int i = 0; Iterator<TopNEntry> iterator = sortedTopics.iterator(); sb.append("----\n" + new SimpleDateFormat("yyyy-MMM-dd HH:mm:ss").format(new Date()) + "\n"); while (iterator.hasNext() && i < 10) { TopNEntry entry = iterator.next(); sb.append("topic [" + entry.topic + "] count [" + entry.count + "]\n"); i++; } sb.append("\n"); try { Files.append(sb.toString(), f, Charsets.UTF_8); logger.info("Wrote top 10 topics to file [{}] ", f.getAbsolutePath()); } catch (IOException e) { logger.error("Cannot write top 10 topics to file [{}]", f.getAbsolutePath(), e); } }
From source file:ezbake.security.api.ua.Authorizations.java
public void setAuths(Set<String> auths) { if (auths != null) this.auths = auths; else/*from www. j ava 2s . c o m*/ this.auths = Sets.newTreeSet(); }
From source file:com.facebook.buck.jvm.java.abi.ClassMirror.java
public ClassMirror(String name) { super(Opcodes.ASM5); this.fileName = name; this.annotations = Sets.newTreeSet(); this.fields = Sets.newTreeSet(); this.innerClasses = Sets.newTreeSet(); this.methods = Sets.newTreeSet(); }
From source file:org.sonar.php.checks.DuplicatedFunctionArgumentCheck.java
@Override public void visitParameterList(ParameterListTree parameterList) { Set<String> parameterNames = Sets.newHashSet(); Set<String> duplicatedParamNames = Sets.newTreeSet(); for (ParameterTree parameter : parameterList.parameters()) { String name = parameter.variableIdentifier().variableExpression().text(); boolean isNewName = parameterNames.add(name); if (!isNewName) { duplicatedParamNames.add(name); }/*from w w w . jav a 2s . c om*/ } if (!duplicatedParamNames.isEmpty()) { String listString = Joiner.on(", ").join(duplicatedParamNames); context() .newIssue(this, String.format(MESSAGE, duplicatedParamNames.size() == 1 ? "parameter" : "parameters", listString)) .tree(parameterList); } super.visitParameterList(parameterList); }
From source file:org.apache.whirr.cli.Main.java
private static SortedSet<String> getSortedRoleNames() { ServiceLoader<ClusterActionHandler> loader = ServiceLoader.load(ClusterActionHandler.class); SortedSet<String> roles = Sets.newTreeSet(); for (ClusterActionHandler handler : loader) { roles.add(handler.getRole());/*from w w w . j ava 2 s . com*/ } return roles; }
From source file:com.jeroensteenbeeke.andalite.forge.AbstractForgeRecipe.java
protected final ActionResult ensureSettings(String... keys) { Set<String> missing = Sets.newTreeSet(); for (String key : keys) { if (!extraSettings.containsKey(key)) { missing.add(key);/*from w w w . ja v a 2s . com*/ } } if (!missing.isEmpty()) { return ActionResult.error("Missing configuration options: %s", Joiner.on(", ").join(missing)); } return ActionResult.ok(); }
From source file:org.eclipse.wb.internal.swt.support.FontSupport.java
/** * @return names of all fonts into system. *///from w w w.ja v a2 s . c om public static String[] getFontFamilies() throws Exception { Set<String> families = Sets.newTreeSet(); // add all font families Collections.addAll(families, ToolkitSupport.getFontFamilies(false)); Collections.addAll(families, ToolkitSupport.getFontFamilies(true)); // add default font families.add(getFontName(getFontData(DisplaySupport.getSystemFont()))); // sort names String[] sortFamilies = families.toArray(new String[families.size()]); Arrays.sort(sortFamilies); return sortFamilies; }
From source file:blockplus.model.polyomino.PolyominoRenderer.java
private static SortedSet<IPosition> normalize(final SortedSet<IPosition> positions) { final SortedSet<IPosition> normalizedPositions = Sets.newTreeSet(); final IPosition topLeftCornerPosition = topLeftCorner(positions); for (final IPosition position : positions) { final int row = position.row() - topLeftCornerPosition.row(); final int column = position.column() - topLeftCornerPosition.column(); normalizedPositions.add(Position(row, column)); }//w w w.j a v a 2 s.c om return normalizedPositions; }
From source file:com.google.template.soy.jssrc.internal.GenFunctionPluginRequiresVisitor.java
public SortedSet<String> exec(SoyFileNode soyFile) { requiredJsLibNames = Sets.newTreeSet(); GenFunctionPluginRequiresHelperVisitor helperVisitor = new GenFunctionPluginRequiresHelperVisitor(); SoytreeUtils.execOnAllV2Exprs(soyFile, helperVisitor, errorReporter); return requiredJsLibNames; }
From source file:blockplus.model.polyomino.PolyominoInstances.java
private static SortedSet<IPosition> rotatePositions(final Iterable<IPosition> positions, final IPosition referential) { final SortedSet<IPosition> newPositions = Sets.newTreeSet(); for (final IPosition position : positions) newPositions.add(rotatePosition(position, referential)); return newPositions; }