/** * A convenience method for creating a synchronized SortedMap. * * @param self a SortedMap * @return a synchronized SortedMap * @see java.util.Collections#synchronizedSortedMap(java.util.SortedMap) * @since 1.0 */ public static <K,V> SortedMap<K,V> asSynchronized(SortedMap<K,V> self) { return Collections.synchronizedSortedMap(self); }
/** * Returns a synchronized sorted map backed by the given sorted map. * <p> * You must manually synchronize on the returned buffer's iterator to * avoid non-deterministic behavior: * * <pre> * Map m = MapUtils.synchronizedSortedMap(myMap); * Set s = m.keySet(); // outside synchronized block * synchronized (m) { // synchronized on MAP! * Iterator i = s.iterator(); * while (i.hasNext()) { * process (i.next()); * } * } * </pre> * * This method uses the implementation in {@link java.util.Collections Collections}. * * @param map the map to synchronize, must not be null * @return a synchronized map backed by the given map * @throws IllegalArgumentException if the map is null */ public static Map synchronizedSortedMap(SortedMap map) { return Collections.synchronizedSortedMap(map); }
/** * Returns a synchronized sorted map backed by the given sorted map. * <p> * You must manually synchronize on the returned buffer's iterator to * avoid non-deterministic behavior: * * <pre> * Map m = MapUtils.synchronizedSortedMap(myMap); * Set s = m.keySet(); // outside synchronized block * synchronized (m) { // synchronized on MAP! * Iterator i = s.iterator(); * while (i.hasNext()) { * process (i.next()); * } * } * </pre> * * This method uses the implementation in {@link java.util.Collections Collections}. * * @param map the map to synchronize, must not be null * @return a synchronized map backed by the given map * @throws IllegalArgumentException if the map is null */ public static Map synchronizedSortedMap(SortedMap map) { return Collections.synchronizedSortedMap(map); }
/** * Returns a synchronized sorted map backed by the given sorted map. * <p> * You must manually synchronize on the returned buffer's iterator to * avoid non-deterministic behavior: * * <pre> * Map m = MapUtils.synchronizedSortedMap(myMap); * Set s = m.keySet(); // outside synchronized block * synchronized (m) { // synchronized on MAP! * Iterator i = s.iterator(); * while (i.hasNext()) { * process (i.next()); * } * } * </pre> * * This method uses the implementation in {@link java.util.Collections Collections}. * * @param <K> the key type * @param <V> the value type * @param map the map to synchronize, must not be null * @return a synchronized map backed by the given map * @throws NullPointerException if the map is null */ public static <K, V> SortedMap<K, V> synchronizedSortedMap(final SortedMap<K, V> map) { return Collections.synchronizedSortedMap(map); }
classes.add(Collections.synchronizedNavigableSet(Collections.emptyNavigableSet()).getClass()); classes.add(Collections.synchronizedSet(Collections.emptySet()).getClass()); classes.add(Collections.synchronizedSortedMap(Collections.emptySortedMap()).getClass()); classes.add(Collections.synchronizedSortedSet(Collections.emptySortedSet()).getClass());
PojoWithObjectMapFields fill() { TreeMap<String, String> tm = new TreeMap<String, String>(); tm.put("foo", "bar"); EnumMap<GuitarPickup, Size> em = new EnumMap<GuitarPickup, Size>( GuitarPickup.class); em.put(GuitarPickup.CONTACT, Size.SMALL); emptyMap = Collections.emptyMap(); singletonMap = Collections.singletonMap("key", "value"); unmodifiableMap = Collections.unmodifiableMap(Collections .emptyMap()); unmodifiableSortedMap = Collections.unmodifiableSortedMap(tm); synchronizedMap = Collections.synchronizedMap(em); synchronizedSortedMap = Collections.synchronizedSortedMap(tm); checkedMap = Collections.checkedMap(em, GuitarPickup.class, Size.class); checkedSortedMap = Collections.checkedSortedMap(tm, String.class, String.class); return this; }
/** * Create a base 64 encoded SHA1 hash key for a given XML element. The key * is based on the element name, the attribute names and their values. Child * elements are ignored. Attributes named 'z' are not concluded since they * contain the hash key itself. * * @param element The element to create the base 64 encoded hash key for * @return the unique key */ public static String calculateUniqueKeyFor(final Element element) { final StringBuilder sb = new StringBuilder(); sb.append(element.getTagName()); final NamedNodeMap attributes = element.getAttributes(); final SortedMap<String, String> attrKVStore = Collections.synchronizedSortedMap(new TreeMap<String, String>()); for (int i = 0, n = attributes.getLength(); i < n; i++) { final Node attr = attributes.item(i); if (!"z".equals(attr.getNodeName()) && !attr.getNodeName().startsWith("_")) { attrKVStore.put(attr.getNodeName(), attr.getNodeValue()); } } for (final Entry<String, String> entry : attrKVStore.entrySet()) { sb.append(entry.getKey()).append(entry.getValue()); } return Base64.encodeBase64String(sha1(sb.toString().getBytes())); }
.synchronizedSortedMap(new TreeMap<>()); .synchronizedSortedMap(new TreeMap<>());
@Override public Object create( final Object sourceCollection ) { return Collections.synchronizedSortedMap( (SortedMap<?, ?>) sourceCollection ); } };
@Override public Object create( final Object sourceCollection ) { return Collections.synchronizedSortedMap( (SortedMap<?, ?>) sourceCollection ); } };
/** Creates a new instance of NameTable */ protected NameTable() { super (TrueTypeTable.NAME_TABLE); records = Collections.synchronizedSortedMap(new TreeMap<NameRecord,String>()); }
/** Creates a new instance of NameTable */ protected NameTable() { super (TrueTypeTable.NAME_TABLE); records = Collections.synchronizedSortedMap(new TreeMap<NameRecord,String>()); }
@Inject public OperationTimeHistory() { queriesTime = Collections.synchronizedSortedMap(new TreeMap<Long, Long>()); updatesTime = Collections.synchronizedSortedMap(new TreeMap<Long, Long>()); commitTime = Collections.synchronizedSortedMap(new TreeMap<Long, Long>()); optimizeTime = Collections.synchronizedSortedMap(new TreeMap<Long, Long>()); initTime = new Date().getTime(); }
SortedMap<String, String> treeMap = new TreeMap<String, String>(); // prints true System.out.println(treeMap.keySet() instanceof SortedSet); // prints false System.out.println(Collections.synchronizedSortedMap(treeMap).keySet() instanceof SortedSet);
/** Creates a new instance of CmapTable */ protected CmapTable() { super(TrueTypeTable.CMAP_TABLE); setVersion((short) 0x0); subtables = Collections.synchronizedSortedMap(new TreeMap<CmapSubtable,CMap>()); }
@Override public final SortedMap<Integer, Version> getComponentVersionMap() { synchronized (versionMap) { checkComponentVersionMap(); return synchronizedSortedMap(versionMap); } }
public SortedMap<ColumnDescription, String> getLabels() { SortedMap<ColumnDescription, String> nodeLabels = Collections.synchronizedSortedMap(new TreeMap<ColumnDescription, String>()); for (Integer key : labels.keySet()) { nodeLabels.put(graph.getDataFormat().getColumnDescription(key), labels.get(key)); } return nodeLabels; }
public DefaultMOServer() { this.registry = Collections.synchronizedSortedMap(new TreeMap(new MOScopeComparator())); this.contexts = new LinkedHashSet(10); this.lockList = new Hashtable(10); }
protected TerracottaTreeCache(boolean isThreadSafe) { if (isThreadSafe) { cacheTree = Collections.synchronizedSortedMap(new TreeMap<Fqn,Map>(new Fqn())); fqnSet = Collections.synchronizedSortedSet(new TreeSet<Fqn>(new Fqn())); } else { cacheTree = new TreeMap<Fqn,Map>(new Fqn()); fqnSet = new TreeSet<Fqn>(new Fqn()); } }
private MetadataProperties mockMetadataProperties() { SortedMap<Integer, ClusterPartition> clusterPartitions = Collections.synchronizedSortedMap(new TreeMap<>()); Map<String, ClusterPartition[]> nodePartitionsMap = new ConcurrentHashMap<>(); nodePartitionsMap.put(METADATA_NODE, new ClusterPartition[] { new ClusterPartition(0, METADATA_NODE, 0) }); MetadataProperties metadataProperties = Mockito.mock(MetadataProperties.class); Mockito.when(metadataProperties.getMetadataNodeName()).thenReturn(METADATA_NODE); Mockito.when(metadataProperties.getClusterPartitions()).thenReturn(clusterPartitions); Mockito.when(metadataProperties.getNodePartitions()).thenReturn(nodePartitionsMap); return metadataProperties; }