List of usage examples for com.google.common.collect ImmutableMap builder
public static <K, V> Builder<K, V> builder()
From source file:org.apereo.portal.events.tincan.converters.LoginEventConverter.java
@Override protected LrsObject getLrsObject(PortalEvent event) { Builder<String, LocalizedString> definitionBuilder = ImmutableMap.builder(); return new LrsObject(buildUrn("Login"), getDefaultObjectType(), definitionBuilder.build()); }
From source file:org.gradle.api.internal.changedetection.rules.InputPropertyValueTaskStateChanges.java
public InputPropertyValueTaskStateChanges(TaskExecution previousExecution, TaskExecution currentExecution, TaskInternal task) {//ww w .jav a2 s . c om ImmutableSortedMap<String, ValueSnapshot> previousInputProperties = previousExecution.getInputProperties(); ImmutableMap.Builder<String, String> changedBuilder = ImmutableMap.builder(); ImmutableSortedMap<String, ValueSnapshot> currentInputProperties = currentExecution.getInputProperties(); for (Map.Entry<String, ValueSnapshot> entry : currentInputProperties.entrySet()) { String propertyName = entry.getKey(); ValueSnapshot currentSnapshot = entry.getValue(); ValueSnapshot previousSnapshot = previousInputProperties.get(propertyName); if (previousSnapshot != null) { if (!currentSnapshot.equals(previousSnapshot)) { changedBuilder.put(propertyName, currentSnapshot instanceof ImplementationSnapshot ? "Implementation" : "Value"); } } } this.changed = changedBuilder.build(); this.task = task; }
From source file:org.graylog.plugins.map.search.MapDataSearch.java
public MapDataSearchResult searchMapData(final MapDataSearchRequest request) throws ValueTypeException { final ImmutableMap.Builder<String, TermsResult> termResults = ImmutableMap.<String, TermsResult>builder(); String filter = null;/*w ww. ja v a 2s .c om*/ if (!isNullOrEmpty(request.streamId())) { filter = "streams:" + request.streamId(); } for (final String field : request.fields()) { final org.graylog2.indexer.results.TermsResult terms = searches.terms(field, request.limit(), request.query(), filter, request.timerange()); // TODO: Validate data! final Map<String, Long> validatedTerms = validateTerms(field, terms.getTerms()); final TermsResult result = TermsResult.create(terms.took().millis(), validatedTerms, terms.getMissing(), terms.getOther(), terms.getTotal(), terms.getBuiltQuery()); termResults.put(field, result); } return MapDataSearchResult.builder().query(request.query()).timerange(request.timerange()) .limit(request.limit()).streamId(request.streamId()).fields(termResults.build()).build(); }
From source file:io.prestosql.connector.system.SystemColumnHandle.java
public static Map<String, ColumnHandle> toSystemColumnHandles(ConnectorId connectorId, ConnectorTableMetadata tableMetadata) { ImmutableMap.Builder<String, ColumnHandle> columnHandles = ImmutableMap.builder(); for (ColumnMetadata columnMetadata : tableMetadata.getColumns()) { columnHandles.put(columnMetadata.getName(), new SystemColumnHandle(connectorId, columnMetadata.getName())); }//from ww w. ja v a 2s .c o m return columnHandles.build(); }
From source file:com.qubole.quark.planner.test.Tpcds.java
@Override public Map<String, Table> getTableMap() { final ImmutableMap.Builder<String, Table> builder = ImmutableMap.builder(); QuarkTable customer_demographics = new QuarkTable(new ImmutableList.Builder<QuarkColumn>() .add(new QuarkColumn("cd_demo_sk", Types.INTEGER)).add(new QuarkColumn("cd_gender", Types.VARCHAR)) .add(new QuarkColumn("cd_marital_status", Types.VARCHAR)) .add(new QuarkColumn("cd_education_status", Types.VARCHAR)) .add(new QuarkColumn("cd_purchase_estimate", Types.INTEGER)) .add(new QuarkColumn("cd_credit_rating", Types.VARCHAR)) .add(new QuarkColumn("cd_dep_count", Types.INTEGER)) .add(new QuarkColumn("cd_dep_employed_count", Types.INTEGER)) .add(new QuarkColumn("cd_dep_college_count", Types.INTEGER)).build()); builder.put("CUSTOMER_DEMOGRAPHICS", customer_demographics); QuarkTable date_dim = new QuarkTable(new ImmutableList.Builder<QuarkColumn>() .add(new QuarkColumn("d_date_sk", Types.INTEGER)).add(new QuarkColumn("d_date_id", Types.VARCHAR)) .add(new QuarkColumn("d_date", Types.DATE)).add(new QuarkColumn("d_month_seq", Types.INTEGER)) .add(new QuarkColumn("d_week_seq", Types.INTEGER)) .add(new QuarkColumn("d_quarter_seq", Types.INTEGER)).add(new QuarkColumn("d_year", Types.INTEGER)) .add(new QuarkColumn("d_dow", Types.INTEGER)).add(new QuarkColumn("d_moy", Types.INTEGER)) .add(new QuarkColumn("d_dom", Types.INTEGER)).add(new QuarkColumn("d_qoy", Types.INTEGER)) .add(new QuarkColumn("d_fy_year", Types.INTEGER)) .add(new QuarkColumn("d_fy_quarter_seq", Types.INTEGER)) .add(new QuarkColumn("d_fy_week_seq", Types.INTEGER)) .add(new QuarkColumn("d_day_name", Types.VARCHAR)) .add(new QuarkColumn("d_quarter_name", Types.VARCHAR)) .add(new QuarkColumn("d_holiday", Types.VARCHAR)).add(new QuarkColumn("d_weekend", Types.VARCHAR)) .add(new QuarkColumn("d_following_holiday", Types.VARCHAR)) .add(new QuarkColumn("d_first_dom", Types.INTEGER)) .add(new QuarkColumn("d_last_dom", Types.INTEGER)) .add(new QuarkColumn("d_same_day_ly", Types.INTEGER)) .add(new QuarkColumn("d_same_day_lq", Types.INTEGER)) .add(new QuarkColumn("d_current_day", Types.VARCHAR)) .add(new QuarkColumn("d_current_week", Types.VARCHAR)) .add(new QuarkColumn("d_current_month", Types.VARCHAR)) .add(new QuarkColumn("d_current_quarter", Types.VARCHAR)) .add(new QuarkColumn("d_current_year", Types.VARCHAR)).build()); builder.put("DATE_DIM", date_dim); QuarkTable time_dim = new QuarkTable(new ImmutableList.Builder<QuarkColumn>() .add(new QuarkColumn("t_time_sk", Types.INTEGER)).add(new QuarkColumn("t_time_id", Types.VARCHAR)) .add(new QuarkColumn("t_time", Types.INTEGER)).add(new QuarkColumn("t_hour", Types.INTEGER)) .add(new QuarkColumn("t_minute", Types.INTEGER)).add(new QuarkColumn("t_second", Types.INTEGER)) .add(new QuarkColumn("t_am_pm", Types.VARCHAR)).add(new QuarkColumn("t_shift", Types.VARCHAR)) .add(new QuarkColumn("t_sub_shift", Types.VARCHAR)) .add(new QuarkColumn("t_meal_time", Types.VARCHAR)).build()); builder.put("TIME_DIM", time_dim); QuarkTable item = new QuarkTable(new ImmutableList.Builder<QuarkColumn>() .add(new QuarkColumn("i_item_sk", Types.INTEGER)).add(new QuarkColumn("i_item_id", Types.VARCHAR)) .add(new QuarkColumn("i_rec_start_date", Types.DATE)) .add(new QuarkColumn("i_rec_end_date", Types.DATE)) .add(new QuarkColumn("i_item_desc", Types.VARCHAR)) .add(new QuarkColumn("i_current_price", Types.DOUBLE)) .add(new QuarkColumn("i_wholesale_cost", Types.DOUBLE)) .add(new QuarkColumn("i_brand_id", Types.INTEGER)).add(new QuarkColumn("i_brand", Types.VARCHAR)) .add(new QuarkColumn("i_class_id", Types.INTEGER)).add(new QuarkColumn("i_class", Types.VARCHAR)) .add(new QuarkColumn("i_category_id", Types.INTEGER)) .add(new QuarkColumn("i_category", Types.VARCHAR)) .add(new QuarkColumn("i_manufact_id", Types.INTEGER)) .add(new QuarkColumn("i_manufact", Types.VARCHAR)).add(new QuarkColumn("i_size", Types.VARCHAR)) .add(new QuarkColumn("i_formulation", Types.VARCHAR)).add(new QuarkColumn("i_color", Types.VARCHAR)) .add(new QuarkColumn("i_units", Types.VARCHAR)).add(new QuarkColumn("i_container", Types.VARCHAR)) .add(new QuarkColumn("i_manager_id", Types.INTEGER)) .add(new QuarkColumn("i_product_name", Types.VARCHAR)).build()); builder.put("ITEM", item); QuarkTable customer = new QuarkTable( new ImmutableList.Builder<QuarkColumn>().add(new QuarkColumn("c_customer_sk", Types.INTEGER)) .add(new QuarkColumn("c_customer_id", Types.VARCHAR)) .add(new QuarkColumn("c_current_cdemo_sk", Types.INTEGER)) .add(new QuarkColumn("c_current_hdemo_sk", Types.INTEGER)) .add(new QuarkColumn("c_current_addr_sk", Types.INTEGER)) .add(new QuarkColumn("c_first_shipto_date_sk", Types.INTEGER)) .add(new QuarkColumn("c_first_sales_date_sk", Types.INTEGER)) .add(new QuarkColumn("c_salutation", Types.VARCHAR)) .add(new QuarkColumn("c_first_name", Types.VARCHAR)) .add(new QuarkColumn("c_last_name", Types.VARCHAR)) .add(new QuarkColumn("c_preferred_cust_flag", Types.VARCHAR)) .add(new QuarkColumn("c_birth_day", Types.INTEGER)) .add(new QuarkColumn("c_birth_month", Types.INTEGER)) .add(new QuarkColumn("c_birth_year", Types.INTEGER)) .add(new QuarkColumn("c_birth_country", Types.VARCHAR)) .add(new QuarkColumn("c_login", Types.VARCHAR)) .add(new QuarkColumn("c_email_address", Types.VARCHAR)) .add(new QuarkColumn("c_last_review_date", Types.VARCHAR)).build()); builder.put("CUSTOMER", customer); QuarkTable web_returns = new QuarkTable( new ImmutableList.Builder<QuarkColumn>().add(new QuarkColumn("wr_returned_date_sk", Types.INTEGER)) .add(new QuarkColumn("wr_returned_time_sk", Types.INTEGER)) .add(new QuarkColumn("wr_item_sk", Types.INTEGER)) .add(new QuarkColumn("wr_refunded_customer_sk", Types.INTEGER)) .add(new QuarkColumn("wr_refunded_cdemo_sk", Types.INTEGER)) .add(new QuarkColumn("wr_refunded_hdemo_sk", Types.INTEGER)) .add(new QuarkColumn("wr_refunded_addr_sk", Types.INTEGER)) .add(new QuarkColumn("wr_returning_customer_sk", Types.INTEGER)) .add(new QuarkColumn("wr_returning_cdemo_sk", Types.INTEGER)) .add(new QuarkColumn("wr_returning_hdemo_sk", Types.INTEGER)) .add(new QuarkColumn("wr_returning_addr_sk", Types.INTEGER)) .add(new QuarkColumn("wr_web_page_sk", Types.INTEGER)) .add(new QuarkColumn("wr_reason_sk", Types.INTEGER)) .add(new QuarkColumn("wr_order_number", Types.INTEGER)) .add(new QuarkColumn("wr_return_quantity", Types.INTEGER)) .add(new QuarkColumn("wr_return_amt", Types.DOUBLE)) .add(new QuarkColumn("wr_return_tax", Types.DOUBLE)) .add(new QuarkColumn("wr_return_amt_inc_tax", Types.DOUBLE)) .add(new QuarkColumn("wr_fee", Types.DOUBLE)) .add(new QuarkColumn("wr_return_ship_cost", Types.DOUBLE)) .add(new QuarkColumn("wr_refunded_cash", Types.DOUBLE)) .add(new QuarkColumn("wr_reversed_charge", Types.DOUBLE)) .add(new QuarkColumn("wr_account_credit", Types.DOUBLE)) .add(new QuarkColumn("wr_net_loss", Types.DOUBLE)).build()); builder.put("WEB_RETURNS", web_returns); QuarkTable web_returns_cube = new QuarkTable(new ImmutableList.Builder<QuarkColumn>() .add(new QuarkColumn("i_item_id", Types.VARCHAR)).add(new QuarkColumn("d_year", Types.INTEGER)) .add(new QuarkColumn("d_qoy", Types.INTEGER)).add(new QuarkColumn("d_moy", Types.INTEGER)) .add(new QuarkColumn("d_date", Types.INTEGER)).add(new QuarkColumn("cd_gender", Types.VARCHAR)) .add(new QuarkColumn("cd_marital_status", Types.VARCHAR)) .add(new QuarkColumn("cd_education_status", Types.VARCHAR)) .add(new QuarkColumn("grouping_id", Types.VARCHAR)) .add(new QuarkColumn("total_net_loss", Types.DOUBLE)).build()); builder.put("WEB_RETURNS_CUBE", web_returns_cube); QuarkTable store_sales = new QuarkTable( new ImmutableList.Builder<QuarkColumn>().add(new QuarkColumn("ss_sold_date_sk", Types.INTEGER)) .add(new QuarkColumn("ss_sold_time_sk", Types.INTEGER)) .add(new QuarkColumn("ss_item_sk", Types.INTEGER)) .add(new QuarkColumn("ss_customer_sk", Types.INTEGER)) .add(new QuarkColumn("ss_cdemo_sk", Types.INTEGER)) .add(new QuarkColumn("ss_hdemo_sk", Types.INTEGER)) .add(new QuarkColumn("ss_addr_sk", Types.INTEGER)) .add(new QuarkColumn("ss_store_sk", Types.INTEGER)) .add(new QuarkColumn("ss_promo_sk", Types.INTEGER)) .add(new QuarkColumn("ss_ticket_number", Types.INTEGER)) .add(new QuarkColumn("ss_quantity", Types.INTEGER)) .add(new QuarkColumn("ss_wholesale_cost", Types.DOUBLE)) .add(new QuarkColumn("ss_list_price", Types.DOUBLE)) .add(new QuarkColumn("ss_sales_price", Types.DOUBLE)) .add(new QuarkColumn("ss_ext_discount_amt", Types.DOUBLE)) .add(new QuarkColumn("ss_ext_sales_price", Types.DOUBLE)) .add(new QuarkColumn("ss_ext_wholesale_cost", Types.DOUBLE)) .add(new QuarkColumn("ss_ext_list_price", Types.DOUBLE)) .add(new QuarkColumn("ss_ext_tax", Types.DOUBLE)) .add(new QuarkColumn("ss_coupon_amt", Types.DOUBLE)) .add(new QuarkColumn("ss_net_paid", Types.DOUBLE)) .add(new QuarkColumn("ss_net_paid_inc_tax", Types.DOUBLE)) .add(new QuarkColumn("ss_net_profit", Types.DOUBLE)).build()); builder.put("STORE_SALES", store_sales); QuarkTable store_sales_cube = new QuarkTable(new ImmutableList.Builder<QuarkColumn>() .add(new QuarkColumn("i_item_id", Types.VARCHAR)) .add(new QuarkColumn("c_customer_id", Types.VARCHAR)).add(new QuarkColumn("d_year", Types.INTEGER)) .add(new QuarkColumn("d_qoy", Types.INTEGER)).add(new QuarkColumn("d_moy", Types.INTEGER)) .add(new QuarkColumn("d_date", Types.INTEGER)).add(new QuarkColumn("cd_gender", Types.VARCHAR)) .add(new QuarkColumn("cd_marital_status", Types.VARCHAR)) .add(new QuarkColumn("cd_education_status", Types.VARCHAR)) .add(new QuarkColumn("grouping_id", Types.VARCHAR)) .add(new QuarkColumn("sum_sales_price", Types.DOUBLE)) .add(new QuarkColumn("sum_extended_sales_price", Types.DOUBLE)).build()); builder.put("STORE_SALES_CUBE", store_sales_cube); QuarkTable store_sales_cube_partial = new QuarkTable(new ImmutableList.Builder<QuarkColumn>() .add(new QuarkColumn("i_item_id", Types.VARCHAR)) .add(new QuarkColumn("c_customer_id", Types.VARCHAR)).add(new QuarkColumn("d_year", Types.INTEGER)) .add(new QuarkColumn("d_moy", Types.INTEGER)).add(new QuarkColumn("d_dom", Types.INTEGER)) .add(new QuarkColumn("cd_gender", Types.VARCHAR)) .add(new QuarkColumn("cd_marital_status", Types.VARCHAR)) .add(new QuarkColumn("cd_education_status", Types.VARCHAR)) .add(new QuarkColumn("grouping_id", Types.VARCHAR)) .add(new QuarkColumn("sum_sales_price", Types.DOUBLE)) .add(new QuarkColumn("sum_extended_sales_price", Types.DOUBLE)).build()); builder.put("STORE_SALES_CUBE_PARTIAL", store_sales_cube_partial); QuarkTable store_sales_cube_daily = new QuarkTable(new ImmutableList.Builder<QuarkColumn>() .add(new QuarkColumn("d_year", Types.INTEGER)).add(new QuarkColumn("d_moy", Types.INTEGER)) .add(new QuarkColumn("d_dom", Types.INTEGER)).add(new QuarkColumn("cd_gender", Types.VARCHAR)) .add(new QuarkColumn("grouping_id", Types.VARCHAR)) .add(new QuarkColumn("sum_sales_price", Types.DOUBLE)) .add(new QuarkColumn("sum_extended_sales_price", Types.DOUBLE)).build()); builder.put("STORE_SALES_CUBE_DAILY", store_sales_cube_daily); QuarkTable store_sales_cube_weekly = new QuarkTable(new ImmutableList.Builder<QuarkColumn>() .add(new QuarkColumn("d_year", Types.INTEGER)).add(new QuarkColumn("d_moy", Types.INTEGER)) .add(new QuarkColumn("d_week_seq", Types.INTEGER)).add(new QuarkColumn("cd_gender", Types.VARCHAR)) .add(new QuarkColumn("grouping_id", Types.VARCHAR)) .add(new QuarkColumn("sum_sales_price", Types.DOUBLE)) .add(new QuarkColumn("sum_extended_sales_price", Types.DOUBLE)).build()); builder.put("STORE_SALES_CUBE_WEEKLY", store_sales_cube_weekly); QuarkTable store_sales_cube_monthly = new QuarkTable(new ImmutableList.Builder<QuarkColumn>() .add(new QuarkColumn("d_year", Types.INTEGER)).add(new QuarkColumn("d_moy", Types.INTEGER)) .add(new QuarkColumn("cd_gender", Types.VARCHAR)).add(new QuarkColumn("grouping_id", Types.VARCHAR)) .add(new QuarkColumn("sum_sales_price", Types.DOUBLE)) .add(new QuarkColumn("sum_extended_sales_price", Types.DOUBLE)).build()); builder.put("STORE_SALES_CUBE_MONTHLY", store_sales_cube_monthly); return builder.build(); }
From source file:com.google.devtools.build.lib.skylarkbuildapi.java.JavaBootstrap.java
@Override public void addBindingsToBuilder(ImmutableMap.Builder<String, Object> builder) { builder.put("java_common", javaCommonApi); builder.put("JavaInfo", javaInfoProviderApi); builder.put("java_proto_common", javaProtoCommonApi); }
From source file:org.apache.hadoop.hive.ql.optimizer.calcite.druid.DruidSchema.java
@Override protected Map<String, Table> getTableMap() { final ImmutableMap.Builder<String, Table> builder = ImmutableMap.builder(); return builder.build(); }
From source file:org.sonar.server.setting.DatabaseSettingLoader.java
@Override public void loadAll(ImmutableMap.Builder<String, String> appendTo) { try (DbSession dbSession = dbClient.openSession(false)) { dbClient.propertiesDao().selectGlobalProperties(dbSession) .forEach(p -> appendTo.put(p.getKey(), defaultString(p.getValue()))); }/*from ww w . jav a2 s . co m*/ }
From source file:edu.bsu.issgame.core.sequence.SequenceMatchScreen.java
private static final ImmutableMap<SequenceItemType, SequenceButton> makeMap(SequenceItemType... types) { ImmutableMap.Builder<SequenceItemType, SequenceButton> builder = ImmutableMap.builder(); for (SequenceItemType type : types) { SequenceButton button = new SequenceButton(type); builder.put(type, button);//from ww w .java2s . c o m } return builder.build(); }
From source file:io.atlassian.fugue.extras.ImmutableMaps.java
/** * Builds an immutable map from the given iterable of * {@link java.util.Map.Entry}.// w ww . ja v a2s .co m * <p> * Any <code>null</code> entries will be filtered out. Additionally, any * entries containing <code>null</code> key or value will also be filtered * out. If multiple entries return the same key, * {@link java.lang.IllegalArgumentException} will be thrown. * * @param <K> the key type * @param <V> the value type * @param from the iterable we use as the source * @return the transformed map */ public static <K, V> ImmutableMap<K, V> toMap(Iterable<Map.Entry<K, V>> from) { ImmutableMap.Builder<K, V> mapBuilder = ImmutableMap.builder(); for (Map.Entry<K, V> entry : from) { if (entry != null) { K key = entry.getKey(); V value = entry.getValue(); if (key != null && value != null) { mapBuilder.put(key, value); } } } return mapBuilder.build(); }