List of usage examples for com.google.common.collect ImmutableMap builder
public static <K, V> Builder<K, V> builder()
From source file:com.proofpoint.event.client.JsonEventSerializer.java
@Inject public JsonEventSerializer(NodeInfo nodeInfo, Set<EventTypeMetadata<?>> eventTypes) { this.nodeinfo = checkNotNull(nodeInfo, "nodeInfo is null"); checkNotNull(eventTypes, "eventTypes is null"); ImmutableMap.Builder<Class<?>, EventTypeMetadata<?>> map = ImmutableMap.builder(); for (EventTypeMetadata<?> eventType : eventTypes) { map.put(eventType.getEventClass(), eventType); }// w ww. ja v a 2 s . co m this.metadataMap = map.build(); }
From source file:com.google.firebase.messaging.Aps.java
private Aps(Builder builder) { checkArgument(Strings.isNullOrEmpty(builder.alertString) || (builder.alert == null), "Multiple alert specifications (string and ApsAlert) found."); ImmutableMap.Builder<String, Object> fields = ImmutableMap.builder(); if (builder.alert != null) { fields.put("alert", builder.alert); } else if (builder.alertString != null) { fields.put("alert", builder.alertString); }/*from ww w . ja va2 s .c om*/ if (builder.badge != null) { fields.put("badge", builder.badge); } if (builder.sound != null) { fields.put("sound", builder.sound); } if (builder.contentAvailable) { fields.put("content-available", 1); } if (builder.mutableContent) { fields.put("mutable-content", 1); } if (builder.category != null) { fields.put("category", builder.category); } if (builder.threadId != null) { fields.put("thread-id", builder.threadId); } fields.putAll(builder.customData); this.fields = fields.build(); }
From source file:org.apache.beam.runners.dataflow.worker.ReaderRegistry.java
/** * A {@link ReaderRegistry} with each {@link ReaderFactory} known to the Dataflow worker already * registered./*from ww w . ja va2 s.co m*/ * * <p>Uses {@link ServiceLoader} to dynamically bind well known types to reader factories via a * {@link ReaderFactory.Registrar}. */ public static ReaderRegistry defaultRegistry() { Set<ReaderFactory.Registrar> readerFactoryRegistrars = Sets .newTreeSet(ReflectHelpers.ObjectsClassComparator.INSTANCE); readerFactoryRegistrars.addAll(Lists .newArrayList(ServiceLoader.load(ReaderFactory.Registrar.class, ReflectHelpers.findClassLoader()))); ImmutableMap.Builder<String, ReaderFactory> factories = ImmutableMap.builder(); for (ReaderFactory.Registrar registrar : readerFactoryRegistrars) { factories.putAll(registrar.factories()); } return new ReaderRegistry(factories.build()); }
From source file:org.apereo.portal.events.tincan.converters.GeneralEventConverter.java
@Override protected LrsObject getLrsObject(PortalEvent event) { Builder<String, LocalizedString> definitionBuilder = ImmutableMap.builder(); return new LrsObject(buildUrn("other", event.getClass().getName()), getDefaultObjectType(), definitionBuilder.build());/*ww w. j a v a 2s. co m*/ }
From source file:com.intuit.data.autumn.manage.MBeanRegistry.java
/** * MBean instance registration service.//from w w w . ja v a2 s. c om * * @param o mbean instance * @param name mbean name */ public void register(final Object o, final String name) { String packageName = o.getClass().getPackage().getName(); ImmutableMap<String, String> attributes = new ImmutableMap.Builder<String, String>().put("name", name) .put("type", o.getClass().getSimpleName()).build(); try { ObjectName objectName = new ObjectName(packageName, new Hashtable<>(attributes)); server.registerMBean(o, objectName); } catch (MalformedObjectNameException e) { LOGGER.warn(format("invalid object name: %s, cause: %s", name, e.getMessage()), e); } catch (NotCompliantMBeanException e) { LOGGER.warn(format("non-compliant mxbean: %s, cause: %s", name, e.getMessage()), e); } catch (InstanceAlreadyExistsException e) { LOGGER.warn(format("mxbean already exists by name: %s, cause: %s", name, e.getMessage()), e); } catch (MBeanRegistrationException e) { LOGGER.warn(format("unable to register mxbean name: %s, cause: %s", name, e.getMessage()), e); } }
From source file:org.jclouds.functions.JoinOnK2.java
@Override public Map<K2, Supplier<V>> apply(Map<K, Supplier<Set<K2>>> regionToZones) { Map<K2, Supplier<V>> regionToEndpoint = regionToEndpointSupplier.get(); Builder<K2, Supplier<V>> builder = ImmutableMap.builder(); for (Entry<K, Supplier<Set<K2>>> entry : regionToZones.entrySet()) { for (K2 zone : entry.getValue().get()) { builder.put(zone, regionToEndpoint.get(entry.getKey())); }//from w w w . j a va2 s. c o m } return builder.build(); }
From source file:io.swagger.codegen.options.SwiftOptionsProvider.java
@Override public Map<String, String> createOptions() { ImmutableMap.Builder<String, String> builder = new ImmutableMap.Builder<String, String>(); return builder.put(CodegenConstants.SORT_PARAMS_BY_REQUIRED_FLAG, SORT_PARAMS_VALUE) .put(CodegenConstants.ENSURE_UNIQUE_PARAMS, ENSURE_UNIQUE_PARAMS_VALUE) .put(SwiftCodegen.PROJECT_NAME, PROJECT_NAME_VALUE).put(SwiftCodegen.RESPONSE_AS, RESPONSE_AS_VALUE) .put(SwiftCodegen.UNWRAP_REQUIRED, UNWRAP_REQUIRED_VALUE) .put(SwiftCodegen.POD_SOURCE, POD_SOURCE_VALUE).put(CodegenConstants.POD_VERSION, POD_VERSION_VALUE) .put(SwiftCodegen.POD_AUTHORS, POD_AUTHORS_VALUE) .put(SwiftCodegen.POD_SOCIAL_MEDIA_URL, POD_SOCIAL_MEDIA_URL_VALUE) .put(SwiftCodegen.POD_DOCSET_URL, POD_DOCSET_URL_VALUE) .put(SwiftCodegen.POD_LICENSE, POD_LICENSE_VALUE).put(SwiftCodegen.POD_HOMEPAGE, POD_HOMEPAGE_VALUE) .put(SwiftCodegen.POD_SUMMARY, POD_SUMMARY_VALUE) .put(SwiftCodegen.POD_DESCRIPTION, POD_DESCRIPTION_VALUE) .put(SwiftCodegen.POD_SCREENSHOTS, POD_SCREENSHOTS_VALUE) .put(SwiftCodegen.POD_DOCUMENTATION_URL, POD_DOCUMENTATION_URL_VALUE).build(); }
From source file:io.datty.unit.UnitRecord.java
public UnitRecord(UnitRecord previous, String minorKey, UnitValue value, UpdatePolicy updatePolicy) { ImmutableMap.Builder<String, UnitValue> builder = ImmutableMap.builder(); for (Map.Entry<String, UnitValue> e : previous.columnMap.entrySet()) { if (e.getKey().equals(minorKey)) { if (value != null) { builder.put(minorKey, value); } else { builder.put(e);/* www . j av a2 s . c o m*/ } } } this.columnMap = builder.build(); this.version = 1L; }
From source file:org.apache.atlas.repository.memory.StructStore.java
StructStore(AttributeInfo aInfo) throws RepositoryException { super(aInfo); this.structType = (StructType) aInfo.dataType(); ImmutableMap.Builder<AttributeInfo, IAttributeStore> b = new ImmutableBiMap.Builder<>(); Collection<AttributeInfo> l = structType.fieldMapping.fields.values(); for (AttributeInfo i : l) { b.put(i, AttributeStores.createStore(i)); }//from w w w .ja v a2s. co m attrStores = b.build(); }