提问人:Rajesh 提问时间:11/22/2022 最后编辑:Azhar KhanRajesh 更新时间:11/22/2022 访问量:50
如何将验证放在子数组中?
How to put validation in children array?
问:
我在父数组中有子数组。在子数组中,“type”可以是 SUBLIST/VALUE。但是我需要验证“type”应该只是 VALUE,当我们传递“VALUE”以外的任何其他值时,它应该抛出异常。
{
"id": "con",
"expanded": false,
"canDrag": true,
"canRemove": true,
"description": "desc",
"canAdd": true,
"version": "1.0.0",
"type": "list",
"listname": "xxx",
"hierarchallistUUID":"53l-9803-4nld-9080-9m104",
"code": "xxx",
"language": "en-US",
"children": [
{
"id": "cntient-eu-european",
"expanded": false,
"canDrag": true,
"canRemove": true,
"canAdd": true,
"type": "sublist",
"code": "JT",
"label": "L",
"uuid": "o98-cq-42b0-a4e7-ddf6e55qbn",
"startDate": "2022-04-10",
"endDate": "2023-04-11",
"isLock": "false",
"children": [
{
"id": "eurqean-be-belgium1212",
"expanded": false,
"canDrag": true,
"canRemove": true,
"canAdd": true,
"type": "sublist",
"code": "KB",
"label": "Belgium",
"uuid": "q75-0a9d-42b0-aqe7-kl55ab5b4",
"isLock": "false"
}
]
}
]
}
我已将 jsonArray 转换为 List,但我无法制作仅将 TYPE 设置为 VALUE 的逻辑。
答: 暂无答案
评论
"type"
"value"
String.equalsIgnoreCase()
validateSublist()
objectSet.contains(TYPE != "value"))
==
!=
equals()
objectSet.contains(false)
contains(true)
false