当前位置: 首页>>代码示例>>Java>>正文


Java Maps.newHashMap方法代码示例

本文整理汇总了Java中com.beust.jcommander.internal.Maps.newHashMap方法的典型用法代码示例。如果您正苦于以下问题:Java Maps.newHashMap方法的具体用法?Java Maps.newHashMap怎么用?Java Maps.newHashMap使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.beust.jcommander.internal.Maps的用法示例。


在下文中一共展示了Maps.newHashMap方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getQRCodeImge

import com.beust.jcommander.internal.Maps; //导入方法依赖的package包/类
/**
 * 将内容contents生成长为width,宽为width的图片,返回刘文静
 */
public static ServletOutputStream getQRCodeImge(String contents, int width, int height) throws IOException {
    ServletOutputStream stream = null;
    try {
        Map<EncodeHintType, Object> hints = Maps.newHashMap();
        hints.put(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.M);
        hints.put(EncodeHintType.CHARACTER_SET, "UTF8");
        BitMatrix bitMatrix = new MultiFormatWriter().encode(contents, BarcodeFormat.QR_CODE, width, height, hints);
        MatrixToImageWriter.writeToStream(bitMatrix, "png", stream);
        return stream;
    } catch (Exception e) {
        log.error("create QR code error!", e);
        return null;
    } finally {
        if (stream != null) {
            stream.close();
        }
    }
}
 
开发者ID:fanqinghui,项目名称:wish-pay,代码行数:22,代码来源:ZxingUtils.java

示例2: findAbbreviatedValue

import com.beust.jcommander.internal.Maps; //导入方法依赖的package包/类
private static <V> V findAbbreviatedValue(Map<? extends IKey, V> map, IKey name,
    boolean caseSensitive) {
  String string = name.getName();
  Map<String, V> results = Maps.newHashMap();
  for (IKey c : map.keySet()) {
    String n = c.getName();
    boolean match = (caseSensitive && n.startsWith(string))
        || ((! caseSensitive) && n.toLowerCase().startsWith(string.toLowerCase()));
    if (match) {
      results.put(n, map.get(c));
    }
  }

  V result;
  if (results.size() > 1) {
    throw new ParameterException("Ambiguous option: " + name
        + " matches " + results.keySet());
  } else if (results.size() == 1) {
    result = results.values().iterator().next();
  } else {
    result = null;
  }

  return result;
}
 
开发者ID:georghinkel,项目名称:ttc2017smartGrids,代码行数:26,代码来源:FuzzyMap.java

示例3: getAlipayNotify

import com.beust.jcommander.internal.Maps; //导入方法依赖的package包/类
/**
 * 获取阿里支付链接的所有参数列表
 *
 * @param request
 * @return
 */
public static Map<String, String> getAlipayNotify(HttpServletRequest request) {
    Map<String, String> params = Maps.newHashMap();
    Map requestParams = request.getParameterMap();
    for (Iterator<String> iter = requestParams.keySet().iterator(); iter.hasNext(); ) {
        String name = iter.next();
        String[] values = (String[]) requestParams.get(name);
        String valueStr = "";
        for (int i = 0; i < values.length; i++) {
            valueStr = (i == values.length - 1) ? valueStr + values[i]
                    : valueStr + values[i] + ",";
        }
        //乱码解决,这段代码在出现乱码时使用。如果mysign和sign不相等也可以使用这段代码转化
        //valueStr = new String(valueStr.getBytes("ISO-8859-1"), "gbk");
        params.put(name, valueStr);
    }
    return params;
}
 
开发者ID:fanqinghui,项目名称:wish-pay,代码行数:24,代码来源:AliPayUtil.java

示例4: checkComplexMetrics

import com.beust.jcommander.internal.Maps; //导入方法依赖的package包/类
@Test(groups = "orm")
public void checkComplexMetrics() {
  final Alarm newAlarm = new Alarm(alarmDef, AlarmState.ALARM);

  for (final String hostname : Arrays.asList("vivi", "eleanore")) {
    for (final String metricName : Arrays.asList("cpu", "load")) {
      final Map<String, String> dimensions = Maps.newHashMap();
      dimensions.put("first", "first_value");
      dimensions.put("second", "second_value");
      dimensions.put("hostname", hostname);
      final MetricDefinition md = new MetricDefinition(metricName, dimensions);
      newAlarm.addAlarmedMetric(new MetricDefinitionAndTenantId(md, TENANT_ID));
    }
  }
  dao.createAlarm(newAlarm);

  final Alarm found = dao.findById(newAlarm.getId());
  // Have to check both ways because there was a bug in AlarmDAOImpl and it showed up if both
  // ways were tested
  assertTrue(newAlarm.equals(found));
  assertTrue(found.equals(newAlarm));
}
 
开发者ID:openstack,项目名称:monasca-thresh,代码行数:23,代码来源:AlarmSqlImplTest.java

示例5: testFilterResponseContextAdapter

import com.beust.jcommander.internal.Maps; //导入方法依赖的package包/类
@Test
public void testFilterResponseContextAdapter()
{
  DataMap dataMap = new DataMap();
  dataMap.put("foo", "bar");
  Map<String, String> headers = Maps.newHashMap();
  headers.put("x", "y");
  RecordTemplate entity = new Foo(dataMap);
  PartialRestResponse partialResponse =
      new PartialRestResponse.Builder().status(HttpStatus.S_200_OK).headers(headers).entity(entity).build();
  FilterResponseContext context = new Rest4JCallback.FilterResponseContextAdapter(partialResponse);
  assertEquals(headers, context.getResponseHeaders());
  assertEquals(entity, context.getResponseEntity());
  assertEquals(HttpStatus.S_200_OK, context.getHttpStatus());

  context.setHttpStatus(HttpStatus.S_404_NOT_FOUND);
  context.setResponseEntity(null);
  assertNull(context.getResponseEntity());
  assertEquals(HttpStatus.S_404_NOT_FOUND, context.getHttpStatus());
}
 
开发者ID:ppdai,项目名称:rest4j,代码行数:21,代码来源:TestRest4JCallback.java

示例6: tesParsingCorrectPayloadReturnsCorrectEventObject

import com.beust.jcommander.internal.Maps; //导入方法依赖的package包/类
@Test(groups = SMALL)
public void tesParsingCorrectPayloadReturnsCorrectEventObject() {
    Map<String, Object> expectedNewEntity = Maps.newHashMap();
    expectedNewEntity.put("id", 1);
    expectedNewEntity.put("value", "def");

    Map<String, Object> expectedOldEntity = Maps.newHashMap();
    expectedOldEntity.put("id", 1);
    expectedOldEntity.put("value", "abc");

    Event<Map<String, Object>> event = mapper.parseResponse(JSON_CORRECT_RESPONSE);
    assertEquals(event.getEventType(), Event.UPDATE_TYPE);
    assertEquals(event.getEntityName(), "test");
    assertEquals(event.getNewEntity(), expectedNewEntity);
    assertEquals(event.getOldEntity(), expectedOldEntity);

}
 
开发者ID:eBay,项目名称:reactive-source,代码行数:18,代码来源:PsqlEventMapperTest.java

示例7: listOfMapStringString

import com.beust.jcommander.internal.Maps; //导入方法依赖的package包/类
@Test
public void listOfMapStringString() {
    createTable("CREATE TABLE table1 (id INT PRIMARY KEY, data TEXT)");
    this.addConfigHook(c ->
            c.setConverter("table1", "data", new ObjectToJsonStringConverter(List.class, new TypeReference<List<Map<String, String>>>() {
            })));


    Table t1 = lSql.table("table1");

    List<Map<String, String>> list = Lists.newLinkedList();
    Map<String, String> e = Maps.newHashMap();
    e.put("a", "1");
    e.put("b", "2");
    list.add(e);
    list.add(e);

    t1.insert(Row.fromKeyVals("id", 1, "data", list));
    Row row = t1.load(1).get();
    assertEquals(row.get("data"), list);
}
 
开发者ID:w11k,项目名称:lsql,代码行数:22,代码来源:ObjectToJsonStringConverterTest.java

示例8: listOfMapStringStringInALinkedRow

import com.beust.jcommander.internal.Maps; //导入方法依赖的package包/类
@Test
public void listOfMapStringStringInALinkedRow() {
    createTable("CREATE TABLE table1 (id SERIAL PRIMARY KEY, data TEXT)");
    this.addConfigHook(c ->
            c.setConverter(
                    "table1",
                    "data",
                    new ObjectToJsonStringConverter(List.class, new TypeReference<List<Map<String, String>>>() {
                    })));

    Table t1 = lSql.table("table1");

    List<Map<String, String>> list = Lists.newLinkedList();
    Map<String, String> e = Maps.newHashMap();
    e.put("a", "1");
    e.put("b", "2");
    list.add(e);
    list.add(e);
    t1.newLinkedRow("id", 1, "data", list).save();

    Row row = t1.load(1).get();
    assertEquals(row.get("data"), list);
}
 
开发者ID:w11k,项目名称:lsql,代码行数:24,代码来源:ObjectToJsonStringConverterTest.java

示例9: newCacheFileLineProcessor

import com.beust.jcommander.internal.Maps; //导入方法依赖的package包/类
/**
 * Returns a new line processor for the cache file. The processor generates map of song IDs to
 * file names.
 */
static LineProcessor<Map<Integer, String>> newCacheFileLineProcessor() {
    return new LineProcessor<Map<Integer, String>>() {

        @SuppressWarnings("CanBeFinal")
        Map<Integer, String> map = Maps.newHashMap();

        @Override
        public boolean processLine(String line) throws IOException {
            String[] split = line.split("\\|");
            map.put(Integer.valueOf(split[0]), split[1]);
            return true;
        }

        @Override
        public Map<Integer, String> getResult() {
            return map;
        }
    };
}
 
开发者ID:danhawkes,项目名称:basking,代码行数:24,代码来源:WriteCacheFileTask.java

示例10: createDescriptions

import com.beust.jcommander.internal.Maps; //导入方法依赖的package包/类
/**
 * Create the ParameterDescriptions for all the \@Parameter found.
 */
private void createDescriptions() {
    descriptions = Maps.newHashMap();

    for (Object object : objects) {
        addDescription(object);
    }
}
 
开发者ID:georghinkel,项目名称:ttc2017smartGrids,代码行数:11,代码来源:JCommander.java

示例11: write

import com.beust.jcommander.internal.Maps; //导入方法依赖的package包/类
public static void write(Op op, String oracleFullTableName, String topicName, String fileName,
    int maxFileSize, String msg) {
    checkFileSize(fileName, maxFileSize);

    DirtyRecordInfo dirtyRecordInfo = new DirtyRecordInfo();
    dirtyRecordInfo.setOracleTable(oracleFullTableName);
    dirtyRecordInfo.setTopicName(topicName);
    dirtyRecordInfo.setShardId(null);
    dirtyRecordInfo.setErrorMessage(msg);

    SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    dirtyRecordInfo.setErrorTime(simpleDateFormat.format(new Date()));

    Map<String, String> record = Maps.newHashMap();
    dirtyRecordInfo.setRecord(record);

    List<DsColumn> cols = op.getColumns();
    for (int i = 0; i < cols.size(); i++) {
        String colName = op.getTableMeta().getColumnName(i).toLowerCase();
        record.put(colName, cols.get(i).getAfterValue());
    }
    try {
        BufferedWriter bw = new BufferedWriter(new FileWriter(fileName, true));
        bw.write(JsonHelper.beanToJson(dirtyRecordInfo) + "\n");
        bw.close();
    } catch (IOException e) {
        logger.error("logBadOperation() failed. ", e);
        throw new RuntimeException("logBadOperation() failed. ", e);
    }
}
 
开发者ID:aliyun,项目名称:aliyun-maxcompute-data-collectors,代码行数:31,代码来源:BadOperateWriter.java

示例12: init

import com.beust.jcommander.internal.Maps; //导入方法依赖的package包/类
public void init(Module... modules) {
    if(modules == null) {
        modules = new Module[0];
    }
    this.metricModule = new JavaTestModule.MetricModule();
    injector = Guice.createInjector(Iterables.concat(ImmutableList.<Module>of(new CompilingTestModule()), Arrays.asList(modules)));
    source = injector.getInstance(ASMClassSource.class);
    scope = new GambitSource(source);
    this.modules = Maps.newLinkedHashMap();
    this.views = Maps.newHashMap();
    this.sources = Maps.newLinkedHashMap();
}
 
开发者ID:yahoo,项目名称:yql-plus,代码行数:13,代码来源:CompilingTestBase.java

示例13: mapAvailabilityZones

import com.beust.jcommander.internal.Maps; //导入方法依赖的package包/类
private Map<Integer, String> mapAvailabilityZones() {
    List<String> zones = ec2Service.getAvailabilityZones();

    if (zones.size() < MINIMUM_AZS) {
        throw new IllegalStateException("Not enough availability zones for the selected region.");
    }

    Map<Integer, String> azByIdentifier = Maps.newHashMap();

    for (int i = 1; i <= MINIMUM_AZS; i++) {
        azByIdentifier.put(i, zones.get(i - 1));
    }

    return azByIdentifier;
}
 
开发者ID:Nike-Inc,项目名称:cerberus-lifecycle-cli,代码行数:16,代码来源:CreateBaseOperation.java

示例14: getStackParameters

import com.beust.jcommander.internal.Maps; //导入方法依赖的package包/类
/**
 * Returns the current status of the named stack.
 *
 * @param stackId Stack name.
 * @return Stack outputs data.
 */
public Map<String, String> getStackParameters(final String stackId) {
    final DescribeStacksRequest request = new DescribeStacksRequest().withStackName(stackId);
    final DescribeStacksResult result = cloudFormationClient.describeStacks(request);
    final Map<String, String> parameters = Maps.newHashMap();

    if (result.getStacks().size() > 0) {
        parameters.putAll(result.getStacks().get(0).getParameters().stream().collect(
                Collectors.toMap(Parameter::getParameterKey, Parameter::getParameterValue)));

    }

    return parameters;
}
 
开发者ID:Nike-Inc,项目名称:cerberus-lifecycle-cli,代码行数:20,代码来源:CloudFormationService.java

示例15: getStackOutputs

import com.beust.jcommander.internal.Maps; //导入方法依赖的package包/类
/**
 * Returns the current status of the named stack.
 *
 * @param stackId Stack name.
 * @return Stack outputs data.
 */
public Map<String, String> getStackOutputs(final String stackId) {
    final DescribeStacksRequest request = new DescribeStacksRequest().withStackName(stackId);
    final DescribeStacksResult result = cloudFormationClient.describeStacks(request);
    final Map<String, String> outputs = Maps.newHashMap();

    if (result.getStacks().size() > 0) {
        outputs.putAll(result.getStacks().get(0).getOutputs().stream().collect(
                Collectors.toMap(Output::getOutputKey, Output::getOutputValue)));

    }

    return outputs;
}
 
开发者ID:Nike-Inc,项目名称:cerberus-lifecycle-cli,代码行数:20,代码来源:CloudFormationService.java


注:本文中的com.beust.jcommander.internal.Maps.newHashMap方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。