it.cnr.iit.jscontact.tools.dto.Organization Maven / Gradle / Ivy
package it.cnr.iit.jscontact.tools.dto;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import it.cnr.iit.jscontact.tools.constraints.BooleanMapConstraint;
import it.cnr.iit.jscontact.tools.constraints.NotNullAnyConstraint;
import it.cnr.iit.jscontact.tools.dto.deserializers.ContextsDeserializer;
import it.cnr.iit.jscontact.tools.dto.interfaces.HasContexts;
import it.cnr.iit.jscontact.tools.dto.interfaces.IdMapValue;
import it.cnr.iit.jscontact.tools.dto.interfaces.IsIANAType;
import it.cnr.iit.jscontact.tools.dto.serializers.ContextsSerializer;
import lombok.*;
import lombok.experimental.SuperBuilder;
import javax.validation.Valid;
import javax.validation.constraints.Pattern;
import java.io.Serializable;
import java.util.Map;
/**
* Class mapping the Organization type as defined in section 2.2.3 of [RFC9553].
*
* @see Section 2.2.3 of RFC9553
* @author Mario Loffredo
*/
@NotNullAnyConstraint(fieldNames = {"name", "units"}, message = "at least one not null member between name and units is required in Organization")
@JsonPropertyOrder({"@type", "name", "units", "sortAs", "contexts"})
@JsonInclude(JsonInclude.Include.NON_NULL)
@SuperBuilder
@Data
@AllArgsConstructor
@NoArgsConstructor
@EqualsAndHashCode(callSuper = false)
public class Organization extends AbstractJSContactType implements HasContexts, IsIANAType, IdMapValue, Serializable {
@Pattern(regexp = "Organization", message = "invalid @type value in Organization")
@JsonProperty("@type")
@Builder.Default
String _type = "Organization";
String name;
@Valid
OrgUnit[] units;
String sortAs;
@JsonSerialize(using = ContextsSerializer.class)
@JsonDeserialize(using = ContextsDeserializer.class)
@BooleanMapConstraint(message = "invalid Map contexts in Organization - Only Boolean.TRUE allowed")
@JsonInclude(JsonInclude.Include.NON_EMPTY)
Map contexts;
@JsonIgnore
String group; // used only to search for an organization related to a title/role
}