List of usage examples for java.util Collections unmodifiableCollection
public static <T> Collection<T> unmodifiableCollection(Collection<? extends T> c)
From source file:com.pongasoft.kiwidoc.model.ClassModel.java
/** * @return all the methods */ public Collection<MethodModel> getAllMethods() { return Collections.unmodifiableCollection(_allMethods.values()); }
From source file:de.btobastian.javacord.entities.impl.ImplServer.java
@Override public Collection<User> getMembers() { return Collections.unmodifiableCollection(members.values()); }
From source file:com.haulmont.cuba.desktop.gui.components.DesktopAbstractBox.java
@Override public Collection<Component> getOwnComponents() { return Collections.unmodifiableCollection(ownComponents); }
From source file:edu.ksu.cis.indus.common.soot.SootBasedDriver.java
/** * Retrieves the root methods in the system. * /*from ww w . j av a 2 s . c om*/ * @return the collection of root methods. */ @Functional @NonNullContainer @NonNull public final Collection<SootMethod> getRootMethods() { return Collections.unmodifiableCollection(rootMethods); }
From source file:fr.gouv.culture.thesaurus.service.rdf.RdfResource.java
/** * Renvoie l'ensemble des ressources lies l'entre pour la proprit * donne./*from w ww . jav a 2 s .co m*/ * * @param property * URI de la proprit * @return Ensemble des URI des ressources lies l'entre via la proprit * (jamais <code>null</code> mais peut tre vide) */ @SuppressWarnings("unchecked") public Collection<String> getAssociations(final String property) { Collection<String> resources = associations.getCollection(property); if (resources == null) { resources = Collections.emptyList(); } else { resources = Collections.unmodifiableCollection(resources); } return resources; }
From source file:com.netflix.config.ConcurrentMapConfiguration.java
@Override public Collection<ConfigurationListener> getConfigurationListeners() { return Collections.unmodifiableCollection(listeners); }
From source file:nz.co.senanque.vaadinsupport.application.MaduraSessionManager.java
public Collection<AbstractField> getFields() { if (logger.isDebugEnabled()) { logger.debug("fetching registered fields for MaduraSessionManager {}", getValidationEngine().getIdentifier()); for (Entry<Integer, AbstractField> entry : m_fields.entrySet()) { logger.debug("{}={}", entry.getKey(), entry.getValue().getCaption()); }/*from w w w . j ava 2 s . c o m*/ logger.debug("--------"); } return Collections.unmodifiableCollection(m_fields.values()); }
From source file:com.datatorrent.lib.io.block.AbstractBlockReader.java
/** * <b>Note:</b> This partitioner does not support parallel partitioning.<br/><br/> * {@inheritDoc}// ww w. j a v a2 s . co m */ @SuppressWarnings("unchecked") @Override public Collection<Partition<AbstractBlockReader<R, B, STREAM>>> definePartitions( Collection<Partition<AbstractBlockReader<R, B, STREAM>>> partitions, PartitioningContext context) { if (partitions.iterator().next().getStats() == null) { //First time when define partitions is called return partitions; } List<Partition<AbstractBlockReader<R, B, STREAM>>> newPartitions = Lists.newArrayList(); //Create new partitions for (Partition<AbstractBlockReader<R, B, STREAM>> partition : partitions) { newPartitions.add(new DefaultPartition<>(partition.getPartitionedInstance())); } partitions.clear(); int morePartitionsToCreate = partitionCount - newPartitions.size(); List<BasicCounters<MutableLong>> deletedCounters = Lists.newArrayList(); if (morePartitionsToCreate < 0) { //Delete partitions Iterator<Partition<AbstractBlockReader<R, B, STREAM>>> partitionIterator = newPartitions.iterator(); while (morePartitionsToCreate++ < 0) { Partition<AbstractBlockReader<R, B, STREAM>> toRemove = partitionIterator.next(); deletedCounters.add(toRemove.getPartitionedInstance().counters); LOG.debug("partition removed {}", toRemove.getPartitionedInstance().operatorId); partitionIterator.remove(); } } else { KryoCloneUtils<AbstractBlockReader<R, B, STREAM>> cloneUtils = KryoCloneUtils.createCloneUtils(this); while (morePartitionsToCreate-- > 0) { DefaultPartition<AbstractBlockReader<R, B, STREAM>> partition = new DefaultPartition<>( cloneUtils.getClone()); newPartitions.add(partition); } } DefaultPartition.assignPartitionKeys(Collections.unmodifiableCollection(newPartitions), blocksMetadataInput); int lPartitionMask = newPartitions.iterator().next().getPartitionKeys().get(blocksMetadataInput).mask; //transfer the state here for (Partition<AbstractBlockReader<R, B, STREAM>> newPartition : newPartitions) { AbstractBlockReader<R, B, STREAM> reader = newPartition.getPartitionedInstance(); reader.partitionKeys = newPartition.getPartitionKeys().get(blocksMetadataInput).partitions; reader.partitionMask = lPartitionMask; LOG.debug("partitions {},{}", reader.partitionKeys, reader.partitionMask); } //transfer the counters AbstractBlockReader<R, B, STREAM> targetReader = newPartitions.iterator().next().getPartitionedInstance(); for (BasicCounters<MutableLong> removedCounter : deletedCounters) { addCounters(targetReader.counters, removedCounter); } return newPartitions; }
From source file:com.datatorrent.lib.dedup.Deduper.java
@Override @SuppressWarnings({ "BroadCatchBlock", "TooBroadCatch", "UseSpecificCatch" }) public Collection<Partition<Deduper<INPUT, OUTPUT>>> definePartitions( Collection<Partition<Deduper<INPUT, OUTPUT>>> partitions, PartitioningContext context) { final int finalCapacity = DefaultPartition.getRequiredPartitionCount(context, this.partitionCount); //Collect the state here List<BucketManager<INPUT>> oldStorageManagers = Lists.newArrayList(); Map<Long, List<INPUT>> allWaitingEvents = Maps.newHashMap(); for (Partition<Deduper<INPUT, OUTPUT>> partition : partitions) { //collect all bucketStorageManagers oldStorageManagers.add(partition.getPartitionedInstance().bucketManager); //collect all waiting events for (Map.Entry<Long, List<INPUT>> awaitingList : partition.getPartitionedInstance().waitingEvents .entrySet()) {// w w w . ja v a 2s . c o m if (awaitingList.getValue().size() > 0) { List<INPUT> existingList = allWaitingEvents.get(awaitingList.getKey()); if (existingList == null) { existingList = Lists.newArrayList(); allWaitingEvents.put(awaitingList.getKey(), existingList); } existingList.addAll(awaitingList.getValue()); } } partition.getPartitionedInstance().waitingEvents.clear(); } partitions.clear(); Collection<Partition<Deduper<INPUT, OUTPUT>>> newPartitions = Lists.newArrayListWithCapacity(finalCapacity); Map<Integer, BucketManager<INPUT>> partitionKeyToStorageManagers = Maps.newHashMap(); for (int i = 0; i < finalCapacity; i++) { try { @SuppressWarnings("unchecked") Deduper<INPUT, OUTPUT> deduper = this.getClass().newInstance(); DefaultPartition<Deduper<INPUT, OUTPUT>> partition = new DefaultPartition<Deduper<INPUT, OUTPUT>>( deduper); newPartitions.add(partition); } catch (Throwable cause) { DTThrowable.rethrow(cause); } } DefaultPartition.assignPartitionKeys(Collections.unmodifiableCollection(newPartitions), input); int lPartitionMask = newPartitions.iterator().next().getPartitionKeys().get(input).mask; //transfer the state here for (Partition<Deduper<INPUT, OUTPUT>> deduperPartition : newPartitions) { Deduper<INPUT, OUTPUT> deduperInstance = deduperPartition.getPartitionedInstance(); deduperInstance.partitionKeys = deduperPartition.getPartitionKeys().get(input).partitions; deduperInstance.partitionMask = lPartitionMask; logger.debug("partitions {},{}", deduperInstance.partitionKeys, deduperInstance.partitionMask); deduperInstance.bucketManager = bucketManager.cloneWithProperties(); for (int partitionKey : deduperInstance.partitionKeys) { partitionKeyToStorageManagers.put(partitionKey, deduperInstance.bucketManager); } //distribute waiting events for (long bucketKey : allWaitingEvents.keySet()) { for (Iterator<INPUT> iterator = allWaitingEvents.get(bucketKey).iterator(); iterator.hasNext();) { INPUT event = iterator.next(); int partitionKey = event.getEventKey().hashCode() & lPartitionMask; if (deduperInstance.partitionKeys.contains(partitionKey)) { List<INPUT> existingList = deduperInstance.waitingEvents.get(bucketKey); if (existingList == null) { existingList = Lists.newArrayList(); deduperInstance.waitingEvents.put(bucketKey, existingList); } existingList.add(event); iterator.remove(); } } } } //let storage manager and subclasses distribute state as well bucketManager.definePartitions(oldStorageManagers, partitionKeyToStorageManagers, lPartitionMask); return newPartitions; }
From source file:edu.stanford.muse.index.Indexer.java
public Collection<String> getDataErrors() { return Collections.unmodifiableCollection(dataErrors); }