@Test public void testWithForm() { FormDocument newForm = ld1.createForm(Collections.singletonList(new TermImpl("en", "add1"))); assertEquals(lid, newForm.getEntityId().getLexemeId()); assertEquals(ld1.getForms().size() + 1, ld1.withForm(newForm).getForms().size()); assertEquals(newForm, ld1.withForm(newForm).getForm(newForm.getEntityId())); }
@Override public LexemeDocument withForm(FormDocument form) { if(!form.getEntityId().getLexemeId().equals(getEntityId())) { throw new IllegalArgumentException("The form " + form.getEntityId() + " does not belong to lexeme " + getEntityId()); } List<FormDocument> newForms = new ArrayList<>(forms); newForms.add(form); return new LexemeDocumentImpl(getEntityId(), lexicalCategory, language, lemmas, claims, newForms, senses, revisionId, nextFormId, nextSenseId); }
LexemeDocumentImpl extends StatementDocumentImpl implements LexemeDocument { @Override public LexemeDocument withForm(FormDocument form) { if(!form.getEntityId().getLexemeId().equals(getEntityId())) { throw new IllegalArgumentException("The form " + form.getEntityId() + " does not belong to lexeme " + getEntityId()); } List<FormDocument> newForms = new ArrayList<>(forms); newForms.add(form); return new LexemeDocumentImpl(getEntityId(), lexicalCategory, language, lemmas, claims, newForms, senses, revisionId, nextFormId, nextSenseId); } }
LexemeDocumentImpl extends StatementDocumentImpl implements LexemeDocument { @Override public LexemeDocument withForm(FormDocument form) { if(!form.getEntityId().getLexemeId().equals(getEntityId())) { throw new IllegalArgumentException("The form " + form.getEntityId() + " does not belong to lexeme " + getEntityId()); } List<FormDocument> newForms = new ArrayList<>(forms); newForms.add(form); return new LexemeDocumentImpl(getEntityId(), lexicalCategory, language, lemmas, claims, newForms, senses, revisionId, nextFormId, nextSenseId); } LexemeDocumentImpl(
			LexemeIdValue id,
			ItemIdValue lexicalCategory,
			ItemIdValue language,
			List<MonolingualTextValue> lemmas,
			List<StatementGroup> statements,
			List<FormDocument> forms,
			List<SenseDocument> senses,
			long revisionId); @JsonCreator  LexemeDocumentImpl(
			@JsonProperty("id") String jsonId,
			@JsonProperty("lexicalCategory") String lexicalCategory,
			@JsonProperty("language") String language,
			@JsonProperty("lemmas") @JsonDeserialize(contentAs=TermImpl.class) Map<String, MonolingualTextValue> lemmas,
			@JsonProperty("claims") Map<String, List<StatementImpl.PreStatement>> claims,
			@JsonProperty("forms") @JsonDeserialize(contentAs=FormDocumentImpl.class) List<FormDocument> forms,
			@JsonProperty("senses") @JsonDeserialize(contentAs=SenseDocumentImpl.class) List<SenseDocument> senses,
			@JsonProperty("lastrevid") long revisionId,
			@JacksonInject("siteIri") String siteIri); private  LexemeDocumentImpl(
			LexemeIdValue id,
			ItemIdValue lexicalCategory,
			ItemIdValue language,
			Map<String, MonolingualTextValue> lemmas,
			Map<String, List<Statement>> statements,
			List<FormDocument> forms,
			List<SenseDocument> senses,
			long revisionId,
			int nextFormId,
			int nextSenseId); }
LexemeDocumentImpl extends StatementDocumentImpl implements LexemeDocument { @Override public LexemeDocument withForm(FormDocument form) { if(!form.getEntityId().getLexemeId().equals(getEntityId())) { throw new IllegalArgumentException("The form " + form.getEntityId() + " does not belong to lexeme " + getEntityId()); } List<FormDocument> newForms = new ArrayList<>(forms); newForms.add(form); return new LexemeDocumentImpl(getEntityId(), lexicalCategory, language, lemmas, claims, newForms, senses, revisionId, nextFormId, nextSenseId); } LexemeDocumentImpl(
			LexemeIdValue id,
			ItemIdValue lexicalCategory,
			ItemIdValue language,
			List<MonolingualTextValue> lemmas,
			List<StatementGroup> statements,
			List<FormDocument> forms,
			List<SenseDocument> senses,
			long revisionId); @JsonCreator  LexemeDocumentImpl(
			@JsonProperty("id") String jsonId,
			@JsonProperty("lexicalCategory") String lexicalCategory,
			@JsonProperty("language") String language,
			@JsonProperty("lemmas") @JsonDeserialize(contentAs=TermImpl.class) Map<String, MonolingualTextValue> lemmas,
			@JsonProperty("claims") Map<String, List<StatementImpl.PreStatement>> claims,
			@JsonProperty("forms") @JsonDeserialize(contentAs=FormDocumentImpl.class) List<FormDocument> forms,
			@JsonProperty("senses") @JsonDeserialize(contentAs=SenseDocumentImpl.class) List<SenseDocument> senses,
			@JsonProperty("lastrevid") long revisionId,
			@JacksonInject("siteIri") String siteIri); private  LexemeDocumentImpl(
			LexemeIdValue id,
			ItemIdValue lexicalCategory,
			ItemIdValue language,
			Map<String, MonolingualTextValue> lemmas,
			Map<String, List<Statement>> statements,
			List<FormDocument> forms,
			List<SenseDocument> senses,
			long revisionId,
			int nextFormId,
			int nextSenseId); @JsonIgnore @Override LexemeIdValue getEntityId(); @JsonIgnore @Override ItemIdValue getLexicalCategory(); @JsonIgnore @Override ItemIdValue getLanguage(); @JsonProperty("lemmas") @Override Map<String, MonolingualTextValue> getLemmas(); @JsonProperty("forms") @Override List<FormDocument> getForms(); @JsonProperty("senses") @Override List<SenseDocument> getSenses(); @JsonIgnore @Override FormDocument getForm(FormIdValue formId); @JsonIgnore @Override SenseDocument getSense(SenseIdValue senseId); @Override int hashCode(); @Override boolean equals(Object obj); @Override String toString(); @Override LexemeDocument withLexicalCategory(ItemIdValue newLexicalCategory); @Override LexemeDocument withLanguage(ItemIdValue newLanguage); @Override LexemeDocument withLemma(MonolingualTextValue lemma); @Override LexemeDocument withStatement(Statement statement); @Override LexemeDocument withoutStatementIds(Set<String> statementIds); @Override FormDocument createForm(List<MonolingualTextValue> representations); @Override LexemeDocument withForm(FormDocument form); @Override SenseDocument createSense(List<MonolingualTextValue> glosses); @Override LexemeDocument withSense(SenseDocument sense); @Override LexemeDocument withRevisionId(long newRevisionId); }
LexemeDocumentImpl extends StatementDocumentImpl implements LexemeDocument { @Override public LexemeDocument withForm(FormDocument form) { if(!form.getEntityId().getLexemeId().equals(getEntityId())) { throw new IllegalArgumentException("The form " + form.getEntityId() + " does not belong to lexeme " + getEntityId()); } List<FormDocument> newForms = new ArrayList<>(forms); newForms.add(form); return new LexemeDocumentImpl(getEntityId(), lexicalCategory, language, lemmas, claims, newForms, senses, revisionId, nextFormId, nextSenseId); } LexemeDocumentImpl(
			LexemeIdValue id,
			ItemIdValue lexicalCategory,
			ItemIdValue language,
			List<MonolingualTextValue> lemmas,
			List<StatementGroup> statements,
			List<FormDocument> forms,
			List<SenseDocument> senses,
			long revisionId); @JsonCreator  LexemeDocumentImpl(
			@JsonProperty("id") String jsonId,
			@JsonProperty("lexicalCategory") String lexicalCategory,
			@JsonProperty("language") String language,
			@JsonProperty("lemmas") @JsonDeserialize(contentAs=TermImpl.class) Map<String, MonolingualTextValue> lemmas,
			@JsonProperty("claims") Map<String, List<StatementImpl.PreStatement>> claims,
			@JsonProperty("forms") @JsonDeserialize(contentAs=FormDocumentImpl.class) List<FormDocument> forms,
			@JsonProperty("senses") @JsonDeserialize(contentAs=SenseDocumentImpl.class) List<SenseDocument> senses,
			@JsonProperty("lastrevid") long revisionId,
			@JacksonInject("siteIri") String siteIri); private  LexemeDocumentImpl(
			LexemeIdValue id,
			ItemIdValue lexicalCategory,
			ItemIdValue language,
			Map<String, MonolingualTextValue> lemmas,
			Map<String, List<Statement>> statements,
			List<FormDocument> forms,
			List<SenseDocument> senses,
			long revisionId,
			int nextFormId,
			int nextSenseId); @JsonIgnore @Override LexemeIdValue getEntityId(); @JsonIgnore @Override ItemIdValue getLexicalCategory(); @JsonIgnore @Override ItemIdValue getLanguage(); @JsonProperty("lemmas") @Override Map<String, MonolingualTextValue> getLemmas(); @JsonProperty("forms") @Override List<FormDocument> getForms(); @JsonProperty("senses") @Override List<SenseDocument> getSenses(); @JsonIgnore @Override FormDocument getForm(FormIdValue formId); @JsonIgnore @Override SenseDocument getSense(SenseIdValue senseId); @Override int hashCode(); @Override boolean equals(Object obj); @Override String toString(); @Override LexemeDocument withLexicalCategory(ItemIdValue newLexicalCategory); @Override LexemeDocument withLanguage(ItemIdValue newLanguage); @Override LexemeDocument withLemma(MonolingualTextValue lemma); @Override LexemeDocument withStatement(Statement statement); @Override LexemeDocument withoutStatementIds(Set<String> statementIds); @Override FormDocument createForm(List<MonolingualTextValue> representations); @Override LexemeDocument withForm(FormDocument form); @Override SenseDocument createSense(List<MonolingualTextValue> glosses); @Override LexemeDocument withSense(SenseDocument sense); @Override LexemeDocument withRevisionId(long newRevisionId);  }