ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
# 组件源码 ``` /** * <b>方法描述:</b> 容器变量删除(保留keys) <br/> * <b>创建者:</b> admin <br/> * <b>创建时间:</b> 2018-05-11 11:53:17 <br/> * * @param dict * 入参|容器|{@link java.util.Map} * @param keys * 入参|保留列表|{@link com.ylink.ide.trade.runtime.context.JavaList} * @return 0 失败<br/> * 1 成功<br/> */ @Component(label = "容器变量删除(保留keys)", style = "判断型", type = "同步组件", comment = "删除容器中的变量,只保留输入的指定key", version = "1.0.0", deprecated = false, author = "admin", date = "2018-05-11 11:53:17") @InParams(param = {@Param(name = "dict", comment = "容器", type = java.util.Map.class), @Param(name = "keys", comment = "保留列表", type = java.util.List.class)}) @Returns(returns = {@Return(id = "0", desp = "失败"), @Return(id = "1", desp = "成功")}) public static ResultBase P_delAndRetainKeys(Map dict, List keys) { if (dict == null) return ResultBase.newFailureResult("TPTC2003", "容器不能为空(Null)"); if (keys == null) return ResultBase.newFailureResult("TPTC2003", "保留元素集合不能为空(Null)"); Iterator it = dict.entrySet().iterator(); while (it.hasNext()) { Map.Entry en = (Entry)it.next(); if (!keys.contains(en.getKey())) { it.remove(); } } return ResultBase.newSuccessResult(); } ``` # 交易中组件使用方式 ![](https://img.kancloud.cn/af/32/af326bb3d2bdf9d73ed6c7af3a06ab73_1872x893.png) # 参数说明及示例 ## 入口参数 容器:一个 Map 对象,示例: `__INNER__` 保留列表:删除容器中的变量,只保留输入的指定 key,示例: `["x"]`