List of usage examples for com.google.common.collect Sets newTreeSet
public static <E extends Comparable> TreeSet<E> newTreeSet()
From source file:sc.calendar.db.DbInterface.java
public SortedSet<CalendarEvent> getEvents(String calId) { SQLiteDatabase con = db.getReadableDatabase(); Cursor cursor = null;//from w w w .jav a 2 s .c o m try { cursor = con.rawQuery(GET_EVENTS_FOR_CAL, new String[] { calId }); SortedSet<CalendarEvent> out = Sets.newTreeSet(); if (cursor.moveToFirst()) { int startIndex = cursor.getColumnIndex(DbConnection.EVENTS_START_NAME); int endIndex = cursor.getColumnIndex(DbConnection.EVENTS_END_NAME); int idIndex = cursor.getColumnIndex(DbConnection.ID); int clearedIndex = cursor.getColumnIndex(DbConnection.EVENTS_CLEARED_NAME); int nameIndex = cursor.getColumnIndex(DbConnection.EVENTS_NAME_NAME); int calFkIndex = cursor.getColumnIndex(DbConnection.CALENDER_FK); do { CalendarEvent ce = new CalendarEvent(cursor.getLong(startIndex), cursor.getLong(endIndex), cursor.getString(nameIndex), cursor.getString(idIndex), cursor.getLong(clearedIndex) != 0, cursor.getString(calFkIndex)); out.add(ce); } while (cursor.moveToNext()); } return out; } finally { if (cursor != null) cursor.close(); con.close(); } }
From source file:com.google.devtools.j2objc.gen.ObjectiveCSourceFileGenerator.java
protected void printForwardDeclarations(Set<Import> forwardDecls) { Set<String> forwardStmts = Sets.newTreeSet(); for (Import imp : forwardDecls) { forwardStmts.add(createForwardDeclaration(imp.getTypeName(), imp.isInterface())); }/*from w w w . j a v a 2 s .c o m*/ if (!forwardStmts.isEmpty()) { newline(); for (String stmt : forwardStmts) { println(stmt); } } }
From source file:edu.buaa.satla.analysis.util.SourceLocationMapper.java
public static Set<Integer> collectTokensFrom(CAstNode astNode, boolean overApproximateTokens) { final TreeSet<Integer> result = Sets.newTreeSet(); Set<FileLocation> locs = collectFileLocationsFrom(astNode); for (FileLocation l : locs) { collectLine(result, l, overApproximateTokens); }// w ww.j av a2 s . com return result; }
From source file:fr.inria.oak.paxquery.algebra.optimizer.rules.PushProjections.java
/** * This method pushes down projections in a given logical plan while keeping the list of columns * that result from the plan unchanged.//from ww w. ja v a 2s . c om * * @param op * the root of the logical plan * @return the new root of the logical plan */ @Override public BaseLogicalOperator transform(BaseLogicalOperator op) { assert op instanceof XMLConstruct || op instanceof XMLTreeConstruct; // 1. Build the NRSMD of the operators in the tree op.getNRSMD(); // 2. Push projections down Set<ProjectColumn> requiredColumnsAbove = Sets.newTreeSet(); Set<ProjectColumn> opRequiredColumns = getRequiredInputColumns(op, requiredColumnsAbove); BaseLogicalOperator child = pushProjections(op.getChildren().get(0), opRequiredColumns); LogicalPlan.connect(op, child); ColumnsMapping updatedColumns = obtainMapping(opRequiredColumns); updateOperatorColumns(op, updatedColumns); op.buildOwnDetails(); // 3. Rebuild NRSMD op.resetNRSMD(); op.getNRSMD(); return op; }
From source file:com.android.tools.idea.avdmanager.SkinChooser.java
private List<File> getSkins() { List<Device> devices = DeviceManagerConnection.getDefaultDeviceManagerConnection().getDevices(); Set<File> result = Sets.newTreeSet(); for (Device device : devices) { File skinFile = AvdWizardUtils.resolveSkinPath(device.getDefaultHardware().getSkinFile(), null, FileOpUtils.create());//from ww w .ja v a2s .com if (skinFile != null && skinFile.exists()) { result.add(skinFile); } } StudioLoggerProgressIndicator progress = new StudioLoggerProgressIndicator(SkinChooser.class); AndroidSdkHandler sdkHandler = AndroidSdks.getInstance().tryToChooseSdkHandler(); for (IAndroidTarget target : sdkHandler.getAndroidTargetManager(progress).getTargets(progress)) { Arrays.stream(target.getSkins()).map(this::resolve).forEach(result::add); } for (ISystemImage img : sdkHandler.getSystemImageManager(progress).getImages()) { Arrays.stream(img.getSkins()).map(this::resolve).forEach(result::add); } List<File> resultList = Lists.newArrayList(); resultList.add(NO_SKIN); resultList.addAll(result); return resultList; }
From source file:ch.puzzle.itc.mobiliar.test.DeploymentInfo.java
public static Set<String> serverNames(List<DeploymentInfo> deployments) { Set<String> serverNames = Sets.newTreeSet(); for (DeploymentInfo info : deployments) { serverNames.add(info.appServer.getName()); }/* ww w .j av a2 s .c o m*/ return serverNames; }
From source file:com.google.template.soy.jssrc.internal.JsSrcUtils.java
public static String getJsTypeExpr(SoyType type, boolean addParensIfNeeded, boolean addRequiredIfNeeded) { String nonNullablePrefix = addRequiredIfNeeded ? "!" : ""; switch (type.getKind()) { case ANY:/*from w w w . j a va 2 s . c om*/ return "*"; case UNKNOWN: // Add parens to avoid confusion w/ the leading ? of a nullable type return "(?)"; case NULL: return "null"; case BOOL: return "boolean"; case STRING: return "string"; case INT: case FLOAT: return "number"; case LIST: { ListType listType = (ListType) type; if (listType.getElementType().getKind() == SoyType.Kind.ANY) { return nonNullablePrefix + "Array"; } return nonNullablePrefix + "Array<" + getJsTypeExpr(listType.getElementType(), false, true) + ">"; } case MAP: { MapType mapType = (MapType) type; if (mapType.getKeyType().getKind() == SoyType.Kind.ANY && mapType.getValueType().getKind() == SoyType.Kind.ANY) { return nonNullablePrefix + "Object<?,?>"; } String keyTypeName = getJsTypeExpr(mapType.getKeyType(), false, true); String valueTypeName = getJsTypeExpr(mapType.getValueType(), false, true); return nonNullablePrefix + "Object<" + keyTypeName + "," + valueTypeName + ">"; } case RECORD: { RecordType recordType = (RecordType) type; if (recordType.getMembers().isEmpty()) { return "!Object"; } List<String> members = Lists.newArrayListWithExpectedSize(recordType.getMembers().size()); for (Map.Entry<String, SoyType> member : recordType.getMembers().entrySet()) { members.add(member.getKey() + ": " + getJsTypeExpr(member.getValue(), true, true)); } return "{" + Joiner.on(", ").join(members) + "}"; } case UNION: { UnionType unionType = (UnionType) type; SortedSet<String> typeNames = Sets.newTreeSet(); boolean isNullable = unionType.isNullable(); boolean hasNullableMember = false; for (SoyType memberType : unionType.getMembers()) { if (memberType.getKind() == SoyType.Kind.NULL) { continue; } if (memberType instanceof SanitizedType) { typeNames.add(getJsTypeName(memberType)); typeNames.add("string"); hasNullableMember = true; continue; } if (JsSrcUtils.isDefaultOptional(memberType)) { hasNullableMember = true; } String typeExpr = getJsTypeExpr(memberType, false, !isNullable); if (typeExpr.equals("?")) { throw new IllegalStateException("Type: " + unionType + " contains an unknown"); } typeNames.add(typeExpr); } if (isNullable && !hasNullableMember) { typeNames.add("null"); } if (isNullable) { typeNames.add("undefined"); } if (typeNames.size() != 1) { String result = Joiner.on("|").join(typeNames); if (addParensIfNeeded) { result = "(" + result + ")"; } return result; } else { return typeNames.first(); } } default: if (type instanceof SanitizedType) { String result = NodeContentKinds .toJsSanitizedContentCtorName(((SanitizedType) type).getContentKind()) + "|string"; if (addParensIfNeeded) { result = "(" + result + ")"; } return result; } return getJsTypeName(type); } }
From source file:com.yahoo.yqlplus.api.types.Annotations.java
@Override public Iterator<Map.Entry<String, Object>> iterator() { // we don't expect much use of this final Set<String> seen = Sets.newTreeSet(); return Iterators.filter(Iterators.concat(annotations.entrySet().iterator(), parent.iterator()), new Predicate<Map.Entry<String, Object>>() { @Override/*w w w.j a va2 s. c o m*/ public boolean apply(Map.Entry<String, Object> input) { return seen.add(input.getKey()); } }); }
From source file:org.apache.tajo.master.QueryManager.java
@Deprecated public Collection<QueryInfo> getFinishedQueries() { Set<QueryInfo> result = Sets.newTreeSet(); synchronized (historyCache) { result.addAll(historyCache.values()); }/*w w w . j a va 2 s .c o m*/ try { result.addAll(this.masterContext.getHistoryReader().getQueriesInHistory()); return result; } catch (Throwable e) { LOG.error(e, e); return result; } }
From source file:org.glowroot.ui.ConfigJsonService.java
@GET(path = "/backend/config/transaction", permission = "agent:config:view:transaction") String getTransactionConfig(@BindAgentId String agentId) throws Exception { TransactionConfig config = configRepository.getTransactionConfig(agentId); Set<String> transactionTypes = Sets.newTreeSet(); transactionTypes.addAll(transactionTypeRepository.read(agentId)); transactionTypes.addAll(liveAggregateRepository.getTransactionTypes(agentId)); transactionTypes.add(configRepository.getUiDefaultsConfig(agentId).getDefaultTransactionType()); return mapper.writeValueAsString(ImmutableTransactionConfigResponse.builder() .config(TransactionConfigDto.create(config)) .defaultTransactionType(configRepository.getUiDefaultsConfig(agentId).getDefaultTransactionType()) .addAllAllTransactionTypes(transactionTypes).build()); }