List of usage examples for java.util Collections unmodifiableSortedMap
public static <K, V> SortedMap<K, V> unmodifiableSortedMap(SortedMap<K, ? extends V> m)
From source file:org.diorite.config.impl.ConfigPropertyTemplateImpl.java
@Nullable @Override//w w w. j av a 2s . com 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; }
From source file:org.freeplane.plugin.script.ScriptingConfiguration.java
SortedMap<String, String> getMenuTitleToPathMap() {
return Collections.unmodifiableSortedMap(menuTitleToPathMap);
}
From source file:org.freeplane.plugin.script.ScriptingConfiguration.java
SortedMap<String, ScriptMetaData> getMenuTitleToMetaDataMap() {
return Collections.unmodifiableSortedMap(menuTitleToMetaDataMap);
}
From source file:org.omnaest.utils.table.impl.TableIndexArbitraryImpl.java
@Override public SortedMap<K, Set<Row<E>>> headMap(K toKey) { return Collections.unmodifiableSortedMap(MapUtils.adapter(this.keyToRowSetMap.headMap(toKey), new ElementBidirectionalConverterSetToUnmodifiableSet<Row<E>>())); }
From source file:org.omnaest.utils.table.impl.TableIndexArbitraryImpl.java
@Override public SortedMap<K, Set<Row<E>>> subMap(K fromKey, K toKey) { return Collections.unmodifiableSortedMap(MapUtils.adapter(this.keyToRowSetMap.subMap(fromKey, toKey), new ElementBidirectionalConverterSetToUnmodifiableSet<Row<E>>())); }
From source file:org.omnaest.utils.table.impl.TableIndexArbitraryImpl.java
@Override public SortedMap<K, Set<Row<E>>> tailMap(K fromKey) { return Collections.unmodifiableSortedMap(MapUtils.adapter(this.keyToRowSetMap.tailMap(fromKey), new ElementBidirectionalConverterSetToUnmodifiableSet<Row<E>>())); }
From source file:org.opencms.scheduler.CmsScheduledJobInfo.java
/** * Sets the "frozen" state of this job.<p> * * This is an internal operation to be used only by the <code>{@link CmsScheduleManager}</code>.<p> * * @param frozen the "frozen" state to set *///from ww w .j a v a 2 s .c o m protected synchronized void setFrozen(boolean frozen) { if (frozen && !m_frozen) { // "freeze" the job configuration m_parameters = Collections.unmodifiableSortedMap(m_parameters); m_context.freeze(); m_frozen = true; } else if (!frozen && m_frozen) { // "unfreeze" the job configuration m_parameters = new TreeMap<String, String>(m_parameters); m_frozen = false; } }
From source file:org.photovault.replication.ValueChange.java
/** * Get a read-only version of all property changes done to this object. * @return// w w w . j a v a2 s .co m */ public SortedMap<String, Object> getPropChanges() { return Collections.unmodifiableSortedMap(propChanges); }
From source file:org.tobarsegais.webapp.data.Index.java
public Index(Collection<IndexEntry> children) { this.children = children == null || children.isEmpty() ? Collections.<IndexEntry>emptyList() : Collections.unmodifiableList(new ArrayList<IndexEntry>(children)); TreeMap<String, IndexEntry> entryTreeMap = new TreeMap<String, IndexEntry>(); for (IndexEntry entry : getChildren()) { final IndexEntry existing = entryTreeMap.get(entry.getKeyword()); if (existing != null) { entryTreeMap.put(entry.getKeyword(), IndexEntry.merge(existing, entry)); } else {/*from w ww . j a v a 2 s .co m*/ entryTreeMap.put(entry.getKeyword(), entry); } } this.entries = Collections.unmodifiableSortedMap(entryTreeMap); Map<IndexEntry, String> ids = new HashMap<IndexEntry, String>(); int id = 0; Stack<Iterator<IndexEntry>> stack = new Stack<Iterator<IndexEntry>>(); stack.push(entries.values().iterator()); while (!stack.isEmpty()) { Iterator<IndexEntry> iterator = stack.pop(); while (iterator.hasNext()) { IndexEntry indexEntry = iterator.next(); stack.push(iterator); ids.put(indexEntry, Integer.toHexString(id++)); if (!indexEntry.getSubEntries().isEmpty()) { stack.push(indexEntry.getSubEntries().values().iterator()); } } } this.ids = Collections.unmodifiableMap(ids); }
From source file:therian.operator.immutablecheck.DefaultImmutableCheckerTest.java
@Test public void testJavaUtilCollectionsFactoryTypes() { assertTrue(//from w w w. j a v a 2 s.c o m therianContext.eval(ImmutableCheck.of(Positions.readOnly(Collections.emptyList()))).booleanValue()); assertTrue( therianContext.eval(ImmutableCheck.of(Positions.readOnly(Collections.emptySet()))).booleanValue()); assertTrue(therianContext.eval(ImmutableCheck.of(Positions.readOnly(Collections.emptySet().iterator()))) .booleanValue()); assertTrue( therianContext.eval(ImmutableCheck.of(Positions.readOnly(Collections.emptyMap()))).booleanValue()); assertTrue(therianContext.eval(ImmutableCheck.of(Positions.readOnly(Collections.emptyMap().keySet()))) .booleanValue()); assertTrue(therianContext .eval(ImmutableCheck.of(Positions.readOnly(Collections.emptyMap().keySet().iterator()))) .booleanValue()); assertTrue(therianContext.eval(ImmutableCheck.of(Positions.readOnly(Collections.emptyMap().values()))) .booleanValue()); assertTrue(therianContext .eval(ImmutableCheck.of(Positions.readOnly(Collections.emptyMap().values().iterator()))) .booleanValue()); assertTrue(therianContext .eval(ImmutableCheck.of(Positions.readOnly(Collections.unmodifiableList(Collections.emptyList())))) .booleanValue()); assertTrue(therianContext .eval(ImmutableCheck .of(Positions.readOnly(Collections.unmodifiableList(Collections.emptyList()).iterator()))) .booleanValue()); assertTrue(therianContext .eval(ImmutableCheck.of( Positions.readOnly(Collections.unmodifiableList(Collections.emptyList()).listIterator()))) .booleanValue()); assertTrue(therianContext .eval(ImmutableCheck.of(Positions.readOnly(Collections.unmodifiableSet(Collections.emptySet())))) .booleanValue()); assertTrue(therianContext .eval(ImmutableCheck .of(Positions.readOnly(Collections.unmodifiableSet(Collections.emptySet()).iterator()))) .booleanValue()); assertTrue(therianContext .eval(ImmutableCheck.of(Positions.readOnly(Collections.unmodifiableMap(Collections.emptyMap())))) .booleanValue()); assertTrue(therianContext .eval(ImmutableCheck .of(Positions.readOnly(Collections.unmodifiableMap(Collections.emptyMap()).keySet()))) .booleanValue()); assertTrue(therianContext .eval(ImmutableCheck .of(Positions.readOnly(Collections.unmodifiableMap(Collections.emptyMap()).values()))) .booleanValue()); assertTrue(therianContext .eval(ImmutableCheck.of(Positions .readOnly(Collections.unmodifiableMap(Collections.emptyMap()).keySet().iterator()))) .booleanValue()); assertTrue(therianContext .eval(ImmutableCheck.of(Positions .readOnly(Collections.unmodifiableMap(Collections.emptyMap()).values().iterator()))) .booleanValue()); assertTrue(therianContext .eval(ImmutableCheck .of(Positions.readOnly(Collections.unmodifiableSortedSet(new TreeSet<String>())))) .booleanValue()); assertTrue(therianContext .eval(ImmutableCheck.of( Positions.readOnly(Collections.unmodifiableSortedSet(new TreeSet<String>()).iterator()))) .booleanValue()); assertTrue(therianContext .eval(ImmutableCheck.of(Positions .readOnly(Collections.unmodifiableSortedSet(new TreeSet<String>()).headSet("foo")))) .booleanValue()); assertTrue(therianContext .eval(ImmutableCheck.of(Positions .readOnly(Collections.unmodifiableSortedSet(new TreeSet<String>()).tailSet("foo")))) .booleanValue()); assertTrue(therianContext .eval(ImmutableCheck.of(Positions .readOnly(Collections.unmodifiableSortedSet(new TreeSet<String>()).subSet("foo", "foo")))) .booleanValue()); assertTrue(therianContext .eval(ImmutableCheck.of(Positions.readOnly( Collections.unmodifiableSortedSet(new TreeSet<String>()).headSet("foo").iterator()))) .booleanValue()); assertTrue(therianContext .eval(ImmutableCheck.of(Positions.readOnly( Collections.unmodifiableSortedSet(new TreeSet<String>()).tailSet("foo").iterator()))) .booleanValue()); assertTrue(therianContext .eval(ImmutableCheck.of(Positions.readOnly( Collections.unmodifiableSortedSet(new TreeSet<String>()).subSet("foo", "foo").iterator()))) .booleanValue()); assertTrue(therianContext .eval(ImmutableCheck .of(Positions.readOnly(Collections.unmodifiableSortedMap(new TreeMap<String, Object>())))) .booleanValue()); assertTrue(therianContext .eval(ImmutableCheck.of(Positions .readOnly(Collections.unmodifiableSortedMap(new TreeMap<String, Object>()).keySet()))) .booleanValue()); assertTrue(therianContext .eval(ImmutableCheck.of(Positions .readOnly(Collections.unmodifiableSortedMap(new TreeMap<String, Object>()).values()))) .booleanValue()); assertTrue(therianContext .eval(ImmutableCheck.of(Positions.readOnly( Collections.unmodifiableSortedMap(new TreeMap<String, Object>()).keySet().iterator()))) .booleanValue()); assertTrue(therianContext .eval(ImmutableCheck.of(Positions.readOnly( Collections.unmodifiableSortedMap(new TreeMap<String, Object>()).values().iterator()))) .booleanValue()); assertTrue(therianContext .eval(ImmutableCheck.of(Positions .readOnly(Collections.unmodifiableSortedMap(new TreeMap<String, Object>()).headMap("foo")))) .booleanValue()); assertTrue(therianContext .eval(ImmutableCheck.of(Positions.readOnly( Collections.unmodifiableSortedMap(new TreeMap<String, Object>()).headMap("foo").keySet()))) .booleanValue()); assertTrue(therianContext .eval(ImmutableCheck.of(Positions.readOnly( Collections.unmodifiableSortedMap(new TreeMap<String, Object>()).headMap("foo").values()))) .booleanValue()); assertTrue(therianContext .eval(ImmutableCheck.of(Positions.readOnly(Collections .unmodifiableSortedMap(new TreeMap<String, Object>()).headMap("foo").keySet().iterator()))) .booleanValue()); assertTrue(therianContext .eval(ImmutableCheck.of(Positions.readOnly(Collections .unmodifiableSortedMap(new TreeMap<String, Object>()).headMap("foo").values().iterator()))) .booleanValue()); assertTrue(therianContext .eval(ImmutableCheck.of(Positions .readOnly(Collections.unmodifiableSortedMap(new TreeMap<String, Object>()).tailMap("foo")))) .booleanValue()); assertTrue(therianContext .eval(ImmutableCheck.of(Positions.readOnly( Collections.unmodifiableSortedMap(new TreeMap<String, Object>()).tailMap("foo").keySet()))) .booleanValue()); assertTrue(therianContext .eval(ImmutableCheck.of(Positions.readOnly( Collections.unmodifiableSortedMap(new TreeMap<String, Object>()).tailMap("foo").values()))) .booleanValue()); assertTrue(therianContext .eval(ImmutableCheck.of(Positions.readOnly(Collections .unmodifiableSortedMap(new TreeMap<String, Object>()).tailMap("foo").keySet().iterator()))) .booleanValue()); assertTrue(therianContext .eval(ImmutableCheck.of(Positions.readOnly(Collections .unmodifiableSortedMap(new TreeMap<String, Object>()).tailMap("foo").values().iterator()))) .booleanValue()); assertTrue(therianContext .eval(ImmutableCheck.of(Positions.readOnly( Collections.unmodifiableSortedMap(new TreeMap<String, Object>()).subMap("foo", "foo")))) .booleanValue()); assertTrue(therianContext .eval(ImmutableCheck.of(Positions.readOnly(Collections .unmodifiableSortedMap(new TreeMap<String, Object>()).subMap("foo", "foo").keySet()))) .booleanValue()); assertTrue(therianContext .eval(ImmutableCheck.of(Positions.readOnly(Collections .unmodifiableSortedMap(new TreeMap<String, Object>()).subMap("foo", "foo").values()))) .booleanValue()); assertTrue(therianContext.eval(ImmutableCheck.of(Positions.readOnly(Collections .unmodifiableSortedMap(new TreeMap<String, Object>()).subMap("foo", "foo").keySet().iterator()))) .booleanValue()); assertTrue(therianContext.eval(ImmutableCheck.of(Positions.readOnly(Collections .unmodifiableSortedMap(new TreeMap<String, Object>()).subMap("foo", "foo").values().iterator()))) .booleanValue()); }