package org.marsik.elshelves.api.entities;

import com.fasterxml.jackson.annotation.JsonIdentityInfo;
import com.fasterxml.jackson.annotation.JsonIdentityReference;
import com.fasterxml.jackson.annotation.ObjectIdGenerators;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.marsik.elshelves.ember.EmberModelName;
import org.marsik.elshelves.api.entities.idresolvers.RequirementIdResolver;

import java.util.Set;
import java.util.UUID;

@Data
@EqualsAndHashCode(of = {}, callSuper = true)
@JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "id", resolver = RequirementIdResolver.class)
@EmberModelName("requirement")
public class RequirementApiModel extends AbstractEntityApiModel {
	public RequirementApiModel(UUID id) {
		super(id);
	}

	public RequirementApiModel() {
	}

    String name;
    String summary;

	/**
	 * Deprecated
	 * Used only for reading old backups
	 */
	ProjectApiModel project;

	ItemApiModel item;

	Set<PartTypeApiModel> type;

	Long count;

	Set<LotApiModel> lots;

	@JsonIdentityReference(alwaysAsId = true)
	public ProjectApiModel getProject() {
		return project;
	}

	@JsonIdentityReference(alwaysAsId = true)
	public Set<PartTypeApiModel> getType() {
		return type;
	}

	@JsonIdentityReference(alwaysAsId = true)
	public Set<LotApiModel> getLots() {
		return lots;
	}
}

@@ -1339,11 +1339,106 @@
 lots;%0A%09%7D
+%0A%0A%09@JsonIdentityReference(alwaysAsId = true)%0A%09public ItemApiModel getItem() %7B%0A%09%09return item;%0A%09%7D
 %0A%7D%0A

Send item as ID in RequirementApiModel