
it.cnr.iit.jscontact.tools.dto.AnniversaryDate Maven / Gradle / Ivy
package it.cnr.iit.jscontact.tools.dto;
import it.cnr.iit.jscontact.tools.constraints.NotNullAnyConstraint;
import it.cnr.iit.jscontact.tools.dto.utils.DateUtils;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
/**
* Class mapping the "date" property values of the Anniversary type as defined in section 2.8.1 of [draft-ietf-calext-jscontact].
*
* @see draft-ietf-calext-jscontact
* @author Mario Loffredo
*/
@NotNullAnyConstraint(fieldNames = {"date", "partialDate"}, message = "at least one not null member is missing in AnniversaryDate")
@Builder
@Data
@AllArgsConstructor
@NoArgsConstructor
public class AnniversaryDate implements Serializable {
Timestamp date;
PartialDate partialDate;
/**
* Tests if this annivesary date is equal to the given date in text format.
*
* @param text the date in text format
* @return true if this anniversary date is equal to the given date in text format, false otherwise
* @see draft-ietf-calext-jscontact
*/
public boolean isEqual(String text) {
if (this.date != null)
return (this.date.getUtc().compareTo(DateUtils.toCalendar(text))==0);
else
return DateUtils.toJSContactPartialDateText(partialDate).equals(text);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy