java.util.Map#copyOf ( )源码实例Demo

下面列出了java.util.Map#copyOf ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: presto   文件: MemoryPoolInfo.java
@JsonCreator
public MemoryPoolInfo(
        @JsonProperty("maxBytes") long maxBytes,
        @JsonProperty("reservedBytes") long reservedBytes,
        @JsonProperty("reservedRevocableBytes") long reservedRevocableBytes,
        @JsonProperty("queryMemoryReservations") Map<QueryId, Long> queryMemoryReservations,
        @JsonProperty("queryMemoryAllocations") Map<QueryId, List<MemoryAllocation>> queryMemoryAllocations,
        @JsonProperty("queryMemoryRevocableReservations") Map<QueryId, Long> queryMemoryRevocableReservations)
{
    this.maxBytes = maxBytes;
    this.reservedBytes = reservedBytes;
    this.reservedRevocableBytes = reservedRevocableBytes;
    this.queryMemoryReservations = Map.copyOf(queryMemoryReservations);
    this.queryMemoryAllocations = Map.copyOf(queryMemoryAllocations);
    this.queryMemoryRevocableReservations = Map.copyOf(queryMemoryRevocableReservations);
}
 
源代码2 项目: vespa   文件: LockedApplication.java
private LockedApplication(Lock lock, TenantAndApplicationId id, Instant createdAt, DeploymentSpec deploymentSpec,
                          ValidationOverrides validationOverrides,
                          Optional<IssueId> deploymentIssueId, Optional<IssueId> ownershipIssueId, Optional<User> owner,
                          OptionalInt majorVersion, ApplicationMetrics metrics, Set<PublicKey> deployKeys,
                          OptionalLong projectId, Optional<ApplicationVersion> latestVersion,
                          Map<InstanceName, Instance> instances) {
    this.lock = lock;
    this.id = id;
    this.createdAt = createdAt;
    this.deploymentSpec = deploymentSpec;
    this.validationOverrides = validationOverrides;
    this.deploymentIssueId = deploymentIssueId;
    this.ownershipIssueId = ownershipIssueId;
    this.owner = owner;
    this.majorVersion = majorVersion;
    this.metrics = metrics;
    this.deployKeys = deployKeys;
    this.projectId = projectId;
    this.latestVersion = latestVersion;
    this.instances = Map.copyOf(instances);
}
 
源代码3 项目: presto   文件: Identity.java
private Identity(
        String user,
        Set<String> groups,
        Optional<Principal> principal,
        Map<String, SelectedRole> roles,
        Map<String, String> extraCredentials,
        Optional<Runnable> onDestroy)
{
    this.user = requireNonNull(user, "user is null");
    this.groups = Set.copyOf(requireNonNull(groups, "groups is null"));
    this.principal = requireNonNull(principal, "principal is null");
    this.roles = Map.copyOf(requireNonNull(roles, "roles is null"));
    this.extraCredentials = Map.copyOf(requireNonNull(extraCredentials, "extraCredentials is null"));
    this.onDestroy = requireNonNull(onDestroy, "onDestroy is null");
}
 
源代码4 项目: presto   文件: ConnectorIdentity.java
private ConnectorIdentity(
        String user,
        Set<String> groups,
        Optional<Principal> principal,
        Optional<SelectedRole> role,
        Map<String, String> extraCredentials)
{
    this.user = requireNonNull(user, "user is null");
    this.groups = Set.copyOf(requireNonNull(groups, "groups is null"));
    this.principal = requireNonNull(principal, "principal is null");
    this.role = requireNonNull(role, "role is null");
    this.extraCredentials = Map.copyOf(requireNonNull(extraCredentials, "extraCredentials is null"));
}
 
源代码5 项目: presto   文件: AggregationApplicationResult.java
public AggregationApplicationResult(
        T handle,
        List<ConnectorExpression> projections,
        List<Assignment> assignments,
        Map<ColumnHandle, ColumnHandle> groupingColumnMapping)
{
    this.handle = requireNonNull(handle, "handle is null");
    requireNonNull(groupingColumnMapping, "goupingSetMapping is null");
    requireNonNull(projections, "projections is null");
    requireNonNull(assignments, "assignment is null");
    this.groupingColumnMapping = Map.copyOf(groupingColumnMapping);
    this.projections = List.copyOf(projections);
    this.assignments = List.copyOf(assignments);
}
 
源代码6 项目: vespa   文件: DeploymentMetrics.java
public DeploymentMetrics(double queriesPerSecond, double writesPerSecond, double documentCount,
                         double queryLatencyMillis, double writeLatencyMills, Optional<Instant> instant,
                         Map<Warning, Integer> warnings) {
    this.queriesPerSecond = queriesPerSecond;
    this.writesPerSecond = writesPerSecond;
    this.documentCount = documentCount;
    this.queryLatencyMillis = queryLatencyMillis;
    this.writeLatencyMills = writeLatencyMills;
    this.instant = Objects.requireNonNull(instant, "instant must be non-null");
    this.warnings = Map.copyOf(Objects.requireNonNull(warnings, "warnings must be non-null"));
    if (warnings.entrySet().stream().anyMatch(kv -> kv.getValue() < 0)) {
        throw new IllegalArgumentException("Warning count must be non-negative. Got " + warnings);
    }
}
 
源代码7 项目: lucene-solr   文件: CustomAnalyzerPanelProvider.java
@Override
public Map<String, String> getTokenFilterParams(int index) {
  if (index < 0 || index > tfParamsList.size()) {
    throw new IllegalArgumentException();
  }
  return Map.copyOf(tfParamsList.get(index));
}
 
源代码8 项目: vespa   文件: RotationStatus.java
private RotationStatus(Map<RotationId, Targets> status) {
    this.status = Map.copyOf(Objects.requireNonNull(status));
}
 
源代码9 项目: catnip   文件: RestPayloadException.java
public RestPayloadException(final Map<String, List<String>> failures) {
    super((String) null);
    this.failures = Map.copyOf(failures);
}
 
源代码10 项目: triplea   文件: ExpiringAfterWriteCache.java
@Override
public Map<IdT, ValueT> asMap() {
  return Map.copyOf(cache.asMap());
}
 
源代码11 项目: lucene-solr   文件: SearchResults.java
/**
 * Returns the field data of this document.
 */
public Map<String, String[]> getFieldValues() {
  return Map.copyOf(fieldValues);
}
 
源代码12 项目: vespa   文件: RotationStatus.java
public Targets(Map<ZoneId, RotationState> targets, Instant lastUpdated) {
    this.targets = Map.copyOf(Objects.requireNonNull(targets, "states must be non-null"));
    this.lastUpdated = Objects.requireNonNull(lastUpdated, "lastUpdated must be non-null");
}
 
源代码13 项目: lucene-solr   文件: Analysis.java
/**
 * Returns value of this attribute.
 */
public Map<String, String> getAttValues() {
  return Map.copyOf(attValues);
}
 
源代码14 项目: vespa   文件: ApplicationRepositoryTest.java
public Context(Map<String, ?> point) {
    this.point = Map.copyOf(point);
}
 
源代码15 项目: lucene-solr   文件: AnalysisSPILoader.java
/** 
 * Reloads the internal SPI list from the given {@link ClassLoader}.
 * Changes to the service list are visible after the method ends, all
 * iterators (e.g., from {@link #availableServices()},...) stay consistent. 
 * 
 * <p><b>NOTE:</b> Only new service providers are added, existing ones are
 * never removed or replaced.
 * 
 * <p><em>This method is expensive and should only be called for discovery
 * of new service providers on the given classpath/classloader!</em>
 */
public synchronized void reload(ClassLoader classloader) {
  Objects.requireNonNull(classloader, "classloader");
  final LinkedHashMap<String,Class<? extends S>> services = new LinkedHashMap<>(this.services);
  final LinkedHashSet<String> originalNames = new LinkedHashSet<>(this.originalNames);
  ServiceLoader.load(clazz, classloader).stream().map(ServiceLoader.Provider::type).forEachOrdered(service -> {
    String name = null;
    String originalName = null;
    Throwable cause = null;
    try {
      originalName = lookupSPIName(service);
      name = originalName.toLowerCase(Locale.ROOT);
      if (!isValidName(originalName)) {
        throw new ServiceConfigurationError("The name " + originalName + " for " + service.getName() +
            " is invalid: Allowed characters are (English) alphabet, digits, and underscore. It should be started with an alphabet.");
      }
    } catch (NoSuchFieldException | IllegalAccessException | IllegalStateException e) {
      cause = e;
    }
    if (name == null) {
      throw new ServiceConfigurationError("The class name " + service.getName() +
          " has no service name field: [public static final String NAME]", cause);
    }
    // only add the first one for each name, later services will be ignored
    // this allows to place services before others in classpath to make 
    // them used instead of others
    //
    // TODO: Should we disallow duplicate names here?
    // Allowing it may get confusing on collisions, as different packages
    // could contain same factory class, which is a naming bug!
    // When changing this be careful to allow reload()!
    if (!services.containsKey(name)) {
      services.put(name, service);
      // preserve (case-sensitive) original name for reference
      originalNames.add(originalName);
    }
  });

  // make sure that the number of lookup keys is same to the number of original names.
  // in fact this constraint should be met in existence checks of the lookup map key,
  // so this is more like an assertion rather than a status check.
  if (services.keySet().size() != originalNames.size()) {
    throw new ServiceConfigurationError("Service lookup key set is inconsistent with original name set!");
  }

  this.services = Map.copyOf(services);
  this.originalNames = Set.copyOf(originalNames);
}
 
源代码16 项目: lucene-solr   文件: BaseIndexFileFormatTestCase.java
/** Get information about which bytes have been read. */
public Map<String, FixedBitSet> getReadBytes() {
  return Map.copyOf(readBytes);
}
 
源代码17 项目: lucene-solr   文件: SegmentInfo.java
void setDiagnostics(Map<String, String> diagnostics) {
  this.diagnostics = Map.copyOf(Objects.requireNonNull(diagnostics));
}
 
源代码18 项目: vespa   文件: NodeTargetVersions.java
@JsonCreator
public NodeTargetVersions(@JsonProperty("versions") Map<NodeType, String> vespaVersions,
                          @JsonProperty("osVersions") Map<NodeType, String> osVersions) {
    this.vespaVersions = Map.copyOf(vespaVersions);
    this.osVersions = Map.copyOf(osVersions);
}
 
源代码19 项目: vespa   文件: FileReferenceDownloader.java
Map<FileReference, Double> downloadStatus() {
    synchronized (downloads) {
        return Map.copyOf(downloadStatus);
    }
}
 
源代码20 项目: ditto   文件: MappingStrategies.java
/**
 * Constructs a new AbstractMappingStrategies object.
 *
 * @param strategies the key-value pairs of the returned mapping strategies.
 * @throws NullPointerException if {@code strategies} is {@code null}.
 */
protected MappingStrategies(final Map<String, MappingStrategy> strategies) {
    this.strategies = Map.copyOf(checkNotNull(strategies, "strategies"));
}