下面列出了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);
}
@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");
}
@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;
}
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"));
}
public final void setImages(Map<String,UUID> images) {
if(images == null) {
this.images = ImmutableMap.of();
}
else {
this.images = ImmutableMap.copyOf(images);
}
}
@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)));
}
}
@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();
}
@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);
}
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);
}
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);
}
public Map<String, String> getLabels() {
return ImmutableMap.copyOf(pm.labels);
}
@Override
public ImmutableMap<String, String> getResult() {
return ImmutableMap.copyOf(properties);
}
public StreamSources(Map<StreamId, StreamSource<?>> streamSources)
{
this.streamSources = ImmutableMap.copyOf(requireNonNull(streamSources, "streamSources is null"));
}
public static NetFlowV9Record create(Map<String, Object> fields) {
return new AutoValue_NetFlowV9Record(ImmutableMap.copyOf(fields));
}
public Map<String, String> getVolumes() {
return ImmutableMap.copyOf(pm.volumes);
}
private DefaultSwaptionMarketDataLookup(
Map<IborIndex, SwaptionVolatilitiesId> volatilityIds) {
JodaBeanUtils.notNull(volatilityIds, "volatilityIds");
this.volatilityIds = ImmutableMap.copyOf(volatilityIds);
}
/**
* 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());
}
/**
* 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));
}
public Map<Integer, TransactionInSummary> getInputs(){ return ImmutableMap.copyOf(ins); }