Inconsistent use of set* and add*, especially in FileEntityBuilder
维护者通常 12 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 新手友好度
- 35/100
- Issue 类型
- 文档
- 描述清晰度
- 基本清楚
- 活跃度
- 停滞
- 技术栈
- java
调研方向
先阅读 issue 中提到的 FileEntityBuilder 方法,然后比较其他实体构建器中 add* 和 set* 的行为。记录观察到的用途和差异,包括 setId、addProperty、addType、setLicense 和 setLocation 的示例;该 issue 未指定文档文件或测试。
由索引模型根据 Issue 内容生成。
描述
As mentioned in #216 there is the need to document purpose and differences of add* and set* in general. While the actual purpose seems to be clear on the semantic level, it's almost impossible to estimate the effect of a set* or add* call without deeper knowledge of the code. Let's take the following example:
FileEntity file = new FileEntity.FileEntityBuilder()
.setId("survey-responses-2019.csv")
.addProperty("name", "Survey responses")
.addType("rdfs:Property")
.setLicense(new ContextualEntity.ContextualEntityBuilder().setId("licenseId").addProperty("name", "LicenseName").build())
.addProperty("contentSize", "26452")
.addProperty("encodingFormat", jsonNode)
.setLocation("http://example.com")
.build()
- setId - Compared to other calls it should do the same as addProperty('@id', id), but holds id different than other properties, such that addProperty('@id', '123') would not work (and may even cause errors). Furthermore, if the id was already set, the call does nothing, such that overwriting an id is not foreseen (which is somehow fine).
- addProperty - Should be better called setProperty(key, value), as previously added properties with the same name are overwritten. Thus, array values can only be set via addProperty(String, JsonNode). Therefore, one could think of either renaming addProperty to setProperty or changing its behaviour (see next point)
- addType - Actually does what an add-method is supposed to do. At the first call it initializes a HashMap and adds the provided value, while subsequent calls add additional values to the HashMap. So basically the behaviour expected also for addProperty.
- setLicense - One of the most confusing calls. In both cases, it internally calls addIdProperty("license", id). If you call it with a string argument, the value is assumed to be the license id and is directly used. If called with a ContextualEntity argument, getId() is used as license id, while the rest is omitted. Thus, the ContextualEntity of the license has to be added separately to the crate afterwards.
- setLocation - Probably the most confusing call as there are more internal possibilities of what may happen. If called with an URI, the argument is set as id. If id was set before, the call is ignored. If called with a path and the id was not set before, the filename is used as id and path as location. If id was set before, path is only used as location without changing the id. If path is null, nothing is done (unless setLocationWithExceptions is used) and if path points to an non existing file, everything is fine until the crate is written and an exception is thrown.
For the moment, I just wanted to have these points documented for further discussions. I also have the impression, that for other entity builders the situation is much clearer (and mostly limited on the builder-level to set* for single values), but a consistent behaviour would be desirable.
- 主要语言
- Java
- 星标
- 5
- 派生
- 4
- 平均合并
- 12 天 10 小时
- 30 天内合并 PR
- 8
环境准备
在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 没有贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
kit-data-manager/ro-crate-java 的其他 Issue
-
documentation
难度 1/5 1 小时以内 新手友好度 75/100
kit-data-manager/ro-crate-java#377 ·
维护者通常 12 天内回复
-
Support Jackson 3可能重新可做 @Pfeil 于 58 天前认领,目前没有进行中的 PR。 未关闭maintenance
kit-data-manager/ro-crate-java#349 · 4 条评论 · 已指派 1 人 ·
维护者通常 12 天内回复
-
Adapt codemeta.json可能重新可做 @Pfeil 于 118 天前认领,目前没有进行中的 PR。 未关闭maintenance
kit-data-manager/ro-crate-java#342 · 已指派 1 人 ·
维护者通常 12 天内回复
-
难度 4/5 3-5 天 新手友好度 20/100
kit-data-manager/ro-crate-java#310 ·
维护者通常 12 天内回复
-
Fully support v1.2.0 features and crates可能重新可做 @Pfeil 于 402 天前认领,目前没有进行中的 PR。 未关闭documentation enhancement maintenance specification-compliance
kit-data-manager/ro-crate-java#282 · 2 条评论 · 已指派 1 人 ·
维护者通常 12 天内回复
查看 kit-data-manager/ro-crate-java 的全部 Issue
相似的 Issue
-
enhancement
难度 2/5 1-3 小时 新手友好度 65/100
-
bug
难度 2/5 1-3 小时 新手友好度 72/100
ReChronoRain/HyperCeiler#1743 ·
维护者通常 6 天内回复
-
Weaviate: bump test image to 1.39.13 (CVE-2026-111943) and identify solon-ai via integration header未关闭
难度 2/5 1-3 小时 新手友好度 72/100
-
status: needs-triage
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 86/100
hiero-ledger/hiero-sdk-java#3010 ·
维护者通常 1 天内回复