diff --git a/pom.xml b/pom.xml
index 7e5a1ead..229174f8 100644
--- a/pom.xml
+++ b/pom.xml
@@ -8,7 +8,7 @@
4.0.0
com.apicatalog
titanium-json-ld
- 1.1.1-SNAPSHOT
+ 1.2.0
jar
Titanium JSON-LD 1.1
diff --git a/src/main/java/com/apicatalog/jsonld/flattening/NodeMapBuilder.java b/src/main/java/com/apicatalog/jsonld/flattening/NodeMapBuilder.java
index cb5dc2df..f7a9be1c 100644
--- a/src/main/java/com/apicatalog/jsonld/flattening/NodeMapBuilder.java
+++ b/src/main/java/com/apicatalog/jsonld/flattening/NodeMapBuilder.java
@@ -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());
@@ -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);
@@ -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());
}
@@ -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) {
@@ -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.