/** * Returns an unmodifiable map backed by the given map. * <p> * This method uses the implementation in the decorators subpackage. * * @param <K> the key type * @param <V> the value type * @param map the map to make unmodifiable, must not be null * @return an unmodifiable map backed by the given map * @throws NullPointerException if the map is null */ public static <K, V> Map<K, V> unmodifiableMap(final Map<? extends K, ? extends V> map) { return UnmodifiableMap.unmodifiableMap(map); }
@Override public Map<K, Collection<V>> asMap() { return UnmodifiableMap.unmodifiableMap(decorated().asMap()); }
public Map<Term, Term> getEntries() { return UnmodifiableMap.unmodifiableMap(entries); }
public DatabaseAccountLocationsInfo(List<String> preferredLocations, URL defaultEndpoint) { this.preferredLocations = new UnmodifiableList<>(preferredLocations.stream().map(loc -> loc.toLowerCase()).collect(Collectors.toList())); this.availableWriteEndpointByLocation = (UnmodifiableMap) UnmodifiableMap.unmodifiableMap(new CaseInsensitiveMap<>()); this.availableReadEndpointByLocation = (UnmodifiableMap) UnmodifiableMap.unmodifiableMap(new CaseInsensitiveMap<>()); this.availableReadLocations = new UnmodifiableList<>(Collections.emptyList()); this.availableWriteLocations = new UnmodifiableList<>(Collections.emptyList()); this.readEndpoints = new UnmodifiableList<>(Collections.singletonList(defaultEndpoint)); this.writeEndpoints = new UnmodifiableList<>(Collections.singletonList(defaultEndpoint)); }
private UnmodifiableMap<String, URL> getEndpointByLocation(Iterable<DatabaseAccountLocation> locations, Utils.ValueHolder<UnmodifiableList<String>> orderedLocations) { Map<String, URL> endpointsByLocation = new CaseInsensitiveMap<>(); List<String> parsedLocations = new ArrayList<>(); for (DatabaseAccountLocation location: locations) { if (!Strings.isNullOrEmpty(location.getName())) { try { URL endpoint = new URL(location.getEndpoint().toLowerCase()); endpointsByLocation.put(location.getName().toLowerCase(), endpoint); parsedLocations.add(location.getName()); } catch (Exception e) { logger.warn("GetAvailableEndpointsByLocation() - skipping add for location = [{}] as it is location name is either empty or endpoint is malformed [{}]", location.getName(), location.getEndpoint()); } } } orderedLocations.v = new UnmodifiableList(parsedLocations); return (UnmodifiableMap) UnmodifiableMap.unmodifiableMap(endpointsByLocation); }
Math.max(this.version, other.version), Math.max(this.globalLsn, other.globalLsn), (UnmodifiableMap) UnmodifiableMap.unmodifiableMap(highestLocalLsnByRegion));
localLsnByRegion.v = (UnmodifiableMap) UnmodifiableMap.unmodifiableMap(lsnByRegion); return true;
public Term build() { // YilongL: Guava's ImmutableMap.copyOf(entries) is not smart enough // to avoid actually copying the entries, because entries is not an // ImmutableMap yet; using Apache's decorate method because it would // avoid creating nesting wrappers BuiltinMap builtinMap = new BuiltinMap( (UnmodifiableMap<Term, Term>) UnmodifiableMap.unmodifiableMap(entries), patternsBuilder.build(), functionsBuilder.build(), variablesBuilder.build(), global); return builtinMap.baseTerms().size() == 1 && builtinMap.collectionVariables().size() == 1 && builtinMap.concreteSize() == 0 ? builtinMap.baseTerms().iterator().next() : builtinMap; } }