001package org.hl7.fhir.dstu3.model;
002
003import java.util.Calendar;
004import java.util.Date;
005
006import org.apache.commons.lang3.time.DateUtils;
007
008public enum TemporalPrecisionEnum {
009
010        YEAR(Calendar.YEAR) {
011                @Override
012                public Date add(Date theInput, int theAmount) {
013                        return DateUtils.addYears(theInput, theAmount);
014                }
015        },
016
017        MONTH(Calendar.MONTH) {
018                @Override
019                public Date add(Date theInput, int theAmount) {
020                        return DateUtils.addMonths(theInput, theAmount);
021                }
022        },
023        DAY(Calendar.DATE) {
024                @Override
025                public Date add(Date theInput, int theAmount) {
026                        return DateUtils.addDays(theInput, theAmount);
027                }
028        },
029        MINUTE(Calendar.MINUTE) {
030                @Override
031                public Date add(Date theInput, int theAmount) {
032                        return DateUtils.addMinutes(theInput, theAmount);
033                }
034        },
035        SECOND(Calendar.SECOND) {
036                @Override
037                public Date add(Date theInput, int theAmount) {
038                        return DateUtils.addSeconds(theInput, theAmount);
039                }
040        },
041        MILLI(Calendar.MILLISECOND) {
042                @Override
043                public Date add(Date theInput, int theAmount) {
044                        return DateUtils.addMilliseconds(theInput, theAmount);
045                }
046        },
047
048        ;
049
050        private int myCalendarConstant;
051
052        TemporalPrecisionEnum(int theCalendarConstant) {
053                myCalendarConstant = theCalendarConstant;
054        }
055
056        public abstract Date add(Date theInput, int theAmount);
057
058        public int getCalendarConstant() {
059                return myCalendarConstant;
060        }
061
062}