Java Code Examples for java.util.Collections.unmodifiableSortedMap()

The following are Jave code examples for showing how to use unmodifiableSortedMap() of the java.util.Collections class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: googles-monorepo-demo   File: Maps.java   View Source Code Vote up 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 2
Project: guava-mock   File: Maps.java   View Source Code Vote up 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 3
Project: s-store   File: Maps.java   View Source Code Vote up 5 votes
private static <K, V> Map<K, V> unmodifiableMap(Map<K, V> map) {
  if (map instanceof SortedMap) {
    return Collections.unmodifiableSortedMap((SortedMap<K, ? extends V>) map);
  } else {
    return Collections.unmodifiableMap(map);
  }
}
 
Example 4
Project: jdk8u-jdk   File: java_util_Collections_UnmodifiableSortedMap.java   View Source Code Vote up 4 votes
protected SortedMap<String, String> getObject() {
    SortedMap<String, String> map = new TreeMap<String, String>();
    map.put("key", "value");
    return Collections.unmodifiableSortedMap(map);
}
 
Example 5
Project: jdk8u-jdk   File: java_util_Collections_UnmodifiableSortedMap.java   View Source Code Vote up 4 votes
protected SortedMap<String, String> getAnotherObject() {
    SortedMap<String, String> map = new TreeMap<String, String>();
    return Collections.unmodifiableSortedMap(map);
}
 
Example 6
Project: openjdk-jdk10   File: java_util_Collections_UnmodifiableSortedMap.java   View Source Code Vote up 4 votes
protected SortedMap<String, String> getObject() {
    SortedMap<String, String> map = new TreeMap<String, String>();
    map.put("key", "value");
    return Collections.unmodifiableSortedMap(map);
}
 
Example 7
Project: googles-monorepo-demo   File: Maps.java   View Source Code Vote up 4 votes
@Override
protected SortedMap<K, V> delegate() {
  return Collections.unmodifiableSortedMap(delegate);
}
 
Example 8
Project: HCFCore   File: UnmodifiableTrie.java   View Source Code Vote up 4 votes
public SortedMap<K, V> tailMap(final K fromKey) {
    return Collections.unmodifiableSortedMap(delegate.tailMap(fromKey));
}
 
Example 9
Project: vexillo   File: FlagFontFamily.java   View Source Code Vote up 4 votes
public SortedMap<EncodingNode, Flag> getFlagMap() {
	return Collections.unmodifiableSortedMap(flags);
}
 
Example 10
Project: HCFCore   File: UnmodifiableTrie.java   View Source Code Vote up 4 votes
public SortedMap<K, V> subMap(final K fromKey, final K toKey) {
    return Collections.unmodifiableSortedMap(delegate.subMap(fromKey, toKey));
}
 
Example 11
Project: cjk-mmseg   File: Tries.java   View Source Code Vote up 4 votes
@Override
public SortedMap<K, V> headMap(K toKey) {
  return Collections.unmodifiableSortedMap(delegate.headMap(toKey));
}
 
Example 12
Project: HCFCore   File: UnmodifiableTrie.java   View Source Code Vote up 4 votes
public SortedMap<K, V> tailMap(final K fromKey) {
    return Collections.unmodifiableSortedMap(delegate.tailMap(fromKey));
}
 
Example 13
Project: guava-mock   File: Maps.java   View Source Code Vote up 4 votes
@Override
protected SortedMap<K, V> delegate() {
  return Collections.unmodifiableSortedMap(delegate);
}
 
Example 14
Project: diorite-configs-java8   File: YamlCollectionCreator.java   View Source Code Vote up 4 votes
@SuppressWarnings({"unchecked", "rawtypes", "SuspiciousSystemArraycopy"})
@Nullable
public static <T> T makeUnmodifiable(Object collection)
{
    if (collection.getClass().isArray())
    {
        int length = Array.getLength(collection);
        if (length == 0)
        {
            return (T) DioriteArrayUtils.getEmptyObjectArray(collection.getClass().getComponentType());
        }
        Object copy = DioriteArrayUtils.newArray(collection.getClass().getComponentType(), length);
        System.arraycopy(collection, 0, copy, 0, length);
        return (T) copy;
    }
    Function function = unmodifiableWrappers.get(collection.getClass());
    if (function == null)
    {
        for (Entry<Class<?>, Function<?, ?>> entry : unmodifiableWrappers.entrySet())
        {
            if (entry.getKey().isInstance(collection))
            {
                function = entry.getValue();
                break;
            }
        }
        if (function != null)
        {
            unmodifiableWrappers.put(collection.getClass(), function);
            return (T) function.apply(collection);
        }

        if (collection instanceof Collection)
        {
            if (collection instanceof Set)
            {
                if (collection instanceof NavigableSet)
                {
                    return (T) Collections.unmodifiableNavigableSet((NavigableSet<?>) collection);
                }
                if (collection instanceof SortedSet)
                {
                    return (T) Collections.unmodifiableSortedSet((SortedSet<?>) collection);
                }
                return (T) Collections.unmodifiableSet((Set<?>) collection);
            }
            if (collection instanceof List)
            {
                return (T) Collections.unmodifiableList((List<?>) collection);
            }
            return (T) Collections.unmodifiableCollection((Collection<?>) collection);
        }
        else if (collection instanceof Map)
        {
            if (collection instanceof NavigableMap)
            {
                return (T) Collections.unmodifiableNavigableMap((NavigableMap<?, ?>) collection);
            }
            if (collection instanceof SortedMap)
            {
                return (T) Collections.unmodifiableSortedMap((SortedMap<?, ?>) collection);
            }
            return (T) Collections.unmodifiableMap((Map<?, ?>) collection);
        }
        else
        {
            new RuntimeException("Can't make this collection unmodifiable: " + collection.getClass().getName()).printStackTrace();
            return (T) collection;
        }
    }
    return (T) function.apply(collection);
}
 
Example 15
Project: cjk-mmseg   File: Tries.java   View Source Code Vote up 4 votes
@Override
public SortedMap<K, V> tailMap(K fromKey) {
  return Collections.unmodifiableSortedMap(delegate.tailMap(fromKey));
}
 
Example 16
Project: s-store   File: Maps.java   View Source Code Vote up 4 votes
@Override
protected SortedMap<K, V> delegate() {
  return Collections.unmodifiableSortedMap(delegate);
}
 
Example 17
Project: HCFCore   File: UnmodifiableTrie.java   View Source Code Vote up 4 votes
public SortedMap<K, V> headMap(final K toKey) {
    return Collections.unmodifiableSortedMap(delegate.headMap(toKey));
}
 
Example 18
Project: HCFCore   File: UnmodifiableTrie.java   View Source Code Vote up 4 votes
public SortedMap<K, V> subMap(final K fromKey, final K toKey) {
    return Collections.unmodifiableSortedMap(delegate.subMap(fromKey, toKey));
}
 
Example 19
Project: util   File: MapUtil.java   View Source Code Vote up 2 votes
/**
 * 返回包装后不可修改的有序Map.
 * 
 * @see java.util.Collections#unmodifiableSortedMap(SortedMap)
 */
public static <K, V> SortedMap<K, V> unmodifiableSortedMap(final SortedMap<K, ? extends V> m) {
	return Collections.unmodifiableSortedMap(m);
}
 
Example 20
Project: JavaGraph   File: TypeGraph.java   View Source Code Vote up 2 votes
/**
 * Returns the (possibly empty) mapping from component type graphs
 * to the elements defined therein.
 * The map is only nonempty if this is a composite type graph, filled
 * through calls of {@link #add(TypeGraph)}.
 */
public SortedMap<String,Sub> getComponentMap() {
    return Collections.unmodifiableSortedMap(this.componentMap);
}