Java Code Examples for com.google.common.collect.ImmutableMap#copyOf()

The following examples show how to use com.google.common.collect.ImmutableMap#copyOf() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
/**
 * 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);
}
 
Example 2
Source Project: presto   File: IndexSourceNode.java    License: Apache License 2.0 6 votes vote down vote up
@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");
}
 
Example 3
Source Project: SimpleWeibo   File: AnnotationOutput.java    License: Apache License 2.0 6 votes vote down vote up
@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;
}
 
Example 4
Source Project: presto   File: OrcColumn.java    License: Apache License 2.0 6 votes vote down vote up
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"));
}
 
Example 5
Source Project: arcusplatform   File: BaseEntity.java    License: Apache License 2.0 5 votes vote down vote up
public final void setImages(Map<String,UUID> images) {
   if(images == null) {
      this.images = ImmutableMap.of();
   }
   else {
      this.images = ImmutableMap.copyOf(images);
   }
}
 
Example 6
Source Project: elasticactors   File: CacheManager.java    License: Apache License 2.0 5 votes vote down vote up
@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);
}
 
Example 7
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)));
    }
}
 
Example 8
@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();
}
 
Example 9
Source Project: docker-client   File: ContainerConfig.java    License: Apache License 2.0 5 votes vote down vote up
@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);
}
 
Example 10
Source Project: circus-train   File: TableReplication.java    License: Apache License 2.0 5 votes vote down vote up
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);
}
 
Example 11
Source Project: keywhiz   File: Secret.java    License: Apache License 2.0 5 votes vote down vote up
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);
}
 
Example 12
Source Project: helios   File: Job.java    License: Apache License 2.0 4 votes vote down vote up
public Map<String, String> getLabels() {
  return ImmutableMap.copyOf(pm.labels);
}
 
Example 13
@Override
public ImmutableMap<String, String> getResult() {
  return ImmutableMap.copyOf(properties);
}
 
Example 14
public StreamSources(Map<StreamId, StreamSource<?>> streamSources)
{
    this.streamSources = ImmutableMap.copyOf(requireNonNull(streamSources, "streamSources is null"));
}
 
Example 15
public static NetFlowV9Record create(Map<String, Object> fields) {
    return new AutoValue_NetFlowV9Record(ImmutableMap.copyOf(fields));
}
 
Example 16
Source Project: helios   File: Job.java    License: Apache License 2.0 4 votes vote down vote up
public Map<String, String> getVolumes() {
  return ImmutableMap.copyOf(pm.volumes);
}
 
Example 17
private DefaultSwaptionMarketDataLookup(
    Map<IborIndex, SwaptionVolatilitiesId> volatilityIds) {
  JodaBeanUtils.notNull(volatilityIds, "volatilityIds");
  this.volatilityIds = ImmutableMap.copyOf(volatilityIds);
}
 
Example 18
Source Project: Strata   File: XmlElement.java    License: Apache License 2.0 2 votes vote down vote up
/**
 * 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());
}
 
Example 19
/**
 * 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));
}
 
Example 20
Source Project: jelectrum   File: TransactionSummary.java    License: MIT License votes vote down vote up
public Map<Integer, TransactionInSummary> getInputs(){ return ImmutableMap.copyOf(ins); }