List of usage examples for com.google.common.collect ImmutableSortedMap copyOfSorted
public static <K, V> ImmutableSortedMap<K, V> copyOfSorted(SortedMap<K, ? extends V> map)
From source file:com.gradleware.tooling.toolingmodel.repository.internal.DefaultOmniBuildInvocationsContainer.java
private DefaultOmniBuildInvocationsContainer(SortedMap<Path, OmniBuildInvocations> buildInvocationsPerProject) { this.buildInvocationsPerProject = ImmutableSortedMap.copyOfSorted(buildInvocationsPerProject); }
From source file:org.apache.bookkeeper.metastore.InMemoryMetastoreCursor.java
public InMemoryMetastoreCursor(SortedMap<String, Versioned<Value>> map, Set<String> fields, ScheduledExecutorService scheduler) { // copy an map for iterator to avoid concurrent modification problem. this.iter = ImmutableSortedMap.copyOfSorted(map).entrySet().iterator(); this.fields = fields; this.scheduler = scheduler; }
From source file:org.gradle.internal.execution.impl.OutputFilterUtil.java
public static ImmutableSortedMap<String, CurrentFileCollectionFingerprint> filterOutputFingerprints( final @Nullable ImmutableSortedMap<String, FileCollectionFingerprint> outputsAfterPreviousExecution, ImmutableSortedMap<String, CurrentFileCollectionFingerprint> outputsBeforeExecution, final ImmutableSortedMap<String, CurrentFileCollectionFingerprint> outputsAfterExecution) { return ImmutableSortedMap.copyOfSorted(Maps.transformEntries(outputsBeforeExecution, new Maps.EntryTransformer<String, CurrentFileCollectionFingerprint, CurrentFileCollectionFingerprint>() { @Override//from www. jav a2 s . c om @SuppressWarnings("NullableProblems") public CurrentFileCollectionFingerprint transformEntry(String propertyName, CurrentFileCollectionFingerprint outputBeforeExecution) { CurrentFileCollectionFingerprint outputAfterExecution = outputsAfterExecution .get(propertyName); FileCollectionFingerprint outputAfterPreviousExecution = getFingerprintForProperty( outputsAfterPreviousExecution, propertyName); return filterOutputFingerprint(outputAfterPreviousExecution, outputBeforeExecution, outputAfterExecution); } })); }
From source file:org.apache.druid.client.ImmutableDruidDataSource.java
public ImmutableDruidDataSource(String name, Map<String, String> properties, SortedMap<String, DataSegment> idToSegments) { this.name = Preconditions.checkNotNull(name); this.properties = ImmutableMap.copyOf(properties); this.idToSegments = ImmutableSortedMap.copyOfSorted(idToSegments); }
From source file:org.gradle.api.internal.changedetection.changes.Util.java
public static ImmutableSortedMap<String, CurrentFileCollectionFingerprint> fingerprintAfterOutputsGenerated( final @Nullable ImmutableSortedMap<String, FileCollectionFingerprint> previous, ImmutableSortedMap<String, CurrentFileCollectionFingerprint> current, SortedSet<? extends TaskFilePropertySpec> outputProperties, boolean hasOverlappingOutputs, TaskInternal task, FileCollectionFingerprinterRegistry fingerprinterRegistry) { final ImmutableSortedMap<String, CurrentFileCollectionFingerprint> outputFilesAfter = fingerprintTaskFiles( task, outputProperties, fingerprinterRegistry); if (!hasOverlappingOutputs) { return outputFilesAfter; } else {//from ww w .ja v a 2 s.c o m return ImmutableSortedMap.copyOfSorted(Maps.transformEntries(current, new Maps.EntryTransformer<String, CurrentFileCollectionFingerprint, CurrentFileCollectionFingerprint>() { @Override @SuppressWarnings("NullableProblems") public CurrentFileCollectionFingerprint transformEntry(String propertyName, CurrentFileCollectionFingerprint beforeExecution) { CurrentFileCollectionFingerprint afterExecution = outputFilesAfter.get(propertyName); FileCollectionFingerprint afterPreviousExecution = Util .getFingerprintAfterPreviousExecution(previous, propertyName); return Util.filterOutputFingerprint(afterPreviousExecution, beforeExecution, afterExecution); } })); } }
From source file:me.lucko.luckperms.common.caching.MetaCache.java
public void loadMeta(MetaHolder meta) { lock.writeLock().lock();// w w w. j a va 2 s .co m try { this.meta = ImmutableMap.copyOf(meta.getMeta()); this.prefixes = ImmutableSortedMap.copyOfSorted(meta.getPrefixes()); this.suffixes = ImmutableSortedMap.copyOfSorted(meta.getSuffixes()); this.prefixStack = meta.getPrefixStack(); this.suffixStack = meta.getSuffixStack(); } finally { lock.writeLock().unlock(); } }
From source file:com.opengamma.strata.pricer.option.TenorRawOptionData.java
private TenorRawOptionData(SortedMap<Tenor, RawOptionData> data) { JodaBeanUtils.notNull(data, "data"); this.data = ImmutableSortedMap.copyOfSorted(data); }
From source file:google.registry.util.CollectionUtils.java
/** Defensive copy helper for {@link SortedMap}. */ public static <K, V> ImmutableSortedMap<K, V> nullToEmptyImmutableCopy(SortedMap<K, V> data) { return data == null ? ImmutableSortedMap.<K, V>of() : ImmutableSortedMap.copyOfSorted(data); }
From source file:me.lucko.luckperms.common.caching.type.MetaCache.java
public void loadMeta(MetaAccumulator meta) { lock.writeLock().lock();/*from w ww .ja v a 2s. c o m*/ try { this.metaMultimap = ImmutableListMultimap.copyOf(meta.getMeta()); //noinspection unchecked Map<String, List<String>> metaMap = (Map) this.metaMultimap.asMap(); ImmutableMap.Builder<String, String> metaMapBuilder = ImmutableMap.builder(); for (Map.Entry<String, List<String>> e : metaMap.entrySet()) { if (e.getValue().isEmpty()) { continue; } // take the value which was accumulated first metaMapBuilder.put(e.getKey(), e.getValue().get(0)); } this.meta = metaMapBuilder.build(); this.prefixes = ImmutableSortedMap.copyOfSorted(meta.getPrefixes()); this.suffixes = ImmutableSortedMap.copyOfSorted(meta.getSuffixes()); this.prefixStack = meta.getPrefixStack(); this.suffixStack = meta.getSuffixStack(); } finally { lock.writeLock().unlock(); } }
From source file:org.locationtech.geogig.model.impl.RevTreeBuilder.java
/** * Creates a tree with the given id and contents, no questions asked. * <p>/*from ww w.j a v a 2 s . c o m*/ * Be careful when using this method instead of {@link #build()}. {@link #build()} will compute * the appropriate id for the tree given its contents as mandated by {@link HashObject}, whilst * this method will create the tree as given, even if the id is not the one that would result * from properly computing it. * * @param id * @param size * @param childTreeCount * @param trees * @param features * @param buckets * @return */ static RevTree create(final ObjectId id, final long size, final int childTreeCount, @Nullable ImmutableList<Node> trees, @Nullable ImmutableList<Node> features, @Nullable SortedMap<Integer, Bucket> buckets) { ImmutableSortedMap<Integer, Bucket> immutableBuckets = buckets == null ? null : ImmutableSortedMap.copyOfSorted(buckets); return RevTreeImpl.create(id, size, childTreeCount, trees, features, immutableBuckets); }