Skip to content

Commit

Permalink
Merge pull request #201 from filip26/snapshot-120
Browse files Browse the repository at this point in the history
Bump version to 1.2.0
  • Loading branch information
filip26 authored Dec 19, 2021
2 parents 5dd6738 + bae9eaa commit 554d7b7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
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

0 comments on commit 554d7b7

Please sign in to comment.