Java Code Examples for java.util.Collections#unmodifiableSortedMap()
The following examples show how to use
java.util.Collections#unmodifiableSortedMap() .
These examples are extracted from open source projects.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: metrics File: MetricRegistryImpl.java License: Apache License 2.0 | 6 votes |
@SuppressWarnings("unchecked") private <T extends Metric> SortedMap<MetricName, T> getMetrics(Class<T> klass, MetricFilter filter) { final TreeMap<MetricName, T> timers = new TreeMap<MetricName, T>(); for (Map.Entry<MetricName, Metric> entry : metrics.entrySet()) { if (klass.isInstance(entry.getValue()) && filter.matches(entry.getKey(), entry.getValue())) { timers.put(entry.getKey(), (T) entry.getValue()); } else if (entry.getValue() instanceof DynamicMetricSet) { for (Map.Entry<MetricName, Metric> dynamicEntry: ((DynamicMetricSet) entry.getValue()).getDynamicMetrics().entrySet()) { if (klass.isInstance(dynamicEntry.getValue()) && filter.matches(dynamicEntry.getKey(), dynamicEntry.getValue())) { timers.put(dynamicEntry.getKey(), (T) dynamicEntry.getValue()); } } } } return Collections.unmodifiableSortedMap(timers); }
Example 2
Source Project: j2objc File: OldCollectionsTest.java License: Apache License 2.0 | 5 votes |
/** * java.util.Collections#unmodifiableSortedMap(java.util.SortedMap) */ public void test_unmodifiableSortedMapLjava_util_SortedMap() { try { // Regression for HARMONY-93 Collections.unmodifiableSortedMap(null); fail("Assert 0: unmodifiableSortedMap(null) must throw NPE"); } catch (NullPointerException e) { // expected } }
Example 3
Source Project: packagedrone File: ModifyContextImpl.java License: Eclipse Public License 1.0 | 5 votes |
public ModifyContextImpl ( final String channelId, final BlobStore store, final CacheStore cacheStore, final ChannelState state, final Map<String, String> aspectStates, final Map<String, ArtifactInformation> artifacts, final Map<MetaKey, CacheEntryInformation> cacheEntries, final Map<MetaKey, String> extractedMetaData, final Map<MetaKey, String> providedMetaData ) { Objects.requireNonNull ( channelId ); Objects.requireNonNull ( store ); Objects.requireNonNull ( cacheStore ); this.channelId = channelId; this.store = store; this.cacheStore = cacheStore; this.state = new Builder ( state ); // main collections this.modAspectStates = new TreeMap<> ( aspectStates ); this.modCacheEntries = new HashMap<> ( cacheEntries ); this.modArtifacts = new HashMap<> ( artifacts ); this.modGeneratorArtifacts = this.modArtifacts.values ().stream ().filter ( art -> art.is ( FACET_GENERATOR ) ).collect ( toMap ( ArtifactInformation::getId, a -> a ) ); this.modExtractedMetadata = new HashMap<> ( extractedMetaData ); this.modProvidedMetadata = new HashMap<> ( providedMetaData ); // create unmodifiable collections this.aspectStates = Collections.unmodifiableSortedMap ( this.modAspectStates ); this.cacheEntries = Collections.unmodifiableMap ( this.modCacheEntries ); this.artifacts = Collections.unmodifiableMap ( this.modArtifacts ); this.generatorArtifacts = Collections.unmodifiableMap ( this.modGeneratorArtifacts ); this.extractedMetadata = Collections.unmodifiableMap ( this.modExtractedMetadata ); this.providedMetadata = Collections.unmodifiableMap ( this.modProvidedMetadata ); // aspect context this.aspectContext = new AspectContextImpl ( this, Activator.getProcessor () ); }
Example 4
Source Project: codebuff File: Maps.java License: BSD 2-Clause "Simplified" License | 5 votes |
private static <K, V> Map<K, V> unmodifiableMap(Map<K, ? extends V> map) { if (map instanceof SortedMap) { return Collections.unmodifiableSortedMap((SortedMap<K, ? extends V>) map); } else { return Collections.unmodifiableMap(map); } }
Example 5
Source Project: Time4A File: DayPeriod.java License: Apache License 2.0 | 5 votes |
private DayPeriod( Locale locale, // optional String calendarType, SortedMap<PlainTime, String> codeMap ) { super(); this.locale = locale; this.calendarType = calendarType; this.codeMap = Collections.unmodifiableSortedMap(codeMap); }
Example 6
Source Project: codebuff File: Maps.java License: BSD 2-Clause "Simplified" License | 5 votes |
private static <K, V> Map<K, V> unmodifiableMap(Map<K, ? extends V> map) { if (map instanceof SortedMap) { return Collections.unmodifiableSortedMap((SortedMap<K, ? extends V>) map); } else { return Collections.unmodifiableMap(map); } }
Example 7
Source Project: packagedrone File: ChannelInformation.java License: Eclipse Public License 1.0 | 5 votes |
private ChannelInformation ( final String id, final Set<String> names, final String description, final ChannelState state, final SortedMap<MetaKey, String> metaData, final SortedMap<String, String> aspectStates ) { super ( id, names, description ); this.state = state; this.metaData = Collections.unmodifiableSortedMap ( metaData ); this.aspectStates = Collections.unmodifiableSortedMap ( aspectStates ); }
Example 8
Source Project: rice File: RemotableRadioButtonGroup.java License: Educational Community License v2.0 | 5 votes |
public void setKeyLabels(Map<String, String> keyLabels) { if (keyLabels == null || keyLabels.isEmpty()) { throw new IllegalArgumentException("keyLabels must be non-null & non-empty"); } // keep previously SortedMaps (such as by sequence number) sorted. if (keyLabels instanceof SortedMap) { this.keyLabels = Collections.unmodifiableSortedMap((SortedMap)keyLabels); } else { this.keyLabels = Collections.unmodifiableMap(new LinkedHashMap<String, String>(keyLabels)); } }
Example 9
Source Project: Bytecoder File: TCharset.java License: Apache License 2.0 | 5 votes |
public static SortedMap<String, java.nio.charset.Charset> availableCharsets() { final TreeMap<String, java.nio.charset.Charset> m = new TreeMap<>( String.CASE_INSENSITIVE_ORDER); put(standardProvider.charsets(), m); return Collections.unmodifiableSortedMap(m); }
Example 10
Source Project: j2objc File: Collections2Test.java License: Apache License 2.0 | 5 votes |
/** * java.util.Collections#unmodifiableSortedMap(java.util.SortedMap) */ public void test_unmodifiableSortedMapLjava_util_SortedMap() { try { // Regression for HARMONY-93 Collections.unmodifiableSortedMap(null); fail("Assert 0: unmodifiableSortedMap(null) must throw NPE"); } catch (NullPointerException e) { // expected } }
Example 11
Source Project: openjdk-jdk9 File: java_util_Collections_UnmodifiableSortedMap.java License: GNU General Public License v2.0 | 4 votes |
protected SortedMap<String, String> getAnotherObject() { SortedMap<String, String> map = new TreeMap<String, String>(); return Collections.unmodifiableSortedMap(map); }
Example 12
Source Project: jdk8u-jdk File: java_util_Collections_UnmodifiableSortedMap.java License: GNU General Public License v2.0 | 4 votes |
protected SortedMap<String, String> getObject() { SortedMap<String, String> map = new TreeMap<String, String>(); map.put("key", "value"); return Collections.unmodifiableSortedMap(map); }
Example 13
Source Project: packagedrone File: AspectMapModel.java License: Eclipse Public License 1.0 | 4 votes |
public SortedMap<String, String> getAspects () { return Collections.unmodifiableSortedMap ( this.map ); }
Example 14
Source Project: codebuff File: Tables.java License: BSD 2-Clause "Simplified" License | 4 votes |
@Override public SortedMap<R, Map<C, V>> rowMap() { Function<Map<C, V>, Map<C, V>> wrapper = unmodifiableWrapper(); return Collections.unmodifiableSortedMap(Maps.transformValues(delegate().rowMap(), wrapper)); }
Example 15
Source Project: codebuff File: Tables.java License: BSD 2-Clause "Simplified" License | 4 votes |
@Override public SortedMap<R, Map<C, V>> rowMap() { Function<Map<C, V>, Map<C, V>> wrapper = unmodifiableWrapper(); return Collections.unmodifiableSortedMap(Maps.transformValues(delegate().rowMap(), wrapper)); }
Example 16
Source Project: Diorite File: ConfigPropertyTemplateImpl.java License: MIT License | 4 votes |
@Nullable @Override public T get(ConfigPropertyValue<T> propertyValue) { T rawValue = propertyValue.getRawValue(); if (rawValue == null) { return null; } if (this.returnUnmodifiableCollections) { if (rawValue instanceof Collection) { if (rawValue instanceof Set) { if (rawValue instanceof NavigableSet) { return (T) Collections.unmodifiableNavigableSet((NavigableSet<?>) rawValue); } if (rawValue instanceof SortedSet) { return (T) Collections.unmodifiableSortedSet((SortedSet<?>) rawValue); } return (T) Collections.unmodifiableSet((Set<?>) rawValue); } if (rawValue instanceof List) { return (T) Collections.unmodifiableList((List<?>) rawValue); } return (T) Collections.unmodifiableCollection((Collection<?>) rawValue); } else if (rawValue instanceof Map) { if (rawValue instanceof NavigableMap) { return (T) Collections.unmodifiableNavigableMap((NavigableMap<?, ?>) rawValue); } if (rawValue instanceof SortedMap) { return (T) Collections.unmodifiableSortedMap((SortedMap<?, ?>) rawValue); } return (T) Collections.unmodifiableMap((Map<?, ?>) rawValue); } } return rawValue; }
Example 17
Source Project: semantic-metrics File: MetricId.java License: Apache License 2.0 | 4 votes |
private MetricId(String key, SortedMap<String, String> tags, boolean isAlreadyUnmodifiable) { this.key = key; this.tags = isAlreadyUnmodifiable ? tags : Collections.unmodifiableSortedMap(tags); this.hash = calculateHashCode(key, tags); }
Example 18
Source Project: openjdk-8-source File: java_util_Collections_UnmodifiableSortedMap.java License: GNU General Public License v2.0 | 4 votes |
protected SortedMap<String, String> getObject() { SortedMap<String, String> map = new TreeMap<String, String>(); map.put("key", "value"); return Collections.unmodifiableSortedMap(map); }
Example 19
Source Project: openjdk-jdk8u File: java_util_Collections_UnmodifiableSortedMap.java License: GNU General Public License v2.0 | 4 votes |
protected SortedMap<String, String> getAnotherObject() { SortedMap<String, String> map = new TreeMap<String, String>(); return Collections.unmodifiableSortedMap(map); }
Example 20
Source Project: arctic-sea File: FilterCapabilities.java License: Apache License 2.0 | 2 votes |
/** * Get temporal operators * * @return temporal operators */ public SortedMap<TimeOperator, SortedSet<QName>> getTemporalOperators() { return Collections.unmodifiableSortedMap(temporalOperators); }