com.google.common.collect.Maps Java Examples
The following examples show how to use
com.google.common.collect.Maps.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source Project: envelope Author: cloudera-labs File: DataStep.java License: Apache License 2.0 | 6 votes |
private void notifyDataStepDataGenerated() { if (EventManager.isHandled(CoreEventTypes.DATA_STEP_DATA_GENERATED)) { long startTime = System.nanoTime(); if (!isCached()) { cache(); } long count = data.count(); long timeTakenNs = System.nanoTime() - startTime; String prettyTimeTaken = EventUtils.prettifyNs(timeTakenNs); Map<String, Object> metadata = Maps.newHashMap(); metadata.put(CoreEventMetadataKeys.DATA_STEP_DATA_GENERATED_STEP_NAME, getName()); metadata.put(CoreEventMetadataKeys.DATA_STEP_DATA_GENERATED_ROW_COUNT, count); metadata.put(CoreEventMetadataKeys.DATA_STEP_DATA_GENERATED_TIME_TAKEN_NS, timeTakenNs); String message = "Data step " + getName() + " generated " + count + " rows in " + prettyTimeTaken; EventManager.notify(new Event(CoreEventTypes.DATA_STEP_DATA_GENERATED, message, metadata)); } }
Example #2
Source Project: cloudbreak Author: hortonworks File: InstanceMetadataUpdaterTest.java License: Apache License 2.0 | 6 votes |
@Before public void setUp() throws CloudbreakException, JsonProcessingException, CloudbreakOrchestratorFailedException { MockitoAnnotations.initMocks(this); when(gatewayConfigService.getGatewayConfig(any(Stack.class), any(InstanceMetaData.class), anyBoolean())).thenReturn(gatewayConfig); InstanceMetadataUpdater.Package packageByName = new InstanceMetadataUpdater.Package(); packageByName.setName("packageByName"); packageByName.setPkg(Lists.newArrayList(generatePackageName("packageByName", "(.*)-(.*)"))); InstanceMetadataUpdater.Package packageByCmd = new InstanceMetadataUpdater.Package(); packageByCmd.setName("packageByCmd"); packageByCmd.setPkg(Lists.newArrayList(generatePackageName("packageByCmd", null))); underTest.setPackages(Lists.newArrayList(packageByCmd, packageByName)); Map<String, Map<String, String>> hostPackageMap = Maps.newHashMap(); hostPackageMap.put("instanceId", packageMap()); hostPackageMap.put("hostByCmd", packageMap()); when(hostOrchestrator.getPackageVersionsFromAllHosts(any(GatewayConfig.class), any())).thenReturn(hostPackageMap); }
Example #3
Source Project: shardingsphere Author: apache File: YamlOrchestrationMasterSlaveIntegrateTest.java License: Apache License 2.0 | 6 votes |
@Test public void assertWithDataSource() throws Exception { File yamlFile = new File(YamlOrchestrationMasterSlaveIntegrateTest.class.getResource(filePath).toURI()); DataSource dataSource; if (hasDataSource) { dataSource = YamlOrchestrationShardingSphereDataSourceFactory.createDataSource(yamlFile); } else { dataSource = YamlOrchestrationShardingSphereDataSourceFactory.createDataSource( Maps.asMap(Sets.newHashSet("db_master", "db_slave_0", "db_slave_1"), AbstractYamlDataSourceTest::createDataSource), yamlFile); } try (Connection connection = dataSource.getConnection(); Statement statement = connection.createStatement()) { statement.executeQuery("SELECT * FROM t_order"); statement.executeQuery("SELECT * FROM t_order_item"); statement.executeQuery("SELECT * FROM t_config"); } ((OrchestrationShardingSphereDataSource) dataSource).close(); }
Example #4
Source Project: livingdoc-confluence Author: testIT-LivingDoc File: MacroParametersUtilsTest.java License: GNU General Public License v3.0 | 6 votes |
@Test public void testMultipleValuesCanBeSeparatedByComaTo() { Map<String, String> parameters = Maps.newHashMap(); String paramName = "zeParam"; String paramValue1 = "un"; String paramValue2 = "deux"; String paramValue3 = "trois"; parameters.put(paramName, paramValue1 + "," + paramValue2 + "," + paramValue3); String[] values = MacroParametersUtils.extractParameterMultiple(paramName, parameters); assertEquals(3, values.length); assertEquals(paramValue1, values[0]); assertEquals(paramValue2, values[1]); assertEquals(paramValue3, values[2]); }
Example #5
Source Project: hmftools Author: hartwigmedical File: FormStatusReader.java License: GNU General Public License v3.0 | 6 votes |
@NotNull public static FormStatusModel buildModelFromCsv(@NotNull final String pathToCsv) throws IOException { Map<FormStatusKey, FormStatus> formStatuses = Maps.newHashMap(); List<String> lines = FileReader.build().readLines(new File(pathToCsv).toPath()); // No need to read the header line lines.remove(0); for (String line : lines) { String[] parts = splitCsvLine(line, FIELD_SEPARATOR, FIELD_COUNT); if (parts.length == FIELD_COUNT) { FormStatusKey formKey = new ImmutableFormStatusKey(removeQuotes(parts[PATIENT_ID_COLUMN].replaceAll("-", "")), removeParentheses(removeQuotes(parts[FORM_NAME_COLUMN])), removeQuotes(parts[FORM_SEQ_NUM_COLUMN]), removeParentheses(removeQuotes(parts[STUDY_EVENT_NAME_COLUMN])), removeQuotes(parts[STUDY_EVENT_SEQ_NUM_COLUMN])); FormStatus formStatus = new ImmutableFormStatus(interpretState(removeQuotes(parts[DATA_STATUS_COLUMN])), interpretLocked(removeQuotes(parts[LOCKED_COLUMN]))); formStatuses.put(formKey, formStatus); } else if (parts.length > 0) { LOGGER.warn("Could not properly parse line in form status csv: {}", line); } } return new ImmutableFormStatusModel(formStatuses); }
Example #6
Source Project: api-mining Author: mast-group File: CppWhitespaceTokenizer.java License: GNU General Public License v3.0 | 6 votes |
@Override public SortedMap<Integer, String> tokenListWithPos(final char[] code) { final SortedMap<Integer, String> tokens = Maps.newTreeMap(); tokens.put(-1, SENTENCE_START); tokens.put(Integer.MAX_VALUE, SENTENCE_END); final Scanner scanner = new Scanner(); scanner.setSource(code); final WhitespaceToTokenConverter wsConverter = new WhitespaceToTokenConverter(); do { final int token = scanner.getNextToken(); if (token == Token.tWHITESPACE) { final String wsToken = wsConverter .toWhiteSpaceSymbol(new String(scanner .getCurrentTokenSource())); tokens.put(scanner.getCurrentPosition(), wsToken); } else { final String nxtToken = new String( scanner.getCurrentTokenSource()); tokens.put(scanner.getCurrentPosition(), getTokenType(token, nxtToken)); } } while (!scanner.atEnd()); return tokens; }
Example #7
Source Project: kylin-on-parquet-v2 Author: Kyligence File: ExecutableManager.java License: Apache License 2.0 | 6 votes |
public void resumeJob(String jobId) { AbstractExecutable job = getJob(jobId); if (job == null) { return; } Map<String, String> info = null; if (job instanceof DefaultChainedExecutable) { List<AbstractExecutable> tasks = ((DefaultChainedExecutable) job).getTasks(); for (AbstractExecutable task : tasks) { if (task.getStatus() == ExecutableState.ERROR || task.getStatus() == ExecutableState.STOPPED) { updateJobOutput(task.getId(), ExecutableState.READY, null, "no output"); break; } } final long endTime = job.getEndTime(); if (endTime != 0) { long interruptTime = System.currentTimeMillis() - endTime + job.getInterruptTime(); info = Maps.newHashMap(getJobOutput(jobId).getInfo()); info.put(AbstractExecutable.INTERRUPT_TIME, Long.toString(interruptTime)); info.remove(AbstractExecutable.END_TIME); } } updateJobOutput(jobId, ExecutableState.READY, info, null); }
Example #8
Source Project: phoenix Author: apache File: SpillableGroupByIT.java License: Apache License 2.0 | 6 votes |
@BeforeClass public static synchronized void doSetup() throws Exception { Map<String, String> props = Maps.newHashMapWithExpectedSize(11); // Set a very small cache size to force plenty of spilling props.put(QueryServices.GROUPBY_MAX_CACHE_SIZE_ATTRIB, Integer.toString(1)); props.put(QueryServices.GROUPBY_SPILLABLE_ATTRIB, String.valueOf(true)); props.put(QueryServices.GROUPBY_SPILL_FILES_ATTRIB, Integer.toString(1)); // Large enough to not run out of memory, but small enough to spill props.put(QueryServices.MAX_MEMORY_SIZE_ATTRIB, Integer.toString(40000)); // Set guidepost width, but disable stats props.put(QueryServices.STATS_GUIDEPOST_WIDTH_BYTES_ATTRIB, Long.toString(20)); props.put(QueryServices.STATS_COLLECTION_ENABLED, Boolean.toString(false)); props.put(QueryServices.EXPLAIN_CHUNK_COUNT_ATTRIB, Boolean.TRUE.toString()); props.put(QueryServices.EXPLAIN_ROW_COUNT_ATTRIB, Boolean.TRUE.toString()); // Must update config before starting server setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator())); }
Example #9
Source Project: Shop-for-JavaWeb Author: EleTeam File: ShopAreaController.java License: MIT License | 6 votes |
/** * List by parentId, return json format string * * @throws IOException */ @RequestMapping("/ajax-list/{parentId}") public void ajaxList(@PathVariable String parentId, HttpServletResponse response) throws IOException { List<Area> areaList = areaService.findByParentId(parentId); // @todo List<Map<String, Object>> list = Lists.newArrayList(); for (Area area : areaList) { Map<String, Object> map = Maps.newHashMap(); map.put("id", area.getId()); map.put("parentId", area.getParentId()); map.put("name", area.getName()); list.add(map); } boolean res = true; String msg = "区域列表"; JsonUtils.setResponse(response); response.getWriter().print(JsonUtils.toString(res, msg, list)); }
Example #10
Source Project: javaide Author: tranleduy2000 File: DependencyManager.java License: GNU General Public License v3.0 | 6 votes |
private static List<LibraryDependencyImpl> convertLibraryInfoIntoDependency( @NonNull List<LibInfo> libInfos, @NonNull Multimap<LibraryDependency, VariantDependencies> reverseMap) { List<LibraryDependencyImpl> list = Lists.newArrayListWithCapacity(libInfos.size()); // since the LibInfos is a graph and the previous "foundLibraries" map ensure we reuse // instance where applicable, we'll create a map to keep track of what we have already // converted. Map<LibInfo, LibraryDependencyImpl> convertedMap = Maps.newIdentityHashMap(); for (LibInfo libInfo : libInfos) { list.add(convertLibInfo(libInfo, reverseMap, convertedMap)); } return list; }
Example #11
Source Project: caja Author: google File: EnvironmentChecksTest.java License: Apache License 2.0 | 6 votes |
public final void testEnvironmentData() throws Exception { Scriptable s = (Scriptable) RhinoTestBed.runJs( new RhinoExecutor.Input( // TODO: make an ASCII-art Rhino. "var navigator = { userAgent: 'Rhino Rhino Rhino' };", "rhino-env"), new RhinoExecutor.Input(getClass(), "environment-checks.js"), new RhinoExecutor.Input("env", getName()) ); Map<String, Object> env = Maps.newHashMap(); for (Object key : ScriptableObject.getPropertyIds(s)) { String code = "" + key; env.put(EnvironmentData.normJs(code, mq), s.get(code, s)); } for (EnvironmentDatum datum : EnvironmentDatum.values()) { assertTrue(datum.name(), env.containsKey(datum.getCode())); System.err.println(datum + " = " + env.get(datum.getCode())); } assertEquals( "Rhino Rhino Rhino", env.get(EnvironmentDatum.NAV_USER_AGENT.getCode())); }
Example #12
Source Project: bazel Author: bazelbuild File: DelegatingWalkableGraph.java License: Apache License 2.0 | 6 votes |
@Override public Map<SkyKey, Pair<SkyValue, Iterable<SkyKey>>> getValueAndRdeps(Iterable<SkyKey> keys) throws InterruptedException { Map<SkyKey, ? extends NodeEntry> entries = getBatch(null, Reason.WALKABLE_GRAPH_VALUE_AND_RDEPS, keys); Map<SkyKey, Pair<SkyValue, Iterable<SkyKey>>> result = Maps.newHashMapWithExpectedSize(entries.size()); for (Map.Entry<SkyKey, ? extends NodeEntry> entry : entries.entrySet()) { // See comment in #getReverseDeps. if (entry.getValue().isDone()) { result.put( entry.getKey(), Pair.of( getValueFromNodeEntry(entry.getValue()), entry.getValue().getReverseDepsForDoneEntry())); } } return result; }
Example #13
Source Project: EserKnife Author: ucarGroup File: IndexMsgController.java License: Apache License 2.0 | 6 votes |
@RequestMapping(value = "/getDemoData") @ResponseBody public Object getColInfoByTabname() { Map<String, Object> map = Maps.newHashMap(); List<Map<String,String>> demoDatas = Lists.newArrayList(); Map<String,String> col1 = Maps.newHashMap(); col1.put("demo_type","string"); col1.put("demo_flag","1"); col1.put("demo_remark","stirng 类型"); demoDatas.add(col1); Map<String,String> col2 = Maps.newHashMap(); col2.put("demo_type","long"); col2.put("demo_flag","1"); col2.put("demo_remark","long 类型"); demoDatas.add(col2); Map<String,String> col3 = Maps.newHashMap(); col3.put("demo_type","date"); col3.put("demo_flag","1"); col3.put("demo_remark","date 类型"); demoDatas.add(col3); map.put("result", demoDatas); return map; }
Example #14
Source Project: brooklyn-server Author: apache File: SshTasks.java License: Apache License 2.0 | 6 votes |
private static Map<String, Object> getSshFlags(Location location) { Set<ConfigKey<?>> sshConfig = MutableSet.of(); StringConfigMap mgmtConfig = null; sshConfig.addAll(location.config().findKeysPresent(ConfigPredicates.nameStartsWith(SshTool.BROOKLYN_CONFIG_KEY_PREFIX))); if (location instanceof AbstractLocation) { ManagementContext mgmt = ((AbstractLocation)location).getManagementContext(); if (mgmt!=null) { mgmtConfig = mgmt.getConfig(); sshConfig.addAll(mgmtConfig.findKeysPresent(ConfigPredicates.nameStartsWith(SshTool.BROOKLYN_CONFIG_KEY_PREFIX))); } } Map<String, Object> result = Maps.newLinkedHashMap(); for (ConfigKey<?> key : sshConfig) { Maybe<Object> v = ((LocationInternal)location).config().getRaw(key); if (v.isAbsent() && mgmtConfig!=null) v = Maybe.of( (Object) mgmtConfig.getConfig(key) ); result.put(ConfigUtils.unprefixedKey(SshTool.BROOKLYN_CONFIG_KEY_PREFIX, key).getName(), v.get()); } return result; }
Example #15
Source Project: shimmer Author: openmhealth File: JawboneHeartRateDataPointMapperUnitTests.java License: Apache License 2.0 | 6 votes |
@Test public void asDataPointsShouldReturnCorrectDataPoints() { List<DataPoint<HeartRate>> dataPoints = mapper.asDataPoints(singletonList(responseNode)); HeartRate expectedHeartRate = new HeartRate.Builder(55) .setTemporalRelationshipToPhysicalActivity(AT_REST) .setEffectiveTimeFrame(OffsetDateTime.parse("2013-11-20T08:05:00-08:00")) .build(); assertThat(dataPoints.get(0).getBody(), equalTo(expectedHeartRate)); // TODO kill maps Map<String, Object> testProperties = Maps.newHashMap(); testProperties.put(HEADER_EXTERNAL_ID_KEY, "40F7_htRRnT8Vo7nRBZO1X"); testProperties.put(HEADER_SOURCE_UPDATE_KEY, "2013-11-21T15:59:59Z"); testProperties.put(HEADER_SCHEMA_ID_KEY, HeartRate.SCHEMA_ID); testProperties.put(HEADER_SENSED_KEY, DataPointModality.SENSED); testDataPointHeader(dataPoints.get(0).getHeader(), testProperties); }
Example #16
Source Project: codemining-core Author: mast-group File: CppWhitespaceTokenizer.java License: BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override public SortedMap<Integer, FullToken> fullTokenListWithPos(final char[] code) { final SortedMap<Integer, FullToken> tokens = Maps.newTreeMap(); tokens.put(-1, new FullToken(SENTENCE_START, SENTENCE_START)); tokens.put(Integer.MAX_VALUE, new FullToken(SENTENCE_END, SENTENCE_END)); final Scanner scanner = new Scanner(); scanner.setSource(code); final WhitespaceToTokenConverter wsConverter = new WhitespaceToTokenConverter(); do { final int token = scanner.getNextToken(); if (token == Token.tWHITESPACE) { final String wsToken = wsConverter .toWhiteSpaceSymbol(new String(scanner .getCurrentTokenSource())); tokens.put(scanner.getCurrentPosition(), new FullToken(wsToken, Integer.toString(token))); } else { final String nxtToken = new String( scanner.getCurrentTokenSource()); tokens.put(scanner.getCurrentPosition(), new FullToken( getTokenType(token, nxtToken), Integer.toString(token))); } } while (!scanner.atEnd()); return tokens; }
Example #17
Source Project: StubbornJava Author: StubbornJava File: DeterministicObjectMapperTest.java License: MIT License | 6 votes |
@Test public void testDeterministicNesting() throws JsonProcessingException { @SuppressWarnings("unused") Object obj = new Object() { public String get1() { return "1"; } public String getC() { return "C"; } public String getA() { return "A"; } }; Set<Integer> ints = Sets.newLinkedHashSet(Lists.newArrayList(1, 4, 2, 3, 5, 7, 8, 9, 6, 0, 50, 100, 99)); Map<String, Object> data = Maps.newLinkedHashMap(); data.put("obj", obj); data.put("c", "C"); data.put("ints", ints); String actual = mapper.writer().writeValueAsString(data); String expected = "{" + "\"c\":\"C\"," + "\"ints\":[0,1,2,3,4,5,6,7,8,9,50,99,100]," + "\"obj\":{\"1\":\"1\",\"a\":\"A\",\"c\":\"C\"}" + "}"; assertEquals(expected, actual); }
Example #18
Source Project: pacbot Author: tmobile File: CommonUtils.java License: Apache License 2.0 | 6 votes |
/** * Builds the query. * * @param filter the filter * @return elastic search query details */ static Map<String, Object> buildQuery(final Map<String, String> filter) { Map<String, Object> queryFilters = Maps.newHashMap(); Map<String, Object> boolFilters = Maps.newHashMap(); List<Map<String, Object>> should = Lists.newArrayList(); for (Map.Entry<String, String> entry : filter.entrySet()) { Map<String, Object> term = Maps.newHashMap(); Map<String, Object> termDetails = Maps.newHashMap(); termDetails.put(entry.getKey(), entry.getValue()); term.put("term", termDetails); should.add(term); } boolFilters.put("should", should); queryFilters.put("bool", boolFilters); return queryFilters; }
Example #19
Source Project: mt-flume Author: javachen File: TestFileChannelFormatRegression.java License: Apache License 2.0 | 6 votes |
public void doTestFileFormatV2PreFLUME1432(boolean useLogReplayV1) throws Exception { TestUtils.copyDecompressed("fileformat-v2-pre-FLUME-1432-checkpoint.gz", new File(checkpointDir, "checkpoint")); for (int i = 0; i < dataDirs.length; i++) { int fileIndex = i + 1; TestUtils.copyDecompressed("fileformat-v2-pre-FLUME-1432-log-" + fileIndex + ".gz", new File(dataDirs[i], "log-" + fileIndex)); } Map<String, String> overrides = Maps.newHashMap(); overrides.put(FileChannelConfiguration.CAPACITY, String.valueOf(10000)); overrides.put(FileChannelConfiguration.USE_LOG_REPLAY_V1, String.valueOf(useLogReplayV1)); channel = createFileChannel(overrides); channel.start(); Assert.assertTrue(channel.isOpen()); Set<String> events = takeEvents(channel, 1); Assert.assertEquals(50, events.size()); }
Example #20
Source Project: Shop-for-JavaWeb Author: EleTeam File: AppAboutController.java License: MIT License | 6 votes |
/** * 关于我们 */ @RequestMapping("/us") public String list(HttpServletResponse response) { boolean result; String message; Map<String, Object> data = Maps.newHashMap(); Map<String, Object> us = Maps.newHashMap(); String desc = " 月光茶人为客户提供休闲温馨的环境,以最真诚的态度服务于我们的客户,提供香浓的咖啡、健康的奶茶和美味的小吃。为了让客户享受更便捷的服务和优惠价格,我们开发了月光茶人APP,欢迎使用。"; String copyright = "Copyright © 2015"; String company = "深圳市宝安区福永月光茶人饮品店"; String address = "深圳市宝安区福永东福围东街103-5"; String tel = "联系电话:0755-29350032"; us.put("desc", desc); us.put("copyright", copyright); us.put("company", company); us.put("address", address); us.put("tel", tel); result = true; message = ""; data.put("us", us); return renderString(response, result, message, data); }
Example #21
Source Project: attic-aurora Author: apache File: JobDiff.java License: Apache License 2.0 | 6 votes |
private static JobDiff computeUnscoped( Map<Integer, ITaskConfig> currentState, IJobKey job, Map<Integer, ITaskConfig> proposedState) { requireNonNull(job); requireNonNull(proposedState); MapDifference<Integer, ITaskConfig> diff = Maps.difference(currentState, proposedState); Map<Integer, ITaskConfig> removedInstances = ImmutableMap.<Integer, ITaskConfig>builder() .putAll(diff.entriesOnlyOnLeft()) .putAll(Maps.transformValues(diff.entriesDiffering(), JobDiff.leftValue())) .build(); Set<Integer> addedInstances = ImmutableSet.<Integer>builder() .addAll(diff.entriesOnlyOnRight().keySet()) .addAll(diff.entriesDiffering().keySet()) .build(); return new JobDiff( removedInstances, addedInstances, ImmutableMap.copyOf(diff.entriesInCommon())); }
Example #22
Source Project: occurrence Author: gbif File: CallbackServiceTest.java License: Apache License 2.0 | 5 votes |
@Before public void setup() { downloadEmailUtils = mock(DownloadEmailUtils.class); occurrenceDownloadService = mock(OccurrenceDownloadService.class); downloadLimitsService= mock(DownloadLimitsService.class); when(downloadLimitsService.exceedsSimultaneousDownloadLimit(any(String.class))).thenReturn(null); when(downloadLimitsService.exceedsDownloadComplexity(any(DownloadRequest.class))).thenReturn(null); when(occurrenceDownloadService.get(anyString())).thenReturn(mockDownload()); oozieClient = mock(OozieClient.class); service = new DownloadRequestServiceImpl(oozieClient, Maps.<String, String>newHashMap(), "http://localhost:8080/", "", occurrenceDownloadService, downloadEmailUtils,downloadLimitsService); }
Example #23
Source Project: helios Author: spotify File: VersionResponseFilterTest.java License: Apache License 2.0 | 5 votes |
private HttpURLConnection doVersionRequest(String version) throws IOException { final Map<String, List<String>> headers = Maps.newHashMap(); headers.put("Content-Type", asList("application/json")); headers.put("Charset", asList("utf-8")); if (version != null) { headers.put(HELIOS_VERSION_HEADER, asList(version)); } final URI uri = URI.create(masterEndpoint() + "/version"); final HttpURLConnection connection = connect(uri, headers); return connection; }
Example #24
Source Project: joyqueue Author: chubaostream File: ConsumerClient.java License: Apache License 2.0 | 5 votes |
protected FetchTopicMessageRequest buildFetchTopicMessageCommand(List<String> topics, String app, int count, long ackTimeout, long longPollTimeout) { Map<String, FetchTopicMessageData> topicMap = Maps.newHashMap(); for (String topic : topics) { topicMap.put(topic, new FetchTopicMessageData(count)); } FetchTopicMessageRequest fetchTopicMessageRequest = new FetchTopicMessageRequest(); fetchTopicMessageRequest.setTopics(topicMap); fetchTopicMessageRequest.setApp(app); fetchTopicMessageRequest.setAckTimeout((int) ackTimeout); fetchTopicMessageRequest.setLongPollTimeout((int) longPollTimeout); return fetchTopicMessageRequest; }
Example #25
Source Project: pacbot Author: tmobile File: TargetTypesServiceImpl.java License: Apache License 2.0 | 5 votes |
private Map<String, Integer> buildSelectedTargetTypesIndex(List<AssetGroupTargetTypes> selectedTargetTypes) { Map<String, Integer> selectedTargetTypeIndex = Maps.newHashMap(); for (int index = 0; index < selectedTargetTypes.size(); index++) { selectedTargetTypeIndex.put(selectedTargetTypes.get(index).getTargetType().toLowerCase(), index); } return selectedTargetTypeIndex; }
Example #26
Source Project: albedo Author: somowhere File: Json.java License: GNU Lesser General Public License v3.0 | 5 votes |
public static Map<String, Object> toMap(JSONObject jsonObject) { Map<String, Object> data = Maps.newHashMap(); // 将json字符串转换成jsonObject Iterator<String> it = jsonObject.keySet().iterator(); // 遍历jsonObject数据,添加到Map对象 while (it.hasNext()) { String key = String.valueOf(it.next()); Object value = jsonObject.get(key); data.put(key, value); } return data; }
Example #27
Source Project: we-cmdb Author: WeBankPartners File: BeanMapUtils.java License: Apache License 2.0 | 5 votes |
public static <T> Map<String, Object> convertBeanToMap(T bean) { Map<String, Object> map = Maps.newHashMap(); if (bean != null) { BeanMap beanMap = BeanMap.create(bean); for (Object key : beanMap.keySet()) { if (beanMap.get(key) != null) { map.put(key.toString(), beanMap.get(key)); } } } return map; }
Example #28
Source Project: brooklyn-server Author: apache File: JCloudsPropertiesBuilder.java License: Apache License 2.0 | 5 votes |
public JCloudsPropertiesBuilder setCustomJcloudsProperties() { Map<String, Object> extra = Maps.filterKeys(conf.getAllConfig(), Predicates.containsPattern("^jclouds\\.")); if (extra.size() > 0) { String provider = getProviderFromConfig(conf); LOG.debug("Configuring custom jclouds property overrides for {}: {}", provider, Sanitizer.sanitize(extra)); } properties.putAll(Maps.filterValues(extra, Predicates.notNull())); return this; }
Example #29
Source Project: onos Author: opennetworkinglab File: MetricsDatabaseTest.java License: Apache License 2.0 | 5 votes |
/** * Tests device metrics map update and query. */ @Test public void testDeviceMetricsMap() { ControlResource.Type type = ControlResource.Type.CONTROL_MESSAGE; DeviceId devId1 = DeviceId.deviceId("of:0000000000000101"); DeviceId devId2 = DeviceId.deviceId("of:0000000000000102"); devMetricsMap = Maps.newHashMap(); Set<DeviceId> devices = ImmutableSet.of(devId1, devId2); devices.forEach(dev -> { if (!devMetricsMap.containsKey(dev)) { devMetricsMap.put(dev, genMDbBuilder(type, ControlResource.CONTROL_MESSAGE_METRICS) .withResourceName(dev.toString()) .build()); } }); Map<String, Double> metrics1 = new HashMap<>(); ControlResource.CONTROL_MESSAGE_METRICS.forEach(msgType -> metrics1.putIfAbsent(msgType.toString(), 10D)); Map<String, Double> metrics2 = new HashMap<>(); ControlResource.CONTROL_MESSAGE_METRICS.forEach(msgType -> metrics2.putIfAbsent(msgType.toString(), 20D)); devMetricsMap.get(devId1).updateMetrics(metrics1); devMetricsMap.get(devId2).updateMetrics(metrics2); ControlResource.CONTROL_MESSAGE_METRICS.forEach(msgType -> assertThat(10D, is(devMetricsMap.get(devId1).recentMetric(msgType.toString()))) ); ControlResource.CONTROL_MESSAGE_METRICS.forEach(msgType -> assertThat(20D, is(devMetricsMap.get(devId2).recentMetric(msgType.toString()))) ); }
Example #30
Source Project: yql-plus Author: yahoo File: ProgramParser.java License: Apache License 2.0 | 5 votes |
void defineDataSource(Location loc, String name, boolean hasAliasDefinition) { if (isCursor(name)) { throw new ProgramCompileException(loc, "Alias '%s' is already used.", name); } if (cursors.isEmpty()) { cursors = Maps.newHashMap(); } cursors.put(name, Boolean.valueOf(hasAliasDefinition)); }