com.google.common.collect.ImmutableMap#copyOf ( )源码实例Demo

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

/**
 * Obtains an instance from the specified parameters.
 * <p>
 * The map provides a lookup from the {@link CalculationTarget} implementation type
 * to the appropriate parameter to use for that target. If a target is requested that
 * is not in the map, the default parameter is used.
 * 
 * @param parameters  the parameters, keyed by target type
 * @param defaultParameter  the default parameter
 * @return the target aware parameter
 */
public static TradeCounterpartyCalculationParameter of(
    Map<StandardId, CalculationParameter> parameters,
    CalculationParameter defaultParameter) {

  ArgChecker.notEmpty(parameters, "values");
  ArgChecker.notNull(defaultParameter, "defaultParameter");
  Class<? extends CalculationParameter> queryType = defaultParameter.queryType();
  for (CalculationParameter value : parameters.values()) {
    if (value.queryType() != queryType) {
      throw new IllegalArgumentException(Messages.format(
          "Map contained a parameter '{}' that did not match the expected query type '{}'",
          value,
          queryType.getClass().getSimpleName()));
    }
  }
  return new TradeCounterpartyCalculationParameter(queryType, ImmutableMap.copyOf(parameters), defaultParameter);
}
 
源代码2 项目: presto   文件: IndexSourceNode.java
@JsonCreator
public IndexSourceNode(
        @JsonProperty("id") PlanNodeId id,
        @JsonProperty("indexHandle") IndexHandle indexHandle,
        @JsonProperty("tableHandle") TableHandle tableHandle,
        @JsonProperty("lookupSymbols") Set<Symbol> lookupSymbols,
        @JsonProperty("outputSymbols") List<Symbol> outputSymbols,
        @JsonProperty("assignments") Map<Symbol, ColumnHandle> assignments)
{
    super(id);
    this.indexHandle = requireNonNull(indexHandle, "indexHandle is null");
    this.tableHandle = requireNonNull(tableHandle, "tableHandle is null");
    this.lookupSymbols = ImmutableSet.copyOf(requireNonNull(lookupSymbols, "lookupSymbols is null"));
    this.outputSymbols = ImmutableList.copyOf(requireNonNull(outputSymbols, "outputSymbols is null"));
    this.assignments = ImmutableMap.copyOf(requireNonNull(assignments, "assignments is null"));
    checkArgument(!lookupSymbols.isEmpty(), "lookupSymbols is empty");
    checkArgument(!outputSymbols.isEmpty(), "outputSymbols is empty");
    checkArgument(assignments.keySet().containsAll(lookupSymbols), "Assignments do not include all lookup symbols");
    checkArgument(outputSymbols.containsAll(lookupSymbols), "Lookup symbols need to be part of the output symbols");
}
 
源代码3 项目: SimpleWeibo   文件: AnnotationOutput.java
@Override
public Void visitAnnotation(AnnotationMirror a, StringBuilder sb) {
  sb.append('@').append(typeSimplifier.simplify(a.getAnnotationType()));
  Map<ExecutableElement, AnnotationValue> map = ImmutableMap.copyOf(a.getElementValues());
  if (!map.isEmpty()) {
    sb.append('(');
    String sep = "";
    for (Map.Entry<ExecutableElement, AnnotationValue> entry : map.entrySet()) {
      sb.append(sep).append(entry.getKey().getSimpleName()).append(" = ");
      sep = ", ";
      this.visit(entry.getValue(), sb);
    }
    sb.append(')');
  }
  return null;
}
 
源代码4 项目: presto   文件: OrcColumn.java
public OrcColumn(
        String path,
        OrcColumnId columnId,
        String columnName,
        OrcTypeKind columnType,
        OrcDataSourceId orcDataSourceId,
        List<OrcColumn> nestedColumns,
        Map<String, String> attributes)
{
    this.path = requireNonNull(path, "path is null");
    this.columnId = requireNonNull(columnId, "columnId is null");
    this.columnName = requireNonNull(columnName, "columnName is null");
    this.columnType = requireNonNull(columnType, "columnType is null");
    this.orcDataSourceId = requireNonNull(orcDataSourceId, "orcDataSourceId is null");
    this.nestedColumns = ImmutableList.copyOf(requireNonNull(nestedColumns, "nestedColumns is null"));
    this.attributes = ImmutableMap.copyOf(requireNonNull(attributes, "attributes is null"));
}
 
源代码5 项目: arcusplatform   文件: BaseEntity.java
public final void setImages(Map<String,UUID> images) {
   if(images == null) {
      this.images = ImmutableMap.of();
   }
   else {
      this.images = ImmutableMap.copyOf(images);
   }
}
 
源代码6 项目: elasticactors   文件: CacheManager.java
@Override
public ImmutableMap<K, V> getAllPresent(Iterable<?> keys) {
    Map<K,V> result = Maps.newLinkedHashMap();
    for (Object key : keys) {
        V value = backingCache.getIfPresent(new CacheKey(segmentKey,key));
        if(value != null) {
            result.put((K) key, value);
        }
    }
    return ImmutableMap.copyOf(result);
}
 
public AbstractCassandraStoreManager(Configuration config) {
    super(config, PORT_DEFAULT);

    this.keySpaceName = config.get(CASSANDRA_KEYSPACE);
    this.compressionEnabled = config.get(CF_COMPRESSION);
    this.compressionChunkSizeKB = config.get(CF_COMPRESSION_BLOCK_SIZE);
    this.compressionClass = config.get(CF_COMPRESSION_TYPE);
    this.atomicBatch = config.get(ATOMIC_BATCH_MUTATE);
    this.thriftFrameSizeBytes = config.get(THRIFT_FRAME_SIZE_MB) * 1024 * 1024;

    // SSL truststore location sanity check
    if (config.get(SSL_ENABLED) && config.get(SSL_TRUSTSTORE_LOCATION).isEmpty())
        throw new IllegalArgumentException(SSL_TRUSTSTORE_LOCATION.getName() + " could not be empty when SSL is enabled.");

    if (config.has(REPLICATION_OPTIONS)) {
        String[] options = config.get(REPLICATION_OPTIONS);

        if (options.length % 2 != 0)
            throw new IllegalArgumentException(REPLICATION_OPTIONS.getName() + " should have even number of elements.");

        Map<String, String> converted = new HashMap<String, String>(options.length / 2);

        for (int i = 0; i < options.length; i += 2) {
            converted.put(options[i], options[i + 1]);
        }

        this.strategyOptions = ImmutableMap.copyOf(converted);
    } else {
        this.strategyOptions = ImmutableMap.of("replication_factor", String.valueOf(config.get(REPLICATION_FACTOR)));
    }
}
 
源代码8 项目: Elasticsearch   文件: PrivateElementsImpl.java
@Override
public Set<Key<?>> getExposedKeys() {
    if (exposedKeysToSources == null) {
        Map<Key<?>, Object> exposedKeysToSourcesMutable = Maps.newLinkedHashMap();
        for (ExposureBuilder<?> exposureBuilder : exposureBuilders) {
            exposedKeysToSourcesMutable.put(exposureBuilder.getKey(), exposureBuilder.getSource());
        }
        exposedKeysToSources = ImmutableMap.copyOf(exposedKeysToSourcesMutable);
        exposureBuilders = null;
    }

    return exposedKeysToSources.keySet();
}
 
源代码9 项目: docker-client   文件: ContainerConfig.java
@JsonCreator
public static NetworkingConfig create(
        @JsonProperty("EndpointsConfig") final Map<String, EndpointConfig> endpointsConfig) {
  final ImmutableMap<String, EndpointConfig> endpointsConfigCopy =
          endpointsConfig == null
                  ? ImmutableMap.<String, EndpointConfig>of()
                  : ImmutableMap.copyOf(endpointsConfig);
  return new AutoValue_ContainerConfig_NetworkingConfig(endpointsConfigCopy);
}
 
源代码10 项目: circus-train   文件: TableReplication.java
public static Map<String, Object> getMergedCopierOptions(
    Map<String, Object> baseCopierOptions,
    Map<String, Object> overrideCopierOptions) {
  Map<String, Object> mergedCopierOptions = new HashMap<>();
  if (baseCopierOptions != null) {
    mergedCopierOptions.putAll(baseCopierOptions);
  }
  if (overrideCopierOptions != null) {
    mergedCopierOptions.putAll(overrideCopierOptions);
  }
  return ImmutableMap.copyOf(mergedCopierOptions);
}
 
源代码11 项目: keywhiz   文件: Secret.java
public Secret(long id,
              String name,
              @Nullable String description,
              LazyString encryptedSecret,
              String checksum,
              ApiDate createdAt,
              @Nullable String createdBy,
              ApiDate updatedAt,
              @Nullable String updatedBy,
              @Nullable Map<String, String> metadata,
              @Nullable String type,
              @Nullable Map<String, String> generationOptions,
              long expiry,
              @Nullable Long version,
              @Nullable ApiDate contentCreatedAt,
              @Nullable String contentCreatedBy) {

  checkArgument(!name.isEmpty());
  this.id = id;
  this.name = name;
  this.description = nullToEmpty(description);
  this.encryptedSecret = checkNotNull(encryptedSecret);
  this.checksum = checksum;
  this.createdAt = checkNotNull(createdAt);
  this.createdBy = nullToEmpty(createdBy);
  this.updatedAt = checkNotNull(updatedAt);
  this.updatedBy = nullToEmpty(updatedBy);
  this.metadata = (metadata == null) ?
      ImmutableMap.of() : ImmutableMap.copyOf(metadata);
  this.type = type;
  this.generationOptions = (generationOptions == null) ?
      ImmutableMap.of() : ImmutableMap.copyOf(generationOptions);
  this.expiry = expiry;
  this.version = version;
  this.contentCreatedAt = contentCreatedAt;
  this.contentCreatedBy = nullToEmpty(contentCreatedBy);
}
 
源代码12 项目: helios   文件: Job.java
public Map<String, String> getLabels() {
  return ImmutableMap.copyOf(pm.labels);
}
 
源代码13 项目: android-test   文件: AndroidPropertyProcessor.java
@Override
public ImmutableMap<String, String> getResult() {
  return ImmutableMap.copyOf(properties);
}
 
源代码14 项目: spliceengine   文件: StreamSources.java
public StreamSources(Map<StreamId, StreamSource<?>> streamSources)
{
    this.streamSources = ImmutableMap.copyOf(requireNonNull(streamSources, "streamSources is null"));
}
 
源代码15 项目: graylog-plugin-netflow   文件: NetFlowV9Record.java
public static NetFlowV9Record create(Map<String, Object> fields) {
    return new AutoValue_NetFlowV9Record(ImmutableMap.copyOf(fields));
}
 
源代码16 项目: helios   文件: Job.java
public Map<String, String> getVolumes() {
  return ImmutableMap.copyOf(pm.volumes);
}
 
源代码17 项目: Strata   文件: DefaultSwaptionMarketDataLookup.java
private DefaultSwaptionMarketDataLookup(
    Map<IborIndex, SwaptionVolatilitiesId> volatilityIds) {
  JodaBeanUtils.notNull(volatilityIds, "volatilityIds");
  this.volatilityIds = ImmutableMap.copyOf(volatilityIds);
}
 
源代码18 项目: Strata   文件: XmlElement.java
/**
 * Obtains an instance with content and attributes.
 * <p>
 * Returns an element representing XML with content and attributes but no children.
 * 
 * @param name  the element name, not empty
 * @param attributes  the attributes, empty if the element has no attributes
 * @param content  the content, empty if the element has no content
 * @return the element
 */
public static XmlElement ofContent(String name, Map<String, String> attributes, String content) {
  return new XmlElement(name, ImmutableMap.copyOf(attributes), content, ImmutableList.of());
}
 
源代码19 项目: astor   文件: NameAnonymousFunctionsMapped.java
/**
 * Gets the function renaming map (the "answer key").
 *
 * @return A mapping from original names to new names
 */
VariableMap getFunctionMap() {
  return new VariableMap(ImmutableMap.copyOf(renameMap));
}
 
源代码20 项目: jelectrum   文件: TransactionSummary.java
public Map<Integer, TransactionInSummary> getInputs(){ return ImmutableMap.copyOf(ins); }