001package ezvcard.property;
002
003import java.time.temporal.Temporal;
004
005import ezvcard.SupportedVersions;
006import ezvcard.VCardVersion;
007import ezvcard.util.PartialDate;
008
009/*
010 Copyright (c) 2012-2023, Michael Angstadt
011 All rights reserved.
012
013 Redistribution and use in source and binary forms, with or without
014 modification, are permitted provided that the following conditions are met: 
015
016 1. Redistributions of source code must retain the above copyright notice, this
017 list of conditions and the following disclaimer. 
018 2. Redistributions in binary form must reproduce the above copyright notice,
019 this list of conditions and the following disclaimer in the documentation
020 and/or other materials provided with the distribution. 
021
022 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
023 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
024 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
025 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
026 ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
027 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
028 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
029 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
030 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
031 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
032
033 The views and conclusions contained in the software and documentation are those
034 of the authors and should not be interpreted as representing official policies, 
035 either expressed or implied, of the FreeBSD Project.
036 */
037
038/**
039 * <p>
040 * Defines the person's time of death.
041 * </p>
042 * 
043 * <p>
044 * <b>Code sample (creating)</b>
045 * </p>
046 * 
047 * <pre class="brush:java">
048 * VCard vcard = new VCard();
049 * 
050 * //date
051 * LocalDate date = LocalDate.of(1954, 6, 7);
052 * Deathdate deathdate = new Deathdate(date);
053 * vcard.setDeathdate(deathdate);
054 * 
055 * //partial date (e.g. just the month and date)
056 * deathdate = new Deathdate(PartialDate.date(null, 6, 7)); //June 7
057 * vcard.setDeathdate(deathdate);
058 * 
059 * //plain text value
060 * deathdate = new Deathdate("In the 1950s");
061 * vcard.setDeathdate(deathdate);
062 * </pre>
063 * 
064 * <p>
065 * <b>Code sample (retrieving)</b>
066 * </p>
067 * 
068 * <pre class="brush:java">
069 * VCard vcard = ...
070 * Deathdate deathdate = vcard.getDeathdate();
071 * 
072 * Temporal date = deathdate.getDate();
073 * if (date != null) {
074 *   //property value is a date
075 * }
076 * 
077 * PartialDate partialDate = deathdate.getPartialDate();
078 * if (partialDate != null) {
079 *   //property value is a partial date
080 *   int year = partialDate.getYear();
081 *   int month = partialDate.getMonth();
082 * }
083 * 
084 * String text = deathdate.getText();
085 * if (text != null) {
086 *   //property value is plain text
087 * }
088 * </pre>
089 * 
090 * <p>
091 * <b>Property name:</b> {@code DEATHDATE}
092 * </p>
093 * <p>
094 * <b>Supported versions:</b> {@code 4.0}
095 * </p>
096 * @author Michael Angstadt
097 * @see <a href="http://tools.ietf.org/html/rfc6474#page-4">RFC 6474 p.4</a>
098 */
099@SupportedVersions(VCardVersion.V4_0)
100public class Deathdate extends DateOrTimeProperty {
101        /**
102         * Creates a deathdate property.
103         * @param date the deathdate
104         */
105        public Deathdate(Temporal date) {
106                super(date);
107        }
108
109        /**
110         * Creates a deathdate property.
111         * @param partialDate the deathdate (vCard 4.0 only)
112         */
113        public Deathdate(PartialDate partialDate) {
114                super(partialDate);
115        }
116
117        /**
118         * Creates a deathdate property.
119         * @param text the text value (vCard 4.0 only)
120         */
121        public Deathdate(String text) {
122                super(text);
123        }
124
125        /**
126         * Copy constructor.
127         * @param original the property to make a copy of
128         */
129        public Deathdate(Deathdate original) {
130                super(original);
131        }
132
133        @Override
134        public Deathdate copy() {
135                return new Deathdate(this);
136        }
137}