我有下面的值与哈希值映射,在值中我已经日期为字符串数据类型。我想比较地图中所有可用的日期,并仅提取一个具有最近日期的键值。
我想与值而不是键进行比较。
我已包含以下代码
import java.util.HashMap;
import java.util.Map;
public class Test {
public static void main(String[] args) {
Map<String, String> map = new HashMap<>();
map.put("1", "1999-01-01");
map.put("2", "2013-10-11");
map.put("3", "2011-02-20");
map.put("4", "2014-09-09");
map.forEach((k, v) -> System.out.println("Key : " + k + " Value : " + v));
}
}
Run Code Online (Sandbox Code Playgroud)
预期的输出是:
关键4值2014-09-09
我正在尝试为以下 JSON 创建一个 swagger 文档,但我收到以下错误:带有“类型:数组”的模式,需要一个兄弟“项目:”字段
JSON:
{
"_id": "string",
"name": "string",
"descriptions": {},
"date": "string",
"customer": {
"id": "string",
"name": {
"firstName": "string",
"lastName": "string",
"middleName": "string"
}
},
"productDetials": {
"id": "string",
"name": {
"name": "string",
"model": "string",
"price": "string",
"comments": "string"
}
},
"Phone": [{
"id": "string",
"category": "string",
"version": "string",
"condition": "string",
"availability": "string"
}
]
}
Run Code Online (Sandbox Code Playgroud)
有人可以帮我获取此 JSON 的 swagger 文档吗?
任何帮助将非常感激。
我是 Groovy gradle 世界的新手,我已经编写了包含所有测试用例的小型 Groovy 项目。我正在尝试使用 jacoco 插件生成代码覆盖率报告。但它只生成测试报告而不生成代码覆盖率报告。请找到我的 jacoco gradle 文件配置。我正在使用gradle 4.5 版本和Groovy 版本:2.5.0 -rc-2 JVM:1.8.0_171 供应商:Oracle Corporation 操作系统:Windows 10
为了生成 html 格式的 jacoco 代码覆盖率报告,我在这里缺少什么。
提前感谢您的帮助!
我的 jacoco.gradle
apply plugin: "jacoco"
jacoco {
toolVersion = '0.8.1'
}
jacocoTestReport {
group = "reporting"
description = "Generate Jacoco coverage reports after running tests."
reports {
xml.enabled true
html.enabled true
csv.enabled false
html.destination "${buildDir}/jacocoHtml"
}
sourceDirectories = fileTree(dir: 'src/main/myproject')
}
Run Code Online (Sandbox Code Playgroud)
我正在运行gradle clean build命令在我的项目存储库下生成构建文件夹。
我正在寻找一种使用 Java Apache FOP 在 XSLT 中生成条形图的方法。
我正在尝试使用下面的 XML 和 XSLT 生成条形图,但它生成没有任何图表的空 .PDF 文件?
数据.xml
<?xml version="1.0" encoding="UTF-8"?>
<sales>
<region>
<title>Eastern Region Quarterly Sales (Second/'04)</title>
<key1 area="New York Area">.95</key1>
<key2 area="Virginia Area">.89</key2>
<key3 area="Maryland Area">.67</key3>
<key4 area="Connecticut Area">.65</key4>
<key5 area="Delaware Area">.45</key5>
</region>
</sales>
Run Code Online (Sandbox Code Playgroud)
酒吧.xsl
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes" />
<xsl:template match="sales">
<svg width="650" height="500">
<g id="axis" transform="translate(0 500) scale(1 -1)">
<line id="axis-y" x1="30" y1="20" x2="30" y2="450" style="fill:none;stroke:rgb(0,0,0);stroke-width:2" />
<line id="axis-x" x1="30" y1="20" x2="460" y2="20" style="fill:none;stroke:rgb(0,0,0);stroke-width:2" /> …Run Code Online (Sandbox Code Playgroud) 我想用;分隔符拆分以下查询字符串并转换为地图。这样我就可以使用密钥访问值 iPhone、6s Plus 和 2016。
def query = type=iPhone;modelName=6s Plus;year=2016
def result = query .split(';')
println result
Run Code Online (Sandbox Code Playgroud)
我想访问这样的值 - result.getAt('type'), result.getAt('modelName')
我尝试了以下方法 - 但它没有按预期工作
Map<String,String> response = result.collectEntries{
[
it.type,
it.modelName,
it.year
]
}
Run Code Online (Sandbox Code Playgroud)
我怎样才能在 Groovy 中实现这一点?
我正在尝试在REST API中从下面的JSON解析productId,名称和价格-但是尝试获取他时我得到了空指针异常name- String name = (String) obj.get("name");,我可以知道我在做什么错吗?
任何帮助将非常感激。谢谢!
JSON:
{
"id": "af0b86eb-046c-4400-8bc4-0e26042b8f53",
"products": [{
"productId": "1234",
"name": "apple",
"price": "383939"
}
]
}
Run Code Online (Sandbox Code Playgroud)
Controller.java
public ResponseEntity<Object> create(@RequestBody Map<String, Object> obj) {
Product response = myservice.create(obj);
return new ResponseEntity<Object>(response, HttpStatus.CREATED);
}
Run Code Online (Sandbox Code Playgroud)
Service.java
public Product create(Map<String, Object> obj) {
for (Entry<String, Object> entry : obj.entrySet()) {
System.out.println("Key : " + entry.getKey() + " Value : " + entry.getValue());
}
Object [] products = (Object[]) obj.get("products");
HashMap <String, Object> productOne …Run Code Online (Sandbox Code Playgroud)