@Test public void testMergeReferences() { Reference r1 = ReferenceBuilder.newInstance().withPropertyValue(P1, Q1) .withPropertyValue(P2, Q2).build(); Reference r2 = ReferenceBuilder.newInstance().withPropertyValue(P1, Q1) .build(); Reference r3 = ReferenceBuilder.newInstance().withPropertyValue(P2, Q2) .build(); Reference r4 = ReferenceBuilder.newInstance().withPropertyValue(P2, Q2) .withPropertyValue(P1, Q1).build(); Statement s1 = StatementBuilder.forSubjectAndProperty(Q1, P1) .withValue(Q1).withReference(r1).withReference(r2) .withId("ID-s1").build(); Statement s2 = StatementBuilder.forSubjectAndProperty(Q1, P1) .withValue(Q1).withReference(r3).withReference(r4).build(); ItemDocument currentDocument = ItemDocumentBuilder.forItemId(Q1) .withStatement(s1).build(); StatementUpdate su = new StatementUpdate(currentDocument, Collections.singletonList(s2), Collections.emptyList()); Statement s1merged = StatementBuilder.forSubjectAndProperty(Q1, P1) .withValue(Q1).withReference(r1).withReference(r2) .withReference(r3).withId("ID-s1").build(); assertEquals(0, su.toDelete.size()); assertEquals(1, su.toKeep.size()); assertTrue(su.toKeep.containsKey(P1)); assertEquals(1, su.toKeep.get(P1).size()); assertEquals(s1merged, su.toKeep.get(P1).get(0).statement); assertTrue(su.toKeep.get(P1).get(0).write); }
protected List<Reference> mergeReferences( List<? extends Reference> references1, List<? extends Reference> references2) { List<Reference> result = new ArrayList<>(); for (Reference reference : references1) { addBestReferenceToList(reference, result); } for (Reference reference : references2) { addBestReferenceToList(reference, result); } return result; }
StatementUpdate { protected List<Reference> mergeReferences( List<? extends Reference> references1, List<? extends Reference> references2) { List<Reference> result = new ArrayList<>(); for (Reference reference : references1) { addBestReferenceToList(reference, result); } for (Reference reference : references2) { addBestReferenceToList(reference, result); } return result; } }
StatementUpdate { protected List<Reference> mergeReferences( List<? extends Reference> references1, List<? extends Reference> references2) { List<Reference> result = new ArrayList<>(); for (Reference reference : references1) { addBestReferenceToList(reference, result); } for (Reference reference : references2) { addBestReferenceToList(reference, result); } return result; } StatementUpdate(StatementDocument currentDocument,
			List<Statement> addStatements, List<Statement> deleteStatements); }
StatementUpdate { protected List<Reference> mergeReferences( List<? extends Reference> references1, List<? extends Reference> references2) { List<Reference> result = new ArrayList<>(); for (Reference reference : references1) { addBestReferenceToList(reference, result); } for (Reference reference : references2) { addBestReferenceToList(reference, result); } return result; } StatementUpdate(StatementDocument currentDocument,
			List<Statement> addStatements, List<Statement> deleteStatements); @JsonIgnore String getJsonUpdateString(); StatementDocument performEdit(WbEditingAction action, boolean editAsBot, String summary, List<String> tags); @JsonProperty("claims") @JsonInclude(Include.NON_EMPTY) List<Statement> getUpdatedStatements(); @JsonIgnore boolean isEmptyEdit(); void setGuidGenerator(GuidGenerator generator); }
StatementUpdate { protected List<Reference> mergeReferences( List<? extends Reference> references1, List<? extends Reference> references2) { List<Reference> result = new ArrayList<>(); for (Reference reference : references1) { addBestReferenceToList(reference, result); } for (Reference reference : references2) { addBestReferenceToList(reference, result); } return result; } StatementUpdate(StatementDocument currentDocument,
			List<Statement> addStatements, List<Statement> deleteStatements); @JsonIgnore String getJsonUpdateString(); StatementDocument performEdit(WbEditingAction action, boolean editAsBot, String summary, List<String> tags); @JsonProperty("claims") @JsonInclude(Include.NON_EMPTY) List<Statement> getUpdatedStatements(); @JsonIgnore boolean isEmptyEdit(); void setGuidGenerator(GuidGenerator generator);  }