List of usage examples for com.google.common.collect ImmutableMap copyOf
public static <K, V> ImmutableMap<K, V> copyOf(Iterable<? extends Entry<? extends K, ? extends V>> entries)
From source file:com.google.gerrit.server.change.AllowedFormats.java
@Inject AllowedFormats(DownloadConfig cfg) {/*from w ww . ja va2 s. c om*/ Map<String, ArchiveFormat> exts = new HashMap<>(); for (ArchiveFormat format : cfg.getArchiveFormats()) { for (String ext : format.getSuffixes()) { exts.put(ext, format); } exts.put(format.name().toLowerCase(), format); } extensions = ImmutableMap.copyOf(exts); // Zip is not supported because it may be interpreted by a Java plugin as a // valid JAR file, whose code would have access to cookies on the domain. allowed = Sets.immutableEnumSet(Iterables.filter(cfg.getArchiveFormats(), f -> f != ArchiveFormat.ZIP)); }
From source file:com.github.tomakehurst.wiremock.verification.LoggedRequest.java
public static LoggedRequest createFrom(Request request) { return new LoggedRequest(request.getUrl(), request.getAbsoluteUrl(), request.getMethod(), request.getClientIp(), copyOf(request.getHeaders()), ImmutableMap.copyOf(request.getCookies()), request.isBrowserProxyRequest(), new Date(), request.getBodyAsBase64(), null); }
From source file:org.opendaylight.yangtools.yang.parser.impl.SchemaContextImpl.java
SchemaContextImpl(final Set<Module> modules, final Map<ModuleIdentifier, String> identifiersToSources) { this.identifiersToSources = ImmutableMap.copyOf(identifiersToSources); /*//from w w w.java 2 s. c om * Instead of doing this on each invocation of getModules(), pre-compute * it once and keep it around -- better than the set we got in. */ this.modules = ImmutableSet.copyOf(ModuleDependencySort.sort(modules.toArray(new Module[modules.size()]))); /* * The most common lookup is from Namespace->Module. * * RESTCONF performs lookups based on module name only, where it wants * to receive the latest revision * * Invest some quality time in building up lookup tables for both. */ final SetMultimap<URI, Module> nsMap = Multimaps.newSetMultimap(new TreeMap<URI, Collection<Module>>(), MODULE_SET_SUPPLIER); final SetMultimap<String, Module> nameMap = Multimaps .newSetMultimap(new TreeMap<String, Collection<Module>>(), MODULE_SET_SUPPLIER); for (Module m : modules) { nameMap.put(m.getName(), m); nsMap.put(m.getNamespace(), m); } namespaceToModules = ImmutableSetMultimap.copyOf(nsMap); nameToModules = ImmutableSetMultimap.copyOf(nameMap); }
From source file:org.gradle.api.internal.attributes.ImmutableAttributes.java
ImmutableAttributes(Map<Attribute<?>, Object> attributes) { assert !attributes.isEmpty(); this.attributes = ImmutableMap.copyOf(attributes); }
From source file:com.github.heuermh.personalgenome.client.Genotype.java
public Genotype(final String profileId, final Map<String, String> values) { checkNotNull(profileId);/*from w w w. java2s.c om*/ checkNotNull(values); this.profileId = profileId; this.values = ImmutableMap.copyOf(values); }
From source file:org.opendaylight.controller.cluster.sharding.DistributedShardModificationFactory.java
DistributedShardModificationFactory(final DOMDataTreeIdentifier root, final Map<PathArgument, WriteableModificationNode> children, final Map<DOMDataTreeIdentifier, ForeignShardModificationContext> childShards) { this.root = Preconditions.checkNotNull(root); this.children = ImmutableMap.copyOf(children); this.childShards = ImmutableMap.copyOf(childShards); }
From source file:org.seedstack.seed.core.internal.el.ELModule.java
@Override protected void configure() { bind(ExpressionFactory.class).toInstance(ExpressionFactory.newInstance()); bind(ELService.class).to(ELServiceInternal.class); bind(ELContextBuilder.class).to(ELContextBuilderImpl.class); for (Class<ELHandler> elHandlerClass : elMap.values()) { bind(elHandlerClass);/* ww w .j a v a2s .c o m*/ } // bind the map of annotation -> ELHandler bind(MAP_TYPE_LITERAL).toInstance(ImmutableMap.copyOf(elMap)); }
From source file:org.opendaylight.yangtools.yang.parser.impl.util.YangSourceFromDependencyInfoResolver.java
public YangSourceFromDependencyInfoResolver( final Map<SourceIdentifier, YangModelDependencyInfo> moduleDependencies, AdvancedSchemaSourceProvider<InputStream> sourceProvider) { super(sourceProvider); dependencyInfo = ImmutableMap.copyOf(moduleDependencies); }
From source file:io.prestosql.plugin.hive.HivePartition.java
public HivePartition(SchemaTableName tableName, String partitionId, Map<ColumnHandle, NullableValue> keys) { this.tableName = requireNonNull(tableName, "tableName is null"); this.partitionId = requireNonNull(partitionId, "partitionId is null"); this.keys = ImmutableMap.copyOf(requireNonNull(keys, "keys is null")); }
From source file:com.facebook.presto.ml.Dataset.java
public Dataset(List<Double> labels, List<FeatureVector> datapoints, Map<Integer, String> labelEnumeration) { requireNonNull(datapoints, "datapoints is null"); requireNonNull(labels, "labels is null"); requireNonNull(labelEnumeration, "labelEnumeration is null"); checkArgument(datapoints.size() == labels.size(), "datapoints and labels have different sizes"); this.labels = ImmutableList.copyOf(labels); this.datapoints = ImmutableList.copyOf(datapoints); this.labelEnumeration = ImmutableMap.copyOf(labelEnumeration); }