List of usage examples for com.google.common.collect Sets newTreeSet
public static <E> TreeSet<E> newTreeSet(Comparator<? super E> comparator)
From source file:org.apache.brooklyn.cli.lister.ItemDescriptors.java
public static Map<String, Object> toItemDescriptor(Class<? extends BrooklynObject> clazz, boolean headingsOnly) { BrooklynDynamicType<?, ?> dynamicType = BrooklynTypes.getDefinedBrooklynType(clazz); BrooklynType type = dynamicType.getSnapshot(); ConfigKey<?> version = dynamicType.getConfigKey(BrooklynConfigKeys.SUGGESTED_VERSION.getName()); Map<String, Object> result = Maps.newLinkedHashMap(); result.put("type", clazz.getName()); if (version != null) { result.put("defaultVersion", version.getDefaultValue()); }//from w w w . j a va 2s . c o m Catalog catalogAnnotation = clazz.getAnnotation(Catalog.class); if (catalogAnnotation != null) { result.put("name", catalogAnnotation.name()); result.put("description", catalogAnnotation.description()); result.put("iconUrl", catalogAnnotation.iconUrl()); } Deprecated deprecatedAnnotation = clazz.getAnnotation(Deprecated.class); if (deprecatedAnnotation != null) { result.put("deprecated", true); } if (!headingsOnly) { Set<EntityConfigSummary> config = Sets.newTreeSet(SummaryComparators.nameComparator()); Set<SensorSummary> sensors = Sets.newTreeSet(SummaryComparators.nameComparator()); Set<EffectorSummary> effectors = Sets.newTreeSet(SummaryComparators.nameComparator()); for (ConfigKey<?> x : type.getConfigKeys()) { config.add(EntityTransformer.entityConfigSummary(x, dynamicType.getConfigKeyField(x.getName()))); } result.put("config", config); if (type instanceof EntityType) { for (Sensor<?> x : ((EntityType) type).getSensors()) sensors.add(SensorTransformer.sensorSummaryForCatalog(x)); result.put("sensors", sensors); for (Effector<?> x : ((EntityType) type).getEffectors()) effectors.add(EffectorTransformer.effectorSummaryForCatalog(x)); result.put("effectors", effectors); } } return result; }
From source file:org.fenixedu.qubdocs.academic.documentRequests.providers.ExtraCurricularCoursesDataProvider.java
public Set<CurriculumEntry> getCurriculumEntries() { if (this.curriculumEntries == null) { this.curriculumEntries = Sets.newTreeSet(CurriculumEntry.NAME_COMPARATOR(locale)); Collection<Registration> registrationList = includeAllRegistrations ? registration.getStudent().getActiveRegistrations() : Collections.singleton(registration); for (Registration activeRegistration : registrationList) { Collection<CurriculumLine> extraCurricularCurriculumLines = activeRegistration .getExtraCurricularCurriculumLines(); for (CurriculumLine curriculumLine : extraCurricularCurriculumLines) { if (curriculumLine.isEnrolment() && ((Enrolment) curriculumLine).isSourceOfAnyCreditsInCurriculum()) { continue; }/*from w w w . j av a 2 s . co m*/ if (curriculumLine.isDismissal() && !((Dismissal) curriculumLine).getCredits().isSubstitution()) { continue; } if (curriculumLine.isDismissal() && !includeSubstitutionCreditations) { continue; } curriculumEntries.addAll(CurriculumEntry.transform(registration, curriculumLine.getCurriculum().getCurriculumEntries(), remarksDataProvider)); } } if (registration.getDegree().isFirstCycle() && registration.getLastStudentCurricularPlan().getCycle(CycleType.SECOND_CYCLE) != null) { CycleCurriculumGroup cycle = registration.getLastStudentCurricularPlan() .getCycle(CycleType.SECOND_CYCLE); Collection<CurriculumLine> approvedCurriculumLines = cycle.getApprovedCurriculumLines(); for (final CurriculumLine curriculumLine : approvedCurriculumLines) { if (curriculumLine.isEnrolment() && !((Enrolment) curriculumLine).isSourceOfAnyCreditsInCurriculum()) { curriculumEntries.addAll(CurriculumEntry.transform(registration, curriculumLine.getCurriculum().getCurriculumEntries(), remarksDataProvider)); } } } } return this.curriculumEntries; }
From source file:io.janusproject.util.AbstractDMultiMapView.java
/** * Copy the given values.//from w w w. j a v a 2 s .co m * <p/> * The replies collection may be a {@link List} or * a {@link Set} according to the type of the * given values' collection. * * @param values - the values. * @return the copy. */ @SuppressWarnings("unchecked") Collection<V> copyValues(Collection<V> values) { Object backEnd = DataViewDelegate.undelegate(values); if (backEnd instanceof List<?>) { return Lists.newArrayList(values); } if (backEnd instanceof TreeSet<?>) { TreeSet<V> c = (TreeSet<V>) backEnd; c = Sets.newTreeSet(c.comparator()); c.addAll(values); return c; } if (backEnd instanceof LinkedHashSet<?>) { return Sets.newLinkedHashSet(values); } if (backEnd instanceof Set<?>) { return Sets.newHashSet(values); } throw new IllegalStateException("Unsupported type of the backend multimap: " + values.getClass()); //$NON-NLS-1$ }
From source file:org.fenixedu.qubdocs.academic.documentRequests.providers.StandaloneCurriculumEntriesDataProvider.java
private void collectWithRegistrations() { curriculumEntries = Sets.newTreeSet(CurriculumEntry.NAME_COMPARATOR(locale)); final Student student = registration.getStudent(); for (final Registration registration : student.getActiveRegistrations()) { Collection<CurriculumLine> standaloneCurriculumLines = registration.getStandaloneCurriculumLines(); for (CurriculumLine curriculumLine : standaloneCurriculumLines) { Collection<ICurriculumEntry> entries = curriculumLine .getCurriculum(emissionDate.toDateTimeAtStartOfDay()).getCurriculumEntries(); curriculumEntries.addAll(CurriculumEntry.transform(registration, entries, remarksDataProvider)); }/*ww w . ja va 2s . c o m*/ } }
From source file:com.android.tools.idea.npw.importing.ModulesTable.java
private Collection<ModuleImportSettingsPane> updateModuleEditors() { isRefreshing = true;//from ww w . j a v a2 s.co m try { ModuleToImport primary = myListModel.getPrimary(); setModuleNameVisibility(primary != null, myListModel.getAllModules().size() > 1); if (primary != null) { apply(myPrimaryModuleSettings, primary); } boolean isFirst = true; Collection<ModuleImportSettingsPane> editors = Lists.newLinkedList(); Set<ModuleToImport> allModules = Sets.newTreeSet(new ModuleComparator(myListModel.getCurrentPath())); Iterables.addAll(allModules, Iterables.filter(myListModel.getAllModules(), Predicates.not(Predicates.equalTo(myListModel.getPrimary())))); for (final ModuleToImport module : allModules) { final ModuleImportSettingsPane pane = createModuleSetupPanel(module, isFirst); if (pane != null) { isFirst = false; editors.add(pane); } } return editors; } finally { isRefreshing = false; } }
From source file:org.dllearner.utilities.split.OptimizedNumericValuesSplitter.java
public <T extends Number & Comparable<T>> List<T> computeSplitValues(OWLDataProperty dp) { List<T> splitsDP = new LinkedList<>(); NumberFormat numberFormat = NumberFormat.getInstance(); SortedSet<T> posRelatedValues = new TreeSet<>(); for (OWLIndividual ex : lp.getPositiveExamples()) { Set<OWLLiteral> relatedValues = reasoner.getRelatedValues(ex, dp); for (OWLLiteral lit : relatedValues) { if (OWLAPIUtils.isIntegerDatatype(lit)) { posRelatedValues.add((T) Integer.valueOf(lit.parseInteger())); } else { try { Number number = numberFormat.parse(lit.getLiteral()); if (number instanceof Long) { number = Double.valueOf(number.toString()); }/* w w w . ja va2 s.c o m*/ posRelatedValues.add((T) (number)); } catch (ParseException e) { e.printStackTrace(); } } } } SortedSet<T> negRelatedValues = new TreeSet<>(); for (OWLIndividual ex : lp.getNegativeExamples()) { Set<OWLLiteral> relatedValues = reasoner.getRelatedValues(ex, dp); for (OWLLiteral lit : relatedValues) { if (OWLAPIUtils.isIntegerDatatype(lit)) { negRelatedValues.add((T) Integer.valueOf(lit.parseInteger())); } else { try { Number number = numberFormat.parse(lit.getLiteral()); if (number instanceof Long) { number = Double.valueOf(number.toString()); } negRelatedValues.add((T) (number)); } catch (ParseException e) { e.printStackTrace(); } } } } SortedSet<T> allRelatedValues = Sets.newTreeSet(posRelatedValues); allRelatedValues.addAll(negRelatedValues); boolean posBefore = false; boolean negBefore = false; for (T val : allRelatedValues) { boolean pos = posRelatedValues.contains(val); boolean neg = negRelatedValues.contains(val); if (pos && !posBefore) { splitsDP.add(val); } if (neg && !negBefore) { splitsDP.add(val); } if (pos && neg) { splitsDP.add(val); } posBefore = pos; negBefore = neg; } return splitsDP; }
From source file:org.waveprotocol.wave.examples.fedone.waveserver.WaveletContainerImpl.java
/** * Constructs an empty WaveletContainer for a wavelet with the given name. * waveletData is not set until a delta has been applied. * * @param waveletName the name of the wavelet. *///from w w w.j a va2s . c om public WaveletContainerImpl(WaveletName waveletName) { this.waveletName = waveletName; waveletData = null; currentVersion = HASHED_HISTORY_VERSION_FACTORY.createVersionZero(waveletName); lastCommittedVersion = null; appliedDeltas = Sets.newTreeSet(appliedDeltaComparator); // Configure the locks used by this Wavelet. final ReadWriteLock readWriteLock = new ReentrantReadWriteLock(); readLock = readWriteLock.readLock(); writeLock = readWriteLock.writeLock(); state = State.OK; }
From source file:eu.interedition.text.util.AbstractTextRepository.java
@Override public String read(Text text, Range range) throws IOException { return getOnlyElement(bulkRead(text, Sets.newTreeSet(singleton(range))).values()); }
From source file:co.cask.cdap.data2.transaction.stream.StreamConsumerStateStore.java
@Override public final void remove(Iterable<? extends StreamConsumerState> states) throws IOException { Set<byte[]> columns = Sets.newTreeSet(Bytes.BYTES_COMPARATOR); for (StreamConsumerState state : states) { columns.add(getColumn(state.getGroupId(), state.getInstanceId())); }// ww w . j a v a 2 s. co m delete(streamId.toBytes(), columns); }
From source file:org.estatio.dom.communicationchannel.CommunicationChannels.java
@Programmatic public SortedSet<CommunicationChannel> findByOwner(final CommunicationChannelOwner owner) { final List<CommunicationChannelOwnerLink> links = communicationChannelOwnerLinks.findByOwner(owner); return Sets.newTreeSet( Iterables.transform(links, CommunicationChannelOwnerLink.Functions.communicationChannel())); }