
it.cnr.iit.jscontact.tools.dto.OnlineService Maven / Gradle / Ivy
/*
* Copyright (C) 2020 Consiglio Nazionale delle Ricerche
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see .
*/
package it.cnr.iit.jscontact.tools.dto;
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.OnlineServiceConstraint;
import it.cnr.iit.jscontact.tools.dto.deserializers.ContextsDeserializer;
import it.cnr.iit.jscontact.tools.dto.deserializers.OnlineServiceTypeDeserializer;
import it.cnr.iit.jscontact.tools.dto.interfaces.HasContexts;
import it.cnr.iit.jscontact.tools.dto.interfaces.HasLabel;
import it.cnr.iit.jscontact.tools.dto.interfaces.IdMapValue;
import it.cnr.iit.jscontact.tools.dto.serializers.ContextsSerializer;
import lombok.*;
import lombok.experimental.SuperBuilder;
import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import java.io.Serializable;
import java.util.Map;
/**
* Class mapping the OnlineService type as defined in section 2.3.2 of [draft-ietf-calext-jscontact].
*
* @see draft-ietf-calext-jscontact
* @author Mario Loffredo
*/
@OnlineServiceConstraint
@JsonPropertyOrder({"@type", "service", "user", "type", "contexts", "pref", "label"})
@JsonInclude(JsonInclude.Include.NON_NULL)
@SuperBuilder
@Data
@AllArgsConstructor
@NoArgsConstructor
@EqualsAndHashCode(callSuper = false)
public class OnlineService extends AbstractJSContactType implements HasLabel, IdMapValue, Serializable, HasContexts {
@NotNull
@Pattern(regexp = "OnlineService", message = "invalid @type value in OnlineService")
@JsonProperty("@type")
@Builder.Default
String _type = "OnlineService";
String service;
@NonNull
@NotNull(message = "user is missing in OnlineService")
String user;
@NonNull
@NotNull(message = "type is missing in OnlineService")
@JsonDeserialize(using = OnlineServiceTypeDeserializer.class)
OnlineServiceType type;
@JsonSerialize(using = ContextsSerializer.class)
@JsonDeserialize(using = ContextsDeserializer.class)
@BooleanMapConstraint(message = "invalid Map contexts in OnlineService - Only Boolean.TRUE allowed")
@JsonInclude(JsonInclude.Include.NON_EMPTY)
@Singular(ignoreNullCollections = true)
Map contexts;
@Min(value = 1, message = "invalid pref in OnlineService - value must be greater or equal than 1")
@Max(value = 100, message = "invalid pref in OnlineService - value must be less or equal than 100")
Integer pref;
String label;
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy