List of usage examples for java.util Map putAll
void putAll(Map<? extends K, ? extends V> m);
From source file:com.sixt.service.framework.servicetest.helper.DockerComposeHelper.java
/** * Set environment variable "registryServer" to the host and port specified by * docker//from www .ja v a 2s .c o m */ public static void setConsulEnvironment(DockerComposeRule docker) { DockerPort consul = docker.containers().container("consul").port(8500); Map<String, String> newEnv = new HashMap<>(); newEnv.put(ServiceProperties.REGISTRY_SERVER_KEY, consul.inFormat("$HOST:$EXTERNAL_PORT")); newEnv.putAll(System.getenv()); setEnv(newEnv); }
From source file:Main.java
public static <T, U> Map<T, U> putAllObjects(Map<T, U> targetMap, Map<T, U> sourceMap) { if (targetMap == null && sourceMap == null) { return new HashMap<T, U>(); }/*www . j a va 2s .c om*/ if (targetMap == null) { return new HashMap<T, U>(sourceMap); } if (sourceMap == null) { return targetMap; // nothing to add } targetMap.putAll(sourceMap); return targetMap; }
From source file:Main.java
/** * Recursive method to disable all child components in JComponent * @param component the highest level parent component * @return The original state of all the child components *//*from w w w . j a v a2s . com*/ public static Map<Component, Boolean> disableAllChildComponents(JComponent... components) { Map<Component, Boolean> stateMap = new HashMap<Component, Boolean>(); for (JComponent component : components) { for (Component child : component.getComponents()) { stateMap.put(child, child.isEnabled()); child.setEnabled(false); if (child instanceof JComponent) stateMap.putAll(disableAllChildComponents((JComponent) child)); } } return stateMap; }
From source file:net.erdfelt.android.sdkfido.git.internal.GitInfo.java
private static void infoTags(Repository db) { System.out.printf("%nAll Tags (%d)%n", db.getTags().size()); Map<String, Ref> sorted = new TreeMap<String, Ref>(); sorted.putAll(db.getTags()); int maxRefLength = 0; for (Entry<String, Ref> entry : sorted.entrySet()) { maxRefLength = Math.max(maxRefLength, entry.getValue().getName().length()); }// w w w .java 2 s .c o m for (Entry<String, Ref> entry : db.getTags().entrySet()) { Ref ref = entry.getValue(); System.out.printf("%-" + maxRefLength + "s %s%n", ref.getName(), ref.getObjectId().abbreviate(ABBREV_LEN).name()); } }
From source file:org.grails.plugins.elasticsearch.mapping.ElasticSearchMappingFactory.java
public static Map<String, Object> getElasticMapping(SearchableClassMapping scm) { Map<String, Object> elasticTypeMappingProperties = new LinkedHashMap<String, Object>(); if (!scm.isAll()) { // "_all" : {"enabled" : true} elasticTypeMappingProperties.put("_all", Collections.singletonMap("enabled", false)); }/*www . ja v a2s .c o m*/ // Map each domain properties in supported format, or object for complex type for (SearchableClassPropertyMapping scpm : scm.getPropertiesMapping()) { // Does it have custom mapping? String propType = scpm.getGrailsProperty().getTypePropertyName(); Map<String, Object> propOptions = new LinkedHashMap<String, Object>(); // Add the custom mapping (searchable static property in domain model) propOptions.putAll(scpm.getAttributes()); if (!(SUPPORTED_FORMAT.contains(scpm.getGrailsProperty().getTypePropertyName()))) { // Handle embedded persistent collections, ie List<String> listOfThings if (scpm.getGrailsProperty().isBasicCollectionType()) { String basicType = ClassUtils.getShortName(scpm.getGrailsProperty().getReferencedPropertyType()) .toLowerCase(Locale.ENGLISH); if (SUPPORTED_FORMAT.contains(basicType)) { propType = basicType; } // Handle arrays } else if (scpm.getGrailsProperty().getReferencedPropertyType().isArray()) { String basicType = ClassUtils .getShortName(scpm.getGrailsProperty().getReferencedPropertyType().getComponentType()) .toLowerCase(Locale.ENGLISH); if (SUPPORTED_FORMAT.contains(basicType)) { propType = basicType; } } else if (isDateType(scpm.getGrailsProperty().getReferencedPropertyType())) { propType = "date"; } else if (GrailsClassUtils.isJdk5Enum(scpm.getGrailsProperty().getReferencedPropertyType())) { propType = "string"; } else if (scpm.getConverter() != null) { // Use 'string' type for properties with custom converter. // Arrays are automatically resolved by ElasticSearch, so no worries. propType = "string"; } else { propType = "object"; } if (scpm.getReference() != null) { propType = "object"; // fixme: think about composite ids. } else if (scpm.isComponent()) { // Proceed with nested mapping. // todo limit depth to avoid endless recursion? propType = "object"; //noinspection unchecked propOptions.putAll((Map<String, Object>) (getElasticMapping(scpm.getComponentPropertyMapping()) .values().iterator().next())); } // Once it is an object, we need to add id & class mappings, otherwise // ES will fail with NullPointer. if (scpm.isComponent() || scpm.getReference() != null) { @SuppressWarnings({ "unchecked" }) Map<String, Object> props = (Map<String, Object>) propOptions.get("properties"); if (props == null) { props = new LinkedHashMap<String, Object>(); propOptions.put("properties", props); } props.put("id", defaultDescriptor("long", "not_analyzed", true)); props.put("class", defaultDescriptor("string", "no", true)); props.put("ref", defaultDescriptor("string", "no", true)); } } propOptions.put("type", propType); // See http://www.elasticsearch.com/docs/elasticsearch/mapping/all_field/ if (!propType.equals("object") && scm.isAll()) { // does it make sense to include objects into _all? if (scpm.shouldExcludeFromAll()) { propOptions.put("include_in_all", false); } else { propOptions.put("include_in_all", true); } } // todo only enable this through configuration... if (propType.equals("string") && scpm.isAnalyzed()) { propOptions.put("term_vector", "with_positions_offsets"); } elasticTypeMappingProperties.put(scpm.getPropertyName(), propOptions); } Map<String, Object> mapping = new LinkedHashMap<String, Object>(); mapping.put(scm.getElasticTypeName(), Collections.singletonMap("properties", elasticTypeMappingProperties)); return mapping; }
From source file:io.cloudslang.content.amazon.factory.helpers.FilterUtils.java
@NotNull public static Map<String, String> getFiltersQueryMap(@NotNull final FilterInputs filterInputs, @NotNull final FilterValidator validator) { final Map<String, String> filtersQueryMap = new HashMap<>(); for (final Filter filter : filterInputs.getFilterList()) { final Map<String, String> filterQueryMap = getFilterQueryMap(filter, filterInputs.getFilterList().indexOf(filter), validator); filtersQueryMap.putAll(filterQueryMap); }/*from w ww . j a v a 2s . c om*/ return filtersQueryMap; }
From source file:io.fabric8.maven.core.extenvvar.ExternalEnvVarHandler.java
private static JsonSchema combineSchemas(JsonSchema schema1, JsonSchema schema2) { if (schema1 == null) { return schema2; }// w w w . ja va2 s . c o m if (schema2 != null) { Map<String, JsonSchemaProperty> properties2 = schema2.getProperties(); Map<String, JsonSchemaProperty> properties1 = schema1.getProperties(); if (properties2 != null) { if (properties1 == null) { return schema2; } else { properties1.putAll(properties2); } } } return schema1; }
From source file:com.opengamma.elsql.ElSqlBundle.java
private static ElSqlBundle parse(List<List<String>> files, ElSqlConfig config) { Map<String, NameSqlFragment> parsed = new LinkedHashMap<String, NameSqlFragment>(); for (List<String> lines : files) { ElSqlParser parser = new ElSqlParser(lines); parsed.putAll(parser.parse()); }// ww w . java 2 s . c om return new ElSqlBundle(parsed, config); }
From source file:com.cloudera.kitten.appmaster.params.lua.WorkflowParameters.java
private static Map<String, Object> loadExtras(Map<String, Object> masterExtras) { Map<String, String> e = System.getenv(); if (e.containsKey(LuaFields.KITTEN_EXTRA_LUA_VALUES)) { Map<String, Object> extras = Maps .newHashMap(LocalDataHelper.deserialize(e.get(LuaFields.KITTEN_EXTRA_LUA_VALUES))); extras.putAll(masterExtras); return extras; }//from ww w.ja v a 2s. c o m return masterExtras; }
From source file:Main.java
static Map<String, Component> getComponents(Container container) { Map<String, Component> listComponent = Collections.EMPTY_MAP; if (container.getComponentCount() > 0) { listComponent = new HashMap<>(); for (Component component : container.getComponents()) { if (component.getName() != null) { if (component instanceof JScrollPane) { listComponent.putAll(getComponents(((JScrollPane) component).getViewport())); } else { listComponent.put(component.getName(), component); }/* w ww .j a v a2 s . c om*/ } } } return listComponent; }