Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump version to 1.2.0 #201

Merged
merged 3 commits into from
Dec 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.apicatalog</groupId>
<artifactId>titanium-json-ld</artifactId>
<version>1.1.1-SNAPSHOT</version>
<version>1.2.0</version>
<packaging>jar</packaging>

<name>Titanium JSON-LD 1.1</name>
Expand Down
20 changes: 10 additions & 10 deletions src/main/java/com/apicatalog/jsonld/flattening/NodeMapBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ public NodeMap build() throws JsonLdError {
// 4.1.1.
if (nodeMap.contains(activeGraph, activeSubject, activeProperty)) {

JsonArray activePropertyValue = nodeMap.get(activeGraph, activeSubject, activeProperty).asJsonArray();
final JsonArray activePropertyValue = nodeMap.get(activeGraph, activeSubject, activeProperty).asJsonArray();

if (activePropertyValue.stream().noneMatch(e -> Objects.equals(e, element))) {
nodeMap.set(activeGraph, activeSubject, activeProperty, Json.createArrayBuilder(activePropertyValue).add(element).build());
Expand Down Expand Up @@ -219,11 +219,13 @@ public NodeMap build() throws JsonLdError {
// 6.1.
if (elementObject.containsKey(Keywords.ID)) {

if (JsonUtils.isNotString(elementObject.get(Keywords.ID)) || JsonUtils.isNull(elementObject.get(Keywords.ID))) {
final JsonValue idValue = elementObject.get(Keywords.ID);

if (JsonUtils.isNull(idValue) || JsonUtils.isNotString(idValue)) {
return nodeMap;
}

id = ((JsonString)elementObject.get(Keywords.ID)).getString();
id = ((JsonString)idValue).getString();

if (BlankNode.hasPrefix(id)) {
id = nodeMap.createIdentifier(id);
Expand All @@ -250,7 +252,7 @@ public NodeMap build() throws JsonLdError {

final JsonArray activePropertyValue = nodeMap.get(activeGraph, id, activeProperty).asJsonArray();

if (activePropertyValue.stream().noneMatch(e -> Objects.equals(e, JsonUtils.toJsonObject(referencedNode)))) {
if (activePropertyValue.stream().filter(JsonUtils::isObject).noneMatch(e -> Objects.equals(e.asJsonObject(), JsonUtils.toJsonObject(referencedNode)))) {
nodeMap.set(activeGraph, id, activeProperty, Json.createArrayBuilder(activePropertyValue).add(JsonUtils.toJsonObject(referencedNode)).build());
}

Expand All @@ -263,7 +265,7 @@ public NodeMap build() throws JsonLdError {
} else if (activeProperty != null) {

// 6.6.1.
JsonObject reference = Json.createObjectBuilder().add(Keywords.ID, id).build();
final JsonObject reference = Json.createObjectBuilder().add(Keywords.ID, id).build();

// 6.6.2.
if (list == null) {
Expand Down Expand Up @@ -324,12 +326,10 @@ public NodeMap build() throws JsonLdError {

if (nodeMap.contains(activeGraph, id, Keywords.INDEX)) {
throw new JsonLdError(JsonLdErrorCode.CONFLICTING_INDEXES);

} else {
nodeMap.set(activeGraph, id, Keywords.INDEX, elementObject.get(Keywords.INDEX));

elementObject.remove(Keywords.INDEX);
}

nodeMap.set(activeGraph, id, Keywords.INDEX, elementObject.get(Keywords.INDEX));
elementObject.remove(Keywords.INDEX);
}

// 6.9.
Expand Down