List of usage examples for com.google.common.collect Maps toMap
public static <K, V> ImmutableMap<K, V> toMap(Iterator<K> keys, Function<? super K, V> valueFunction)
From source file:org.atlasapi.application.v3.ApplicationConfiguration.java
private static Map<Publisher, SourceStatus> noAPIKeySourceStatusMap() { return Maps.toMap(Publisher.all(), new Function<Publisher, SourceStatus>() { @Override/* w ww. j av a2s .c o m*/ public SourceStatus apply(Publisher input) { return input.enabledWithNoApiKey() ? SourceStatus.AVAILABLE_ENABLED : SourceStatus.UNAVAILABLE; } }); }
From source file:osgi.enroute.examples.led.controller.util.Utils.java
/** * Converts legacy {@link Dictionary} ADT to {@link Map} * * @param dictionary//ww w . j ava 2 s . c om * The legacy {@link Dictionary} object to transform * * @throws NullPointerException * if argument is null */ public static <K, V> Map<K, V> dictionaryToMap(final Dictionary<K, V> dictionary) { checkNotNull(dictionary); final Iterator<K> keysIter = Iterators.forEnumeration(dictionary.keys()); final Map<K, V> dict = Maps.toMap(keysIter, dictionary::get); return dict; }
From source file:com.github.tomakehurst.wiremock.extension.responsetemplating.RequestTemplateModel.java
public static RequestTemplateModel from(final Request request) { URI url = URI.create(request.getUrl()); Map<String, QueryParameter> rawQuery = Urls.splitQuery(url); Map<String, ListOrSingle<String>> adaptedQuery = Maps.transformValues(rawQuery, TO_TEMPLATE_MODEL); Map<String, ListOrSingle<String>> adaptedHeaders = Maps.toMap(request.getAllHeaderKeys(), new Function<String, ListOrSingle<String>>() { @Override/*from w w w . j av a2 s . c o m*/ public ListOrSingle<String> apply(String input) { return ListOrSingle.of(request.header(input).values()); } }); Map<String, ListOrSingle<String>> adaptedCookies = Maps.transformValues(request.getCookies(), new Function<Cookie, ListOrSingle<String>>() { @Override public ListOrSingle<String> apply(Cookie input) { return ListOrSingle.of(input.getValue()); } }); UrlPath path = new UrlPath(request.getUrl()); return new RequestTemplateModel(request.getUrl(), path, adaptedQuery, adaptedHeaders, adaptedCookies, request.getBodyAsString()); }
From source file:org.gradle.model.dsl.internal.spike.ModelRegistry.java
public Object get(ModelPath path) { ModelCreator modelCreator = creators.get(path); Map<String, Object> inputs = Maps.toMap(modelCreator.getInputPaths(), new Function<String, Object>() { public Object apply(String inputPath) { return get(ModelPath.path(inputPath)); }/*from w w w . ja v a 2 s.c om*/ }); Object result = modelCreator.create(inputs); Set<ModelPath> promisedPaths = getPromisedPaths(); for (ModelPath modelPath : promisedPaths) { if (path.isDirectChild(modelPath)) { closeChild(result, modelPath); } } return result; }
From source file:org.jclouds.functions.ExpandProperties.java
@Override public Properties apply(final Properties properties) { checkNotNull(properties, "properties cannot be null"); // Only expand the properties that are Strings Map<String, String> stringProperties = Maps.toMap(properties.stringPropertyNames(), new Function<String, String>() { @Override//from ww w. j a v a 2 s . c o m public String apply(String input) { return properties.getProperty(input); } }); boolean pendingReplacements = true; Map<String, String> propertiesToResolve = new HashMap<String, String>(stringProperties); while (pendingReplacements) { Map<String, String> leafs = leafs(propertiesToResolve); if (leafs.isEmpty()) { break; } pendingReplacements = resolveProperties(propertiesToResolve, leafs); } // Replace the values with the resolved ones Properties resolved = new Properties(); resolved.putAll(properties); for (Map.Entry<String, String> entry : propertiesToResolve.entrySet()) { resolved.setProperty(entry.getKey(), entry.getValue()); } return resolved; }
From source file:com.twitter.aurora.scheduler.configuration.SanitizedConfiguration.java
/** * Constructs a SanitizedConfiguration object and populates the set of {@link ITaskConfig}s for * the provided config./*www. j a v a 2 s . c o m*/ * * @param sanitized A sanitized configuration. */ @VisibleForTesting public SanitizedConfiguration(IJobConfiguration sanitized) { this.sanitized = sanitized; this.tasks = Maps.toMap( ContiguousSet.create(Range.closedOpen(0, sanitized.getInstanceCount()), DiscreteDomain.integers()), Functions.constant(sanitized.getTaskConfig())); }
From source file:google.registry.model.billing.RegistrarBillingUtils.java
/** * Returns query of {@link RegistrarBillingEntry} for each currency, most recent first. * * <p><b>Note:</b> Currency map keys are returned in sorted order, from {@link #getCurrencies()}. *//*from w w w .j a v a 2 s .com*/ public static ImmutableMap<CurrencyUnit, Query<RegistrarBillingEntry>> getBillingEntryQueries( final Registrar registrar) { return Maps.toMap(getCurrencies(), new Function<CurrencyUnit, Query<RegistrarBillingEntry>>() { @Override public Query<RegistrarBillingEntry> apply(CurrencyUnit currency) { return ofy().load().type(RegistrarBillingEntry.class).ancestor(registrar) .filter("currency", currency).order("-created"); } }); }
From source file:com.dangdang.ddframe.rdb.sharding.merger.resultset.memory.row.GroupByResultSetRow.java
public GroupByResultSetRow(final ResultSet resultSet, final List<GroupByColumn> groupByColumns, final List<AggregationColumn> aggregationColumns) throws SQLException { super(resultSet); this.resultSet = resultSet; this.groupByColumns = groupByColumns; aggregationUnitMap = Maps.toMap(aggregationColumns, new Function<AggregationColumn, AggregationUnit>() { @Override// w w w . java 2 s .c o m public AggregationUnit apply(final AggregationColumn input) { return AggregationUnitFactory.create(input.getAggregationType()); } }); }
From source file:fi.hsl.parkandride.core.service.FacilityHistoryService.java
/** * Deduces the status history for the given date range. * If the status changes during the day, the status that was mostly active * during the period of 6 to 10 a.m. is selected. *///from w w w. j a va 2 s . c om @TransactionalRead public Map<LocalDate, FacilityStatus> getStatusHistoryByDay(final long facilityId, final LocalDate start, final LocalDate end) { final List<FacilityStatusHistory> statusHistory = facilityHistoryRepository.getStatusHistory(facilityId, start, end); return Maps.toMap(dateRangeClosed(start, end), date -> findEntryForDate(statusHistory, date, IDENTITY_STATUS).status); }
From source file:dagger.internal.codegen.ComponentHierarchyValidator.java
ValidationReport<TypeElement> validate(ComponentDescriptor componentDescriptor) { ValidationReport.Builder<TypeElement> report = ValidationReport .about(componentDescriptor.componentDefinitionType()); validateSubcomponentMethods(report, componentDescriptor, Maps.toMap(componentDescriptor.transitiveModuleTypes(), constant(componentDescriptor.componentDefinitionType()))); if (compilerOptions.scopeCycleValidationType().diagnosticKind().isPresent()) { validateScopeHierarchy(report, componentDescriptor, LinkedHashMultimap.<ComponentDescriptor, Scope>create()); }/*w ww.j a v a 2 s. c om*/ return report.build(); }